List of usage examples for org.openqa.selenium.support.ui ExpectedConditions invisibilityOfElementLocated
public static ExpectedCondition<Boolean> invisibilityOfElementLocated(final By locator)
From source file:io.ddavison.conductor.Locomotive.java
License:Open Source License
public Locomotive selectOptionByText(By by, String text) { Select box = new Select(waitForElement(by)); waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by))) .waitForCondition(ExpectedConditions.elementToBeClickable(by)); box.selectByVisibleText(text);/*from ww w .j av a 2 s .c o m*/ return this; }
From source file:io.ddavison.conductor.Locomotive.java
License:Open Source License
public Locomotive selectOptionByValue(By by, String value) { Select box = new Select(waitForElement(by)); waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by))) .waitForCondition(ExpectedConditions.elementToBeClickable(by)); box.selectByValue(value);/*www .jav a 2 s. c o m*/ return this; }
From source file:io.federecio.dropwizard.swagger.selenium.DefaultServerWithApiAndAuthHiddenSeleniumTest.java
License:Apache License
@Test public void testFieldsAssetsAreNotVisible() throws Exception { driver.get(getSwaggerUrl());// w w w . j a v a 2 s .com driver.manage().timeouts().implicitlyWait(WAIT_IN_SECONDS, TimeUnit.SECONDS); // Check for invisibility of JSON document selector By inputSelector = By.xpath("#input_baseUrl"); new WebDriverWait(driver, WAIT_IN_SECONDS) .until(ExpectedConditions.invisibilityOfElementLocated(inputSelector)); By explore = By.xpath("#explore"); new WebDriverWait(driver, WAIT_IN_SECONDS).until(ExpectedConditions.invisibilityOfElementLocated(explore)); // Check for invisilibity of auth fields By apiKey = By.xpath("#input_apiKey"); new WebDriverWait(driver, WAIT_IN_SECONDS).until(ExpectedConditions.invisibilityOfElementLocated(apiKey)); By authHeader = By.xpath("#input_authHeader"); new WebDriverWait(driver, WAIT_IN_SECONDS) .until(ExpectedConditions.invisibilityOfElementLocated(authHeader)); By apiSelector = By.xpath("#input_headerSelect"); new WebDriverWait(driver, WAIT_IN_SECONDS) .until(ExpectedConditions.invisibilityOfElementLocated(apiSelector)); }
From source file:io.openvidu.test.OpenViduClientBrowserTest.java
License:Apache License
public void waitWhileElement(String label, Browser browser, String id) throws TimeoutException { int originalTimeout = 60; try {//from w w w .j av a2 s . c o m originalTimeout = browser.getTimeout(); log.debug("Original browser timeout (s): {}, set to 1", originalTimeout); browser.setTimeout(1); browser.changeTimeout(1); new WebDriverWait(browser.getWebDriver(), testTimeout, POLLING_LATENCY) .until(ExpectedConditions.invisibilityOfElementLocated(By.id(id))); } catch (org.openqa.selenium.TimeoutException e) { log.warn("Timeout when waiting for element {} to disappear in browser {}", id, label, e); throw new TimeoutException( "Element with id='" + id + "' is present in page after " + testTimeout + " seconds"); } finally { browser.setTimeout(originalTimeout); browser.changeTimeout(originalTimeout); } }
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_Start_Scan_Health_Check(WebDriver driver) { driver.findElement(By.cssSelector("form[id='health_check__scan_store'] input[name='site_url']")) .sendKeys("https://www.iwdagency.com/extensions/"); driver.findElement(By.cssSelector("#health_check__scan_store>button")).click(); WebDriverWait wait1 = new WebDriverWait(driver, 10); try {//w w w.j a v a 2 s . c om wait1.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#healthcheck__overlay"))); wait1.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("#healthcheck__overlay"))); } catch (org.openqa.selenium.NoSuchElementException | TimeoutException e) { System.out.println("#healthcheck__overlay not visible"); //.health_cheack__cancel } }
From source file:IWDmainsiteProject.PageObjects.Verify_Pages.java
public static void Verify_Scan_My_Store_Health_Check(WebDriver driver) { driver.findElement(By.cssSelector("form[id='health_check__site_url'] input[name='site_url']")) .sendKeys("https://www.iwdagency.com/extensions/"); driver.findElement(By.cssSelector("#health_check__site_url>button")).click(); WebDriverWait wait1 = new WebDriverWait(driver, 10); try {/*from w w w .j a v a 2 s . co m*/ wait1.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#healthcheck__overlay"))); wait1.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("#healthcheck__overlay"))); } catch (org.openqa.selenium.NoSuchElementException | TimeoutException e) { System.out.println("#healthcheck__overlay not visible"); } String TextLink1 = driver.findElement(By.cssSelector(".site_url")).getText(); System.out.println(TextLink1); String expectedlink1 = "https://www.iwdagency.com/extensions/"; assertEquals(TextLink1, expectedlink1); System.out.println("Link is correct https://www.iwdagency.com/extensions"); driver.findElement(By.cssSelector(".health_check__remove.fa.fa-times")).click(); wait1.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".site_url"))); System.out.println("Link was removed"); driver.findElement(By.cssSelector("form[id='health_check__scan_url'] input[name='site_url']")) .sendKeys("http://dev.weeetail.com/extensions/"); driver.findElement(By.cssSelector("#health_check__scan_url>button")).click(); try { wait1.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#healthcheck__overlay"))); wait1.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("#healthcheck__overlay"))); } catch (org.openqa.selenium.NoSuchElementException | TimeoutException e) { System.out.println("#healthcheck__overlay not visible"); } String TextLink2 = driver.findElement(By.cssSelector(".site_url")).getText(); System.out.println(TextLink2); String expectedlink2 = "http://dev.weeetail.com/extensions/"; assertEquals(TextLink2, expectedlink2); System.out.println("Link is correct dev.m2ce.deviwd.com"); }
From source file:javax.portlet.tck.driver.TCKSimpleTestDriver.java
License:Apache License
/** * Looks for a link or button that can be clicked for the TC and clicks it if found. * //from w ww.ja v a 2 s . com * First looks for a test case setup link or button and clicks it if found. Then it * looks for a test case execution link and clicks it if found. * * @return web element list containing the test case results. * @throws Exception */ @SuppressWarnings("unused") protected List<WebElement> processClickable(List<WebElement> wels) throws Exception { String setupId = tcName + Constants.SETUP_ID; String actionId = tcName + Constants.CLICK_ID; String resultId = tcName + Constants.RESULT_ID; String detailId = tcName + Constants.DETAIL_ID; String asyncId = tcName + Constants.ASYNC_ID; String notreadyId = tcName + Constants.NOTREADY_ID; List<WebElement> tcels = null; for (WebElement wel : wels) { tcels = wel.findElements(By.id(setupId)); if (!tcels.isEmpty()) break; } debugLines.add(" Setup link found: " + ((tcels != null) && !tcels.isEmpty())); // If were dealing with async, make sure the JavaScript is initialized List<WebElement> acels = driver.findElements(By.id(asyncId)); debugLines.add(" Async elements found: " + ((acels != null) && !acels.isEmpty())); if (acels != null && !acels.isEmpty()) { WebDriverWait wdw = new WebDriverWait(driver, timeout); wdw.until(ExpectedConditions.invisibilityOfElementLocated(By.id(notreadyId))); debugLines.add(" Async elements are now ready."); } // Click setup link if found if ((tcels != null) && !tcels.isEmpty()) { WebElement wel = tcels.get(0); if (scroll) { JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver; javascriptExecutor.executeScript( "window.scrollTo(0, (arguments[0].getBoundingClientRect().top + window.pageYOffset) - (window.innerHeight / 2));", wel); } wel.click(); debugLines.add(" Clicked setup link."); WebDriverWait wdw = new WebDriverWait(driver, timeout); String expr = "//*[@id='" + resultId + "'] | //*[@id='" + actionId + "']"; debugLines.add(" xpath string: ===" + expr + "==="); wdw.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(expr))); wels = driver.findElements(By.name(tcName)); debugLines.add(" Found elements: " + (!wels.isEmpty())); List<WebElement> xels = driver.findElements(By.xpath(expr)); for (WebElement w : xels) { debugLines.add(" Element: " + w.getTagName() + ", id=" + w.getAttribute("id")); } } // Now click the action link, if present for (WebElement wel : wels) { tcels = wel.findElements(By.id(actionId)); if (!tcels.isEmpty()) break; } debugLines.add(" Clickable link found: " + ((tcels != null) && !tcels.isEmpty())); if (tcels != null && !tcels.isEmpty()) { WebElement wel = tcels.get(0); if (scroll) { JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver; javascriptExecutor.executeScript( "window.scrollTo(0, (arguments[0].getBoundingClientRect().top + window.pageYOffset) - (window.innerHeight / 2));", wel); } wel.click(); WebDriverWait wdw = new WebDriverWait(driver, timeout); wdw.until(ExpectedConditions.visibilityOfElementLocated(By.id(resultId))); wels = driver.findElements(By.name(tcName)); if ((wels == null) || wels.isEmpty()) { throw new Exception("Test case " + tcName + " failed. No results after action link click."); } } return wels; }
From source file:javax.portlet.tck.driver.TCKTestDriver.java
License:Apache License
/** * Looks for a link or button that can be clicked for the TC and clicks it if found. * /* w w w . j a v a 2s .co m*/ * First looks for a test case setup link or button and clicks it if found. Then it * looks for a test case execution link and clicks it if found. * * @return web element list containing the test case results. * @throws Exception */ @SuppressWarnings("unused") protected List<WebElement> processClickable(List<WebElement> wels) throws Exception { String setupId = tcName + Constants.SETUP_ID; String actionId = tcName + Constants.CLICK_ID; String resultId = tcName + Constants.RESULT_ID; String detailId = tcName + Constants.DETAIL_ID; String asyncId = tcName + Constants.ASYNC_ID; String notreadyId = tcName + Constants.NOTREADY_ID; List<WebElement> tcels = null; for (WebElement wel : wels) { tcels = wel.findElements(By.id(setupId)); if (!tcels.isEmpty()) break; } debugLines.add(" Setup link found: " + ((tcels != null) && !tcels.isEmpty())); // If were dealing with async, make sure the JavaScript is initialized List<WebElement> acels = driver.findElements(By.id(asyncId)); debugLines.add(" Async elements found: " + ((acels != null) && !acels.isEmpty())); if (acels != null && !acels.isEmpty()) { WebDriverWait wdw = new WebDriverWait(driver, timeout); wdw.until(ExpectedConditions.invisibilityOfElementLocated(By.id(notreadyId))); debugLines.add(" Async elements are now ready."); } // Click setup link if found if ((tcels != null) && !tcels.isEmpty()) { WebElement wel = tcels.get(0); if (scroll) { JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver; javascriptExecutor.executeScript( "window.scrollTo(0, (arguments[0].getBoundingClientRect().top + window.pageYOffset) - (window.innerHeight / 2));", wel); } try { wel.click(); } catch (StaleElementReferenceException e) { System.out.println("setup link: " + e.getClass().getName() + " caught when trying to use WebElements found with " + tcName); wels = driver.findElements(By.name(tcName)); for (WebElement welly : wels) { tcels = welly.findElements(By.id(setupId)); if (!tcels.isEmpty()) break; } wel = tcels.get(0); wel.click(); } debugLines.add(" Clicked setup link."); WebDriverWait wdw = new WebDriverWait(driver, timeout); String expr = "//*[@id='" + resultId + "'] | //*[@id='" + actionId + "']"; debugLines.add(" xpath string: ===" + expr + "==="); wdw.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(expr))); wels = driver.findElements(By.name(tcName)); debugLines.add(" Found elements: " + (!wels.isEmpty())); List<WebElement> xels = driver.findElements(By.xpath(expr)); for (WebElement w : xels) { debugLines.add(" Element: " + w.getTagName() + ", id=" + w.getAttribute("id")); } } // Now click the action link, if present for (WebElement wel : wels) { tcels = wel.findElements(By.id(actionId)); if (!tcels.isEmpty()) break; } debugLines.add(" Clickable link found: " + ((tcels != null) && !tcels.isEmpty())); if (tcels != null && !tcels.isEmpty()) { WebElement wel = tcels.get(0); if (scroll) { JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver; javascriptExecutor.executeScript( "window.scrollTo(0, (arguments[0].getBoundingClientRect().top + window.pageYOffset) - (window.innerHeight / 2));", wel); } try { wel.click(); } catch (StaleElementReferenceException e) { System.out.println("action link: " + e.getClass().getName() + " caught when trying to use WebElements found with " + tcName); wels = driver.findElements(By.name(tcName)); for (WebElement welly : wels) { tcels = welly.findElements(By.id(actionId)); if (!tcels.isEmpty()) break; } wel = tcels.get(0); wel.click(); } WebDriverWait wdw = new WebDriverWait(driver, timeout); wdw.until(ExpectedConditions.visibilityOfElementLocated(By.id(resultId))); wels = driver.findElements(By.name(tcName)); if ((wels == null) || wels.isEmpty()) { throw new Exception("Test case " + tcName + " failed. No results after action link click."); } } return wels; }
From source file:OnlineStore.CartTest.java
/** * Given 1 iphone5 in the cart/*from www. j av a 2s . c o m*/ * When I try to remove it from cart * Then I should see an empty cart */ @Test public void removeProduct() throws InterruptedException { driver.get("http://store.demoqa.com/products-page/product-category/n/"); driver.findElement(By.name("Buy")).submit(); driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); driver.get("http://store.demoqa.com/products-page/checkout/"); driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); WebElement remove = driver.findElement(By.cssSelector("form.adjustform.remove > input[name=\"submit\"]")); remove.click(); if (wait.until(ExpectedConditions .invisibilityOfElementLocated(By.cssSelector("form.adjustform.remove > input[name=\"submit\"]")))) ; WebElement msg = driver.findElement(By.xpath("//*[@id=\"post-29\"]/div")); String str = msg.getText(); assertEquals("Oops, there is nothing in your cart.", str); }
From source file:org.alfresco.po.common.util.Utils.java
License:Open Source License
/** * Helper method to wait for the invisibility of an element located * by selector/*from w w w. j a v a 2 s.c o m*/ */ public static void waitForInvisibilityOf(By locator) { webDriverWait().until(ExpectedConditions.invisibilityOfElementLocated(locator)); }