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.util.PageUtil.java
License:Open Source License
/** * Check weather the particular page is Loaded. * @param driver the driver/* w ww. j ava2 s . c o m*/ * @param url the url * @param timeout the timeout * @return boolean */ public static boolean isPageLoaded(final WebDriver driver, final String url, final int timeout) { boolean ispageLoaded = (new WebDriverWait(driver, timeout)).until(new ExpectedCondition<Boolean>() { boolean loaded; public Boolean apply(WebDriver d) { if (d.getCurrentUrl().equalsIgnoreCase(url)) loaded = true; return loaded; } }); return ispageLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Utility to check weather the particular field is displayed by field name and the text value. * @param driver the driver// w ww .j a v a 2 s.c o m * @param fieldname the fieldname * @param textValue the text value * @param timeOut the time out * @return boolean */ public static boolean isDisplayedByText(final WebDriver driver, final String fieldname, final String textValue, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { WebElement element = d.findElement(By.id(fieldname)); return element.getText().contains(textValue); } }); 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 by css class name. * @param driver the driver/*from w w w. ja v a2s . co m*/ * @param fieldname the fieldname * @param textValue the text value * @param timeOut the time out * @return boolean */ public static boolean isDisplayedByClassNameText(final WebDriver driver, final String fieldname, final String textValue, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { WebElement element = d.findElement(By.className(fieldname)); return element.getText().contains(textValue); } }); return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Check according to the link text.//from ww w .j ava 2 s. c o m * @param driver the driver * @param fieldname the fieldname * @param timeOut the time out * @return boolean */ public static boolean isDisplayedByLinkText(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) { WebElement element = driver.findElement(By.linkText(fieldname)); return element.isDisplayed(); } }); return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Check particular web Element text contains the expected text. * @param driver the driver// w ww . j av a 2 s . c om * @param element the element * @param textValue the text value * @param timeOut the time out * @return boolean */ public static boolean isDisplayedByElementText(final WebDriver driver, final WebElement element, final String textValue, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return element.getText().contains(textValue); } }); return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Retrieve element by attribute value./* w w w . jav a 2 s . c o m*/ * @param driver the driver * @param tagName the tag name * @param attributeName the attribute name * @param attributeValue the attribute value * @param timeOut the time out * @return the web element */ public static WebElement retrieveElementByAttributeValue(final WebDriver driver, final String tagName, final String attributeName, final String attributeValue, int timeOut) { elementAttrValue = null; (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean isLoaded = false; List<WebElement> elementList = driver.findElements(By.tagName(tagName)); for (WebElement webElement : elementList) { String valueAttribute = webElement.getAttribute(attributeName.trim()); if (valueAttribute.trim().equalsIgnoreCase(attributeValue)) { elementAttrValue = webElement; isLoaded = true; break; } } return isLoaded; } }); return elementAttrValue; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Contain by attribute value./*from www . j a va 2 s . co m*/ * @param driver the driver * @param tagName the tag name * @param attributeName the attribute name * @param attributeValue the attribute value * @param timeOut the time out * @return the web element */ public static WebElement containByAttributeValue(final WebDriver driver, final String tagName, final String attributeName, final String attributeValue, int timeOut) { elementAttrValue = null; (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean isLoaded = false; List<WebElement> elementList = driver.findElements(By.tagName(tagName)); for (WebElement webElement : elementList) { String valueAttribute = webElement.getAttribute(attributeName.trim()); if (valueAttribute.trim().contains(attributeValue)) { elementAttrValue = webElement; isLoaded = true; break; } } return isLoaded; } }); return elementAttrValue; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Retrieve element by contains of attribute value. * @param driver the driver/* w w w . jav a 2 s. c om*/ * @param tagName the tag name * @param attributeName the attribute name * @param attributeValue the attribute value * @param timeOut the time out * @return the web element */ public static WebElement retrieveElementByContainsOfAttributeValue(final WebDriver driver, final String tagName, final String attributeName, final String attributeValue, final int timeOut) { elementContainsAttrValue = null; (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean isLoaded = false; List<WebElement> elementList = driver.findElements(By.tagName(tagName)); for (WebElement webElement : elementList) { String valueAttribute = webElement.getAttribute(attributeName.trim()); if (valueAttribute != null && valueAttribute.trim().contains(attributeValue)) { elementContainsAttrValue = webElement; isLoaded = true; break; } } return isLoaded; } }); return elementContainsAttrValue; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Retrieve element by attribute value for sub element. * @param driver the driver/*from w w w. j a va2s . c om*/ * @param subElement the sub element * @param tagName the tag name * @param attributeName the attribute name * @param attributeValue the attribute value * @param timeOut the time out * @return the web element */ public static WebElement retrieveElementByAttributeValueForSubElement(final WebDriver driver, final WebElement subElement, final String tagName, final String attributeName, final String attributeValue, final int timeOut) { subElementEqualsAttrValue = null; (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean isLoaded = false; List<WebElement> elementList = subElement.findElements(By.tagName(tagName)); for (WebElement webElement : elementList) { String valueAttribute = webElement.getAttribute(attributeName.trim()); if (valueAttribute.trim().equalsIgnoreCase(attributeValue)) { subElementEqualsAttrValue = webElement; isLoaded = true; break; } } return isLoaded; } }); return subElementEqualsAttrValue; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Retrieve element by attribute value contains for sub element. * @param driver the driver/* www .ja v a 2 s . co m*/ * @param subElement the sub element * @param tagName the tag name * @param attributeName the attribute name * @param attributeValue the attribute value * @param timeOut the time out * @return the web element */ public static WebElement retrieveElementByAttributeValueContainsForSubElement(final WebDriver driver, final WebElement subElement, final String tagName, final String attributeName, final String attributeValue, final int timeOut) { subElementContainsAttrValue = null; try { (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean isLoaded = false; List<WebElement> elementList = subElement.findElements(By.tagName(tagName)); for (WebElement webElement : elementList) { String valueAttribute = webElement.getAttribute(attributeName.trim()); if (valueAttribute.trim().contains(attributeValue)) { subElementContainsAttrValue = webElement; isLoaded = true; break; } } return isLoaded; } }); } catch (TimeoutException te) { } return subElementContainsAttrValue; }