List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait
public WebDriverWait(WebDriver driver, Duration timeout)
From source file:com.ecofactor.qa.automation.platform.util.Pageutil.java
License:Open Source License
/** * Gets the element by sub element.//from ww w.ja v a 2 s.c o m * @param driver the driver * @param subElement the sub element * @param locator the locator * @param timeout the timeout * @return the element by sub element */ public static WebElement getElementBySubElement(final WebDriver driver, final WebElement subElement, final By locator, final CustomTimeout timeout) { return new WebDriverWait(driver, timeout.getValue()).until(new ExpectedCondition<WebElement>() { public WebElement apply(final WebDriver driver) { if (subElement.findElement(locator) != null) { return subElement.findElement(locator); } return null; } }); }
From source file:com.ecofactor.qa.automation.platform.util.Pageutil.java
License:Open Source License
/** * Gets the elements by sub element.// www. j av a 2 s . c o m * @param driver the driver * @param subElement the sub element * @param locator the locator * @param timeout the timeout * @return the elements by sub element */ public static List<WebElement> getElementsBySubElement(final WebDriver driver, final WebElement subElement, final By locator, final CustomTimeout timeout) { return new WebDriverWait(driver, timeout.getValue()).until(new ExpectedCondition<List<WebElement>>() { public List<WebElement> apply(final WebDriver driver) { return subElement.findElements(locator); } }); }
From source file:com.ecofactor.qa.automation.platform.util.Pageutil.java
License:Open Source License
/** * Wait for page loaded.//from w ww . ja v a 2s . co m * @param driver the driver */ public static void waitForPageLoaded(final WebDriver driver) { final ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() { public Boolean apply(final WebDriver driver) { return ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete"); } }; final Wait<WebDriver> wait = new WebDriverWait(driver, 120); try { wait.until(expectation); } catch (Throwable error) { LogUtil.setLogString("Page load takes more time", true); } }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Utility to check weather the particular field is displayed or not. * @param driver the driver//ww w . jav a2 s . c om * @param fieldname the fieldname * @param timeOut the time out * @return boolean */ public static boolean isDisplayedById(final WebDriver driver, final String fieldname, final int timeOut) { boolean isLoaded = false; try { isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { WebElement element = d.findElement(By.id(fieldname)); return element.isDisplayed(); } }); } catch (TimeoutException te) { isLoaded = false; } return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Utility to check weather the particular field is displayed or not. * @param driver the driver//from w w w .j a v a 2s .c om * @param cssSelector the css selector * @param timeOut the time out * @return boolean */ public static boolean isDisplayedByCSS(final WebDriver driver, final String cssSelector, final int timeOut) { boolean isLoaded = false; try { isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { List<WebElement> elements = d.findElements(By.cssSelector(cssSelector)); boolean displayed = false; for (WebElement element : elements) { displayed = element.isDisplayed(); if (displayed) { break; } } return displayed; } }); } catch (TimeoutException te) { isLoaded = false; } return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Utility to check weather the particular field is enabled or not. * @param driver the driver/*w w w. j av a2s. c om*/ * @param fieldname the fieldname * @param timeOut the time out * @return boolean */ public static boolean isEnabledById(final WebDriver driver, final String fieldname, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.id(fieldname)).isEnabled(); } }); return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Utility to check weather the particular field is enabled by class name or not. * @param driver the driver//from w w w. j ava 2s. com * @param className the class name * @param timeOut the time out * @return boolean */ public static boolean isEnabledByClassName(final WebDriver driver, final String className, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.className(className)).isEnabled(); } }); return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Utility to check weather the particular field is enabled by subelement or not. * @param driver the driver/*w ww.j av a2s .c o m*/ * @param subElement the sub element * @param fieldname the fieldname * @param timeOut the time out * @return boolean */ public static boolean isEnabledByIdSubElement(final WebDriver driver, final WebElement subElement, final String fieldname, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return subElement.findElement(By.id(fieldname)).isEnabled(); } }); return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Utility to check weather the particular field is displayed or not. * @param driver the driver//from www . j ava2s .com * @param tagName the tag name * @param timeOut the time out * @return boolean */ public static boolean isDisplayedByTagName(final WebDriver driver, final String tagName, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.tagName(tagName)).isDisplayed(); } }); return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * <p>/*from w w w . j a v a 2 s . c o m*/ * Utility to check weather the particular field has the specified style class name. * </p> * @param driver the driver * @param fieldname the fieldname * @param ClassName the class name * @param timeOut the time out * @return true, if is element contains class name */ public static boolean isElementContainsClassName(final WebDriver driver, final String fieldname, final String ClassName, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.id(fieldname)).getAttribute("className").equalsIgnoreCase(ClassName); } }); return isLoaded; }