List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait
public WebDriverWait(WebDriver driver, Duration timeout)
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
/** * Determines if the specified element is visible. An element can be rendered invisible by setting the CSS * "visibility" property to "hidden", or the "display" property to "none", either for the element itself or * one if its ancestors. This method will fail if the element is not present. * * @param locator an <a href="#locators">element locator</a> * @param timeout int time value/* ww w . ja v a2 s . c om*/ * @return true if the specified element is visible, false otherwise */ @Override public boolean isElementVisibleWithWait(String locator, int timeout) { try { (new WebDriverWait(webDriver, timeout)) .until(ExpectedConditions.visibilityOfElementLocated(getSelector(locator))); return true; } catch (Exception e1) { return false; } }
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 w ww. 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.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 ww . j a va2 s. c o m*/ 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; } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void waitForElementVisible(String guiElementDescription, int timeoutInSeconds) { String msg = "Wait %ss for [%s] on page [%s]"; log.debug("waitForElementVisible should time out in " + timeoutInSeconds); log.debug(String.format(msg, timeoutInSeconds, guiElementDescription, this.getClass().getSimpleName())); WebElement e = (new WebDriverWait(webDriver, timeoutInSeconds)) .until(ExpectedConditions.visibilityOfElementLocated(getSelector(guiElementDescription))); log.debug("Element found"); if (e != null) { return;/*www.j a va 2s. c o m*/ } else { throw new ElementNotVisibleException(guiElementDescription + " did not become visible."); } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void waitForElementVisible(WebElement locator, int timeoutInSeconds) throws ElementNotVisibleException { WebElement e = null;//from w w w .ja v a 2s . c o m log.debug("Wait for Element Visible should time out in " + timeoutInSeconds); e = (new WebDriverWait(webDriver, timeoutInSeconds)).until(ExpectedConditions.visibilityOf(locator)); log.debug("end wait for Element Visible"); if (e != null) { return; } else { throw new ElementNotVisibleException(locator.getTagName() + " did not become visible."); } }
From source file:com.chtr.tmoauto.webui.CommonFunctions.java
License:Open Source License
@Override public void waitForElementClickable(String guiElementDescription, int timeoutInSeconds) throws ElementNotVisibleException { WebElement e = null;//from ww w . j a va 2 s . c o m log.debug("Wait for Element Visible should time out in " + timeoutInSeconds); e = (new WebDriverWait(webDriver, timeoutInSeconds)) .until(ExpectedConditions.elementToBeClickable(getSelector(guiElementDescription))); log.debug("end wait for Element Visible"); if (e != null) { return; } else { throw new ElementNotVisibleException(guiElementDescription + " did not become visible."); } }
From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * Nvigate to URL.//from w w w. ja va 2 s . co m * * @param url * the url */ public static void navigateToUrl(String url) { driver.get(url); String browser = Validate.readsystemvariable("browser"); if (browser.equals("IE")) { WebDriverWait wait = new WebDriverWait(driver, 10); WebElement ele = wait.until(ExpectedConditions.elementToBeClickable( driver.findElement(By.linkText("Continue to this website (not recommended).")))); ele.click(); } // driver.get(driver.getCurrentUrl()); }
From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * waits for the given webelement./*from w ww . j a va 2 s. co m*/ * * @param element * the element */ public static void waitForElement(WebElement element) { WebDriverWait wait = new WebDriverWait(getDriver(), Integer.parseInt(System.getProperty("explicit.wait"))); wait.until(ExpectedConditions.visibilityOf(element)); }
From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * waits for the alert.//from w ww .ja va 2s . c o m */ public static void waitForAlert() { WebDriverWait wait = new WebDriverWait(getDriver(), Integer.parseInt(System.getProperty("explicit.wait"))); wait.until(ExpectedConditions.alertIsPresent()); }
From source file:com.cisco.dbds.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * Waits for the Element given by the locator. * /* ww w . j a va 2 s. c o m*/ * @param locatorname * the locatorname * @param timeout * the timeout * @return the web element */ public static WebElement waitForElement(By locatorname, int timeout) { WebDriverWait wait = new WebDriverWait(driver, timeout); return wait.until(presenceOfElementLocated(locatorname)); }