List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait
public WebDriverWait(WebDriver driver, Duration timeout)
From source file:StoryKeyboardShortcutTests.java
@Test public void storyKeyDelete() throws InterruptedException { //a. Launch story in firefox driver.get(//from w ww . j a va 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(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 ww w . j av 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:StoryKeyboardShortcutTests.java
@Test public void storyKeyboardMute() throws InterruptedException { //1. Go to story site driver.get(//from w w w. j av 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']"))); //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:ExperimentRunner.java
License:Apache License
protected void runExperiment(String url, Hashtable<String, ArrayList<String>> store) { driver.get(url);/*ww w . j av a 2s.co m*/ // for octane, if an element with id="jit_final_result" contains text "===experiment done===" new WebDriverWait(driver, maxWaitTime).until(ExpectedConditions .textToBePresentInElementLocated(By.id("jit_final_result"), "===experiment done===")); System.out.println("text found in element"); String expResult = driver.findElement(By.id("jit_final_result")).getAttribute("innerHTML"); System.out.println(expResult); processRecordConsoleOutput(expResult, store); }
From source file:seleniumTester.java
@Test public void test1() { (new WebDriverWait(driver, WAIT_MAX)).until((ExpectedCondition<Boolean>) (WebDriver d) -> { WebElement e = d.findElement(By.tagName("tbody")); List<WebElement> rows = e.findElements(By.tagName("tr")); return rows.size() == 5; });/*from w w w . ja v a 2 s . co m*/ }
From source file:seleniumTester.java
@Test public void test2() throws Exception { WebElement element = driver.findElement(By.id("filter")); element.sendKeys("1999"); (new WebDriverWait(driver, WAIT_MAX)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { WebElement e = d.findElement(By.tagName("tbody")); List<WebElement> rows = e.findElements(By.tagName("tr")); return rows.size() == 2; }/*from w w w. jav a 2s.co m*/ }); }
From source file:seleniumTester.java
@Test public void test3() { WebElement element = driver.findElement(By.id("filter")); element.sendKeys(Keys.CONTROL + "a"); element.sendKeys(Keys.DELETE);// w w w.ja v a 2s .c o m (new WebDriverWait(driver, WAIT_MAX)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { WebElement e = d.findElement(By.tagName("tbody")); List<WebElement> rows = e.findElements(By.tagName("tr")); Assert.assertThat(rows.size(), is(5)); return rows.size() == 5; } }); }
From source file:seleniumTester.java
@Test public void test_5() { List<WebElement> tds = driver.findElement(By.id("tbodycars")).findElements(By.cssSelector("tr")).get(0) .findElements(By.tagName("td")); tds.get(7).findElements(By.tagName("a")).get(0).click(); WebElement element = driver.findElement(By.id("description")); element.sendKeys(Keys.CONTROL + "a"); element.sendKeys(Keys.DELETE);//from w ww . j a v a 2 s. c o m element.sendKeys("Cool car"); driver.findElement(By.id("save")).click(); (new WebDriverWait(driver, WAIT_MAX)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { WebElement e = d.findElement(By.tagName("tbody")); List<WebElement> rows = e.findElements(By.tagName("tr")); String result = null; for (int i = 0; i < rows.size(); i++) { if (rows.get(i).findElements(By.tagName("td")).get(0).getText().equalsIgnoreCase("938")) { result = rows.get(i).findElements(By.tagName("td")).get(5).getText(); break; } } assertThat(result, is("Cool car")); return true; } }); }
From source file:WaitTool.java
License:Open Source License
/** * Wait for the element to be present in the DOM, and displayed on the page. * And returns the first WebElement using the given method. * * @param WebDriver The driver object to be used * @param By selector to find the element * @param int The time in seconds to wait until returning a failure * * @return WebElement the first WebElement using the given method, or null (if the timeout is reached) *///from w w w . j a v a 2s . c o m public static WebElement waitForElement(WebDriver driver, final By by, int timeOutInSeconds) { WebElement element; try { //To use WebDriverWait(), we would have to nullify implicitlyWait(). //Because implicitlyWait time also set "driver.findElement()" wait time. //info from: https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/6VO_7IXylgY driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify implicitlyWait() WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds); element = wait.until(ExpectedConditions.visibilityOfElementLocated(by)); driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); //reset implicitlyWait return element; //return the element } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:WaitTool.java
License:Open Source License
/** * Wait for the element to be present in the DOM, regardless of being displayed or not. * And returns the first WebElement using the given method. * * @param WebDriver The driver object to be used * @param By selector to find the element * @param int The time in seconds to wait until returning a failure * * @return WebElement the first WebElement using the given method, or null (if the timeout is reached) */// w ww . j a v a 2 s . co m public static WebElement waitForElementPresent(WebDriver driver, final By by, int timeOutInSeconds) { WebElement element; try { driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); //nullify implicitlyWait() WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds); element = wait.until(ExpectedConditions.presenceOfElementLocated(by)); driver.manage().timeouts().implicitlyWait(DEFAULT_WAIT_4_PAGE, TimeUnit.SECONDS); //reset implicitlyWait return element; //return the element } catch (Exception e) { e.printStackTrace(); } return null; }