List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfElementLocated
public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
From source file:BallerinaEditorUITest.java
License:Open Source License
private WebElement waitAndGetElementByXpath(WebDriver driver, String xpath) { WebDriverWait wait = new WebDriverWait(driver, 50); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath))); return driver.findElement(By.xpath(xpath)); }
From source file:StoryKeyboardShortcutTests.java
@Test public void storyFirstTest() throws InterruptedException { //1. Go to story site driver.get(//from ww w . ja 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']"))); //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(// ww w .j a va2 s . com "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 w ww . j a v a 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 ww 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(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(// w w w.j av a2 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(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(// w w 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']"))); //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: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 ava2 s . 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:TestaCadastroProcesso.java
@Test(dependsOnGroups = "login", groups = "required") public void testaMsgNumero() throws Exception { driver.navigate()//from w ww . ja va2s .c o m .to("http://52.1.49.37/SIAPCON_SPRINT11/ListarProcessos.jsf?(Not.Licensed.For.Production)="); driver.navigate().to( "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)="); // gera um tempo de espera para a pgina carregar e o elemento ser renderizado driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS); try { // insere um numero de processo valido WebElement numero = driver .findElement(By.id("RichWidgets_wt95:wtMainContent:wtnumeroProcessoAtualWidget")); numero.sendKeys("000"); // clica no boto submit WebElement submit = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wt38")); submit.click(); // Espera at que o elemento que contm a msg de erro esteja vsivel WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("Feedback_Message_Error"))); // testa se a msg de obrigatoriedade est sendo exibida if (!driver.findElement(By.className("Feedback_Message_Error")).isDisplayed()) { Assert.fail("No est exibindo msg"); } } catch (Exception e) { throw (e); } driver.navigate().to( "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)="); // insere um numero de processo valido WebElement numero = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wtnumeroProcessoAtualWidget")); numero.sendKeys("00000.000000/00"); try { // clica no boto submit WebElement submit = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wt38")); submit.click(); // espera at que o elemento que contm a msg de erro esteja visvel WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("Feedback_Message_Error"))); if (!driver.findElement(By.className("Feedback_Message_Error")).isDisplayed()) { Assert.fail("No est exibindo msg"); } } catch (Exception e) { throw (e); } }
From source file:TestaCadastroProcesso.java
@Test(dependsOnGroups = "required", groups = "salva") public void testaInsercaoProcesso() { driver.navigate().to(//from w w w . jav a2 s. c om "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)="); driver.navigate().to( "http://52.1.49.37/SIAPCON_SPRINT11/ProcessoDetail.jsf?processoId=0&(Not.Licensed.For.Production)="); try { // insere um numero de processo valido WebElement numero = driver .findElement(By.id("RichWidgets_wt95:wtMainContent:wtnumeroProcessoAtualWidget")); numero.sendKeys(proc); // insere um tipo de processo valido WebElement tipo = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wttipoProcessoWidget")); tipo.sendKeys("a"); // clica no boto submit WebElement submit = driver.findElement(By.id("RichWidgets_wt95:wtMainContent:wt38")); submit.click(); // espera at que o boto de encerrar cadastro esteja visvel WebDriverWait wait = new WebDriverWait(driver, 60); wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("corbranca"))); if (!driver.findElement(By.className("corbranca")).isDisplayed()) { Assert.fail("No exibiu o boto encerrar cadastro"); } } catch (Exception e) { throw (e); } }