List of usage examples for org.openqa.selenium.interactions Actions sendKeys
public Actions sendKeys(CharSequence... keys)
From source file:StoryKeyboardShortcutTests.java
@Test public void storyFirstTest() throws InterruptedException { //1. Go to story site driver.get(/* w ww . jav a2 s . c o m*/ "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc"); //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"))); //2. Close the license popup WebElement okButton = driver.findElement(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")); okButton.click(); //Click on Media tab WebElement uploadButton = driver.findElement( By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td")); uploadButton.click(); //Click on video tab WebElement videoTab = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[1]/div/div/div/table[1]/tbody[2]/tr[1]/td[1]/div/div/div[2]")); videoTab.click(); WebElement searchText = driver.findElement(By.id("isc_30")); searchText.sendKeys("SSS_2477_01.mov"); Thread.sleep(5000); WebElement selectVideo = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div[1]/div[3]")); selectVideo.click(); WebElement selectVideo1 = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div[1]/div[3]")); selectVideo1.click(); Thread.sleep(2000); WebElement timeLine = driver.findElement(By.cssSelector("svg[id=multimedia_ClearInOut]")); timeLine.click(); Thread.sleep(2000); int xp1 = 0; WebElement testtimecode1 = driver.findElement(By.xpath("//*[contains(text(),'00:0" + xp1 + ":')]")); final String starttime = testtimecode1.getText(); Actions action = new Actions(driver); action.sendKeys(Keys.SPACE).build().perform(); System.out.println(testtimecode1.getText()); int ourtime = 9000; Thread.sleep(ourtime); int xp = (ourtime - 1000) / 1000; action.sendKeys(Keys.SPACE).build().perform(); Thread.sleep(2000); timeLine.click(); Thread.sleep(2000); WebElement testtimecode = driver.findElement(By.xpath("//*[contains(text(),'00:0" + xp + ":')]")); System.out.println(testtimecode.getText()); System.out.println(testtimecode1.getText()); Assert.assertNotEquals(testtimecode.getText(), starttime); //Assert.assertNotEquals("111", "1"); }
From source file:StoryKeyboardShortcutTests.java
@Test public void storyKeyboardFrameForward() throws InterruptedException { //a. Launch story in firefox driver.get(//from ww w . ja v a 2s .c o m "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc"); //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"))); //Close the license popup WebElement okButton = driver.findElement(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")); okButton.click(); //Click on Media tab WebElement uploadButton = driver.findElement( By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td")); uploadButton.click(); //From storytab double click on story named 'storytest' Thread.sleep(2000); WebElement storytest = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]")); storytest.click(); WebElement storytest1 = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]")); storytest1.click(); storytest1.click(); Thread.sleep(3000); //Select the video element in timeline div[class="thumbnailStrip"] WebElement timelinebar = driver.findElement(By.cssSelector("div[class='thumbnailStrip']")); timelinebar.click(); Thread.sleep(2000); WebElement timebarnumber = driver.findElement( By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']")); final String timevalue = timebarnumber.getText(); WebElement timebarnumber1 = driver.findElement( By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']")); final String timevalue1 = timebarnumber.getText(); System.out.println(timevalue); Thread.sleep(2000); Actions action = new Actions(driver); action.sendKeys(Keys.DECIMAL).build().perform(); WebElement timebarnumber2 = driver.findElement( By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']//small")); final String timevalue2 = timebarnumber.getText(); final String firsttime = (timevalue1.substring(timevalue2.lastIndexOf(":") + 1)); int timer1 = Integer.parseInt(firsttime); final String secondtime = (timevalue2.substring(timevalue2.lastIndexOf(":") + 1)); int timer2 = Integer.parseInt(secondtime); System.out.println(timer1); System.out.println(timer2); Assert.assertEquals(timer1 + 1, timer2); }
From source file:StoryKeyboardShortcutTests.java
@Test public void storyKeyboardFrameBackward() throws InterruptedException { //a. Launch story in firefox driver.get(/*from ww w .j a va 2 s .co m*/ "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc"); //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"))); //Close the license popup WebElement okButton = driver.findElement(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")); okButton.click(); //Click on Media tab WebElement uploadButton = driver.findElement( By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td")); uploadButton.click(); //From storytab double click on story named 'storytest' Thread.sleep(2000); WebElement storytest = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]")); storytest.click(); WebElement storytest1 = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]")); storytest1.click(); storytest1.click(); Thread.sleep(3000); //Select the video element in timeline div[class="thumbnailStrip"] WebElement timelinebar = driver.findElement(By.cssSelector("div[class='thumbnailStrip']")); timelinebar.click(); Thread.sleep(2000); WebElement timebarnumber = driver.findElement( By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']")); final String timevalue = timebarnumber.getText(); WebElement timebarnumber1 = driver.findElement( By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']")); final String timevalue1 = timebarnumber.getText(); System.out.println(timevalue); Thread.sleep(2000); Actions action = new Actions(driver); action.sendKeys(Keys.SEPARATOR).build().perform(); WebElement timebarnumber2 = driver.findElement( By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']//small")); final String timevalue2 = timebarnumber.getText(); final String firsttime = (timevalue1.substring(timevalue2.lastIndexOf(":") + 1)); int timer1 = Integer.parseInt(firsttime); final String secondtime = (timevalue2.substring(timevalue2.lastIndexOf(":") + 1)); int timer2 = Integer.parseInt(secondtime); System.out.println(timer1); System.out.println(timer2); Assert.assertEquals(timer1 - 1, timer2); }
From source file:StoryKeyboardShortcutTests.java
@Test public void storyKeyDelete() throws InterruptedException { //a. Launch story in firefox driver.get(//from w ww. j av a 2 s. c om "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc"); //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"))); //Close the license popup WebElement okButton = driver.findElement(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")); okButton.click(); //Click on Media tab WebElement uploadButton = driver.findElement( By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td")); uploadButton.click(); //From storytab double click on story named 'storytest' Thread.sleep(2000); WebElement storytest = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]")); storytest.click(); WebElement storytest1 = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]")); storytest1.click(); storytest1.click(); Thread.sleep(3000); //Select the video element in timeline div[class="thumbnailStrip"] WebElement timelinebar = driver.findElement(By.cssSelector("div[class='thumbnailStrip']")); timelinebar.click(); Thread.sleep(2000); WebElement timebarnumber = driver.findElement( By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']")); final String timevalue = timebarnumber.getText(); WebElement timebarnumber1 = driver.findElement( By.xpath("//div[contains(@style,'POSITION') and @eventproxy='sta_timeline_cursorlabel_1']")); final String timevalue1 = timebarnumber.getText(); Actions action = new Actions(driver); //Asserting if presence of element shows false after deletion button is pressed action.sendKeys(Keys.DELETE).build().perform(); Boolean isPresent2 = driver.findElements(By.cssSelector("div[class='thumbnailStrip']")).size() > 0; Assert.assertEquals(false, isPresent2); // Undoing the change to timeline by pressing 'CTRL + Z' Thread.sleep(2000); Actions action2 = new Actions(driver); action2.keyDown(Keys.CONTROL).sendKeys(String.valueOf('\u007A')).perform(); /* Thread.sleep(2000); Actions action = new Actions(driver); //String selectAll = Keys.chord(Keys.CONTROL, "a"); action.sendKeys(".").perform(); // action.sendKeys(selectAll).build().perform(); //action.sendKeys(Keys.getKeyFromUnicode('selectAll')).build().perform(); */ }
From source file:StoryKeyboardShortcutTests.java
@Test public void storyKeyVolumeBar() throws InterruptedException { //a. Launch story in firefox driver.get(//from w w w . ja v a 2 s . c o m "http://tanveer-pc:9724/web/story/story.html?debug&storyhub=tanveer-pc&gh=Guest/@tanveer-pc&pilot=tanveer-pc&preview=tanveer-pc&mediaservice=tanveer-pc"); //driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 15); wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']"))); //Close the license popup WebElement okButton = driver.findElement(By.cssSelector( "img[src='http://tanveer-pc:9724/web/story/story/sc/skins/vizrt/images/Editor/Close.png']")); okButton.click(); //Click on Media tab WebElement uploadButton = driver.findElement( By.xpath("html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[1]/div[1]/div/table/tbody/tr/td")); uploadButton.click(); //From storytab double click on story named 'storytest' Thread.sleep(2000); WebElement storytest = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]")); storytest.click(); WebElement storytest1 = driver.findElement(By.xpath( "html/body/div[4]/div/div[1]/div/div[1]/div/div[2]/div[3]/div/div/div/div/div[2]/div[2]/div[3]/div/div[3]")); storytest1.click(); storytest1.click(); Thread.sleep(3000); //Select the video element in timeline div[class="thumbnailStrip"] WebElement timelinebar = driver.findElement(By.cssSelector("div[class='thumbnailStrip']")); timelinebar.click(); Thread.sleep(3000); Actions action = new Actions(driver); action.sendKeys("a").perform(); //html/body/div[7]/div/div Boolean isPresent2 = driver.findElements(By.xpath("html/body/div[7]/div/div")).size() > 0; System.out.println(isPresent2); Assert.assertEquals(false, isPresent2); }
From source file:cat.calidos.morfeu.webapp.ui.UIWidget.java
License:Apache License
@SuppressWarnings("unchecked") public T pressKey(String k) { // we are sending the keys this way as it seems to work as it should, selenide or selenium has a lot of trouble here Actions actions = new Actions(driver); //actions.moveToElement(element.getWrappedElement()); //actions.click(); actions.sendKeys(Keys.chord((CharSequence) k)); actions.build().perform();/*from ww w . j a v a 2 s . c o m*/ // this keeps failing randomly try { Thread.sleep(50); } catch (InterruptedException e) { } return (T) this; }
From source file:cat.calidos.morfeu.webapp.ui.UIWidget.java
License:Apache License
@SuppressWarnings("unchecked") public T pressBackspace() { WebDriver driver = element.getWrappedDriver(); Actions actions = new Actions(driver); actions.sendKeys(Keys.BACK_SPACE); actions.build().perform();//from www. j a v a 2s .com return (T) this; }
From source file:com.ataco.erzeta.TC_RZ_1.java
/** * TC-RZ-3 (hlavn)//from w w w . j a v a 2 s. c o m * Test na vytvoen nov rezervace. */ @Test public void testAddNewReservation() { clickPlusButton(); NativeSelectElement sourceSelect = $(NativeSelectElement.class).first(); sourceSelect.selectByText(testedSourceName); Calendar c = Calendar.getInstance(); c.setTime(new Date()); c.add(Calendar.DATE, 2); int day = c.get(Calendar.DAY_OF_MONTH); TestBenchElement datepicker = (TestBenchElement) findElements( By.cssSelector(".v-touchkit-datepicker-datePickerDetailView")).get(1); datepicker.focus(); datepicker.click(); Actions actions = new Actions(getDriver()); actions.sendKeys(Integer.toString(day)); actions.build().perform(); SliderElement slider1 = $(SliderElement.class).first(); slider1.click(); actions = new Actions(getDriver()); for (int i = 1; i < quantity; i++) { actions.sendKeys(Keys.ARROW_RIGHT); } actions.build().perform(); TextAreaElement descriptionTextArea = $(TextAreaElement.class).caption("Popis:").first(); descriptionTextArea.setValue(testedDescription); ButtonElement saveButton = $(ButtonElement.class).caption("ULOIT").first(); saveButton.click(); sleep(500); testDataFromNewReservation(); }
From source file:com.ataco.erzeta.TC_RZ_3.java
/** * TC-RZ-3 (hlavn)/*from w w w . j a va 2 s .c om*/ * Test na vytvoen novho zdroje */ @Test public void testAddNewSource() { NativeButtonElement menuButton = $(NativeButtonElement.class).caption("").first(); menuButton.click(); sleep(500); NativeButtonElement sourcesButton = $(NativeButtonElement.class).caption("Zdroje").first(); sourcesButton.click(); sleep(500); clickPlusButton(); sleep(500); TextFieldElement nameLabel = $(TextFieldElement.class).caption("Nzev").first(); nameLabel.setValue(testedSourceName); Calendar c = Calendar.getInstance(); c.setTime(new Date()); TestBenchElement existSince = (TestBenchElement) findElements(By.cssSelector(".v-touchkit-datepicker")) .get(0); existSince.focus(); existSince.click(); String sequence = String.format( "%s" + Integer.toString(c.get(Calendar.DAY_OF_MONTH)) + "%s" + Integer.toString(c.get(Calendar.MONTH)) + Integer.toString(c.get(Calendar.YEAR)), c.get(Calendar.DAY_OF_MONTH) < 10 ? "0" : "", c.get(Calendar.MONTH) < 10 ? "0" : ""); Actions actions = new Actions(getDriver()); actions.sendKeys(sequence); actions.build().perform(); TestBenchElement existTill = (TestBenchElement) findElements(By.cssSelector(".v-touchkit-datepicker")) .get(1); existTill.focus(); existTill.click(); actions = new Actions(getDriver()); c.add(Calendar.DATE, 2); sequence = String.format( "%s" + Integer.toString(c.get(Calendar.DAY_OF_MONTH)) + "%s" + Integer.toString(c.get(Calendar.MONTH)) + Integer.toString(c.get(Calendar.YEAR)), c.get(Calendar.DAY_OF_MONTH) < 10 ? "0" : "", c.get(Calendar.MONTH) < 10 ? "0" : ""); actions.sendKeys(sequence); actions.build().perform(); TextFieldElement capacityTextField = $(TextFieldElement.class).caption("Kapacita").first(); capacityTextField.setValue(Integer.toString(capacity)); TestBenchElement publicAccessSwitch = (TestBenchElement) findElement(By.cssSelector(".v-touchkit-switch")); publicAccessSwitch.click(); sleep(100); TextAreaElement descriptionTextArea = $(TextAreaElement.class).caption("Popis").first(); descriptionTextArea.setValue(testedDescription); TestBenchElement authorizationsTab = (TestBenchElement) findElements(By.cssSelector(".v-tabsheet-tabitem")) .get(1); authorizationsTab.click(); clickPlusButton(); NativeSelectElement usernameSelect = $(NativeSelectElement.class).first(); usernameSelect.selectByText("testovaciJmeno testovaciPrijmeni"); NativeButtonElement saveButton = $(NativeButtonElement.class).caption("ULOIT").first(); saveButton.click(); sleep(500); testDataFromNewReservation(); }
From source file:com.cengage.mindtap.keywords.ReadingActivityPageAction.java
public void clickOnEscButton() { Actions action = new Actions(driver); action.sendKeys(Keys.ESCAPE); }