List of usage examples for org.openqa.selenium.support.ui ExpectedConditions invisibilityOfElementLocated
public static ExpectedCondition<Boolean> invisibilityOfElementLocated(final By locator)
From source file:applango.common.services.Applango.genericApplangoWebsiteActions.java
public static void waitUntilWaitForServerDissappears(WebDriverWait wait) throws IOException { logger.info("Wait until waitbox disappear"); long start = getStartTimeInMillis(); wait.until(ExpectedConditions.invisibilityOfElementLocated((By.id(applangoObject.WAITBOX.getValue())))); getFinishTimeAndCompareToStartTime(start); }
From source file:automated_tests.InitialPopups.java
@Test(priority = 5) public static void clickInstructionsOverlay() { //Wait until the instructions overlay to show up before clicking it wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("instructionsOverlayHeader"))); driver.findElement(By.className("instructionsOverlayHeader")).click(); //Wait until the instructions overlay disappears before continuing wait.until(ExpectedConditions.invisibilityOfElementLocated(By.className("instructionsOverlayHeader"))); System.out.println("Closed instructions overlay"); }
From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebBase.java
License:Open Source License
/** * Mtodo que verifica em todas as classes se existe um componente Loading, * e se existir, ele sempre espera que este elemento desaparea antes de * continuar./*from w w w .ja v a 2 s . c om*/ */ @SuppressWarnings("unchecked") public void waitLoading() { driver = (WebDriver) runner.getDriver(); driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS); if (!alreadySearchLoadingMap) { alreadySearchLoadingMap = true; Reflections reflections = new Reflections(""); Set<Class<?>> annotatedClasses = reflections.getTypesAnnotatedWith(ScreenMap.class); for (Class<?> clazzI : annotatedClasses) { HashSet<Field> fields = (HashSet<Field>) ReflectionUtils.getAllFields(clazzI, ReflectionUtils.withAnnotation(ElementMap.class), ReflectionUtils.withTypeAssignableTo(Loading.class)); if (fields.size() == 1) { for (Field field : fields) { loadingMap = field.getAnnotation(ElementMap.class); } } } } if (loadingMap != null) { boolean existeLoading; try { // Verifica se existe o LOADING ExpectedConditions .presenceOfElementLocated( ByConverter.convert(loadingMap.locatorType(), loadingMap.locator()[0])) .apply(driver); existeLoading = true; log.debug(message.getString("message-loading-visible")); } catch (Exception e) { existeLoading = false; } if (existeLoading) { // Fora esperar o loading aparecer quando o elemento utilizado // tem a propriedade forWaitLoading na anotao @ElementMap if (getElementMap() != null && getElementMap().forceWaitLoading()) { WebDriverWait wait = new WebDriverWait(getDriver(), (BehaveConfig.getRunner_ScreenMaxWait() / 1000)); wait.until(ExpectedConditions.visibilityOfElementLocated( ByConverter.convert(loadingMap.locatorType(), loadingMap.locator()[0]))); log.debug(message.getString("message-force-loading")); } // Aguardo o LOADING desaparecer! WebDriverWait wait = new WebDriverWait(getDriver(), (BehaveConfig.getRunner_ScreenMaxWait() / 1000)); wait.until(ExpectedConditions.invisibilityOfElementLocated( ByConverter.convert(loadingMap.locatorType(), loadingMap.locator()[0]))); log.debug(message.getString("message-loading-invisible")); } } driver.manage().timeouts().implicitlyWait(BehaveConfig.getRunner_ScreenMaxWait(), TimeUnit.MILLISECONDS); }
From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebBase.java
License:Open Source License
public void waitInvisible(int index) { final String locator = getLocatorWithParameters(getElementMap().locator()[index].toString()); final By by = ByConverter.convert(getElementMap().locatorType(), locator); boolean testInvisibility = true; driver = (WebDriver) runner.getDriver(); // Zera o tempo do driver, se no o implicity wait no funciona com o // tempo correto driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS); try {// w w w .ja va 2s .c om // Aguarda o elemento ficar visivel (MinWait) Long waitTimeVis = (BehaveConfig.getRunner_ScreenMinWait() / 1000); WebDriverWait waitVis = new WebDriverWait(driver, waitTimeVis); waitVis.until(ExpectedConditions.visibilityOfElementLocated(by)); testInvisibility = true; } catch (org.openqa.selenium.TimeoutException e) { testInvisibility = false; } if (testInvisibility) { // Aguarda ele sumir Long waitTime = (BehaveConfig.getRunner_ScreenMaxWait() / 1000); WebDriverWait wait = new WebDriverWait(driver, waitTime); wait.until(ExpectedConditions.invisibilityOfElementLocated(by)); } // Volta o tempo padro (maxWait) no driver driver.manage().timeouts().implicitlyWait(BehaveConfig.getRunner_ScreenMaxWait(), TimeUnit.MILLISECONDS); }
From source file:ca.nrc.cadc.web.selenium.AbstractTestWebPage.java
License:Open Source License
protected void waitForElementInvisible(final By by) throws Exception { assert (waitUntil(ExpectedConditions.invisibilityOfElementLocated(by)) != null); }
From source file:ca.nrc.cadc.web.selenium.AbstractTestWebPage.java
License:Open Source License
public void waitForElementNotPresent(final By by) throws Exception { waitUntil(ExpectedConditions.invisibilityOfElementLocated(by)); }
From source file:ca.nrc.cadc.web.selenium.AbstractWebApplicationIntegrationTest.java
License:Open Source License
public void waitForElementInvisible(final By by) throws Exception { assert (waitUntil(ExpectedConditions.invisibilityOfElementLocated(by)) != null); }
From source file:com.atanas.kanchev.testframework.selenium.handlers.Wait.java
License:Apache License
/** * {@inheritDoc}//w w w . ja v a2 s .c om */ @Override public boolean isElementVisible(By locator, boolean visibility, long wait) { if (visibility) try { getWait(wait).until(ExpectedConditions.visibilityOfElementLocated(locator)); return true; } catch (TimeoutException e) { logger.error( "Timeout after waiting " + wait + " for visibility of element by: " + locator.toString()); return false; } else try { getWait(wait).until(ExpectedConditions.invisibilityOfElementLocated(locator)); return true; } catch (TimeoutException e) { logger.error("Timeout after waiting " + wait + " for invisibility of element by: " + locator.toString()); throw new TimeoutException(e.getMessage()); } }
From source file:com.autocognite.appium.lib.base.AbstractAppiumUiDriver.java
License:Apache License
@Override public void waitForElementInvisibility(By findBy) throws Exception { getWaiter().until(ExpectedConditions.invisibilityOfElementLocated(findBy)); }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void waitForElementNotFound(String guiElementDescription, int timeoutInSeconds) { String msg = "Wait %ss for [%s] on page [%s]"; log.debug(String.format(msg, timeoutInSeconds, guiElementDescription, this.getClass().getSimpleName())); try {//from w w w .j a v a2 s . com Boolean e = (new WebDriverWait(webDriver, timeoutInSeconds)) .until(ExpectedConditions.invisibilityOfElementLocated(getSelector(guiElementDescription))); log.debug("Element found"); if (e == true) { return; } else { throw new ElementNotVisibleException(guiElementDescription + " is still on the page."); } } catch (TimeoutException toe) { return; } catch (WebDriverException e) { return; } }