List of usage examples for org.openqa.selenium.support.ui ExpectedConditions presenceOfElementLocated
public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator)
From source file:com.amolik.scrapers.OdishaRationCardScraper.java
public static void waitForSubmit(WebDriver driver, String emptyText, String dataText) { By byText = By.xpath("//table[@id='gvDist']/tbody/tr[1]/td[1][text()='" + emptyText + "']" + "|" + "//table[@id='gvDist']/tbody/tr[3]/td[6][contains(text(),'" + dataText + "')]"); WebElement element = new WebDriverWait(driver, 10) .until(ExpectedConditions.presenceOfElementLocated(byText)); }
From source file:com.arcbees.test.ElementLocator.java
License:Apache License
private WebElement doFindElement() { if (timeout > 0) { return new WebDriverWait(webDriver, timeout).until(ExpectedConditions.presenceOfElementLocated(by)); } else {/*from w w w . j a v a 2 s .c o m*/ return webDriver.findElement(by); } }
From source file:com.ariatemplates.seleniumjavarobot.DebuggableChrome.java
License:Apache License
public DebuggableChrome() { ChromeOptions options = new ChromeOptions(); String debugExtension = System.getProperty("seleniumjavarobot.chrome.debugextension"); if (debugExtension == null || !new File(debugExtension).isDirectory()) { throw new RuntimeException( "Please set the seleniumjavarobot.chrome.debugextension system property to point to the path of the chrome extension."); }/*w w w. j av a 2 s .c o m*/ options.addArguments("load-extension=" + debugExtension); options.addArguments("start-maximized"); webdriver = new ChromeDriver(options); // waits for the extension page to be loaded: (new WebDriverWait(webdriver, 10)) .until(ExpectedConditions.presenceOfElementLocated(By.id("selenium-java-robot"))); webdriver.manage().timeouts().setScriptTimeout(1, TimeUnit.DAYS); }
From source file:com.atanas.kanchev.testframework.selenium.handlers.Wait.java
License:Apache License
/** * {@inheritDoc}//from w ww.ja va2 s.c o m */ @Override public boolean isElementPresent(By locator, long wait) { try { getWait(wait).until(ExpectedConditions.presenceOfElementLocated(locator)); return true; } catch (TimeoutException e) { logger.error("Timeout after waiting for presence 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 waitForElementPresence(By findBy) throws Exception { getWaiter().until(ExpectedConditions.presenceOfElementLocated(findBy)); }
From source file:com.autocognite.appium.lib.base.AbstractAppiumUiDriver.java
License:Apache License
@Override public void waitForElementAbsence(By findBy) throws Exception { try {//from w ww. j a v a 2s.c om getWaiter().until(ExpectedConditions.presenceOfElementLocated(findBy)); throw new Exception("Not able to establish absence of element after polling for same."); } catch (Exception e) { // Do nothing. } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public WebElement findElement(final String locator, int timeOut) { log.debug("debug: Looking for element: " + locator); WebElement e = (new WebDriverWait(webDriver, timeOut)) .until(ExpectedConditions.presenceOfElementLocated(getSelector(locator))); return e;//w w w.j av a 2 s . c o m }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void waitForElementFound(String guiElementDescription, int timeoutInSeconds) { String msg = "Wait %ss for [%s] on page [%s]"; log.debug(String.format(msg, timeoutInSeconds, guiElementDescription, this.getClass())); try {//from ww w . jav a 2s. co m WebElement e = (new WebDriverWait(webDriver, timeoutInSeconds)) .until(ExpectedConditions.presenceOfElementLocated(getSelector(guiElementDescription))); log.debug("DEBUG: Element found"); if (e != null) { return; } else { throw new ElementNotVisibleException(guiElementDescription + " did not load."); } } catch (TimeoutException toe) { throw new ElementNotVisibleException( guiElementDescription + " did not load with TimeoutException " + toe.getMessage()); } }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to find presence of the element in page. * /*from w w w. ja v a2 s.c om*/ * @param by * (by element to be visible in page) * @param timeoutInSeconds * (timeout value in seconds) * @return presenceOfElement (Web element object of the presence element) */ public WebElement findPresenceOfElement(final By by, final int timeoutInSeconds) { WebElement presenceOfElement; try { presenceOfElement = (new WebDriverWait(this.driver, timeoutInSeconds)) .until(ExpectedConditions.presenceOfElementLocated(by)); } catch (Exception e) { String errorMessage = "Could not find presence of element: " + by.toString(); this.logger.logWithScreenShot("Could not find presence of element: " + by.toString(), this.driver); throw new RuntimeException(errorMessage); } return presenceOfElement; }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Checks if is enabled./*from w w w. j a v a 2s.c om*/ * * @param driver the driver * @param locator the locator * @param timeout the timeout * @return true, if is enabled */ public static boolean isEnabled(final WebDriver driver, final By locator, final Timeout timeout) { try { return new WebDriverWait(driver, timeout.getValue()) .until(ExpectedConditions.presenceOfElementLocated(locator)).isEnabled(); } catch (Exception ex) { return false; } }