List of usage examples for org.openqa.selenium WebDriver findElement
@Override WebElement findElement(By by);
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/*from w w w . j av a 2 s. com*/ * @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 ww w . ja v a2 s . c o m * @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 displayed or not. * @param driver the driver// www. j av a2 s . c o m * @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 ww . ja v a 2 s .co 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; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Select option by value./* w w w. jav a 2 s . c o m*/ * @param driver the driver * @param selectId the select id * @param selectValue the select value */ public static void selectOptionByValue(final WebDriver driver, final String selectId, final String selectValue) { logger.info("Select id:" + selectId + " ; selectValue" + selectValue); Select select = new Select(driver.findElement(By.id(selectId))); select.selectByValue(selectValue); }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Is particular element displayed by class Name. . . * @param driver the driver//from w w w . j av a 2 s. c o m * @param fieldname the fieldname * @param timeOut the time out * @return boolean */ public static boolean isDisplayedByClassName(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) { return d.findElement(By.className(fieldname)).isDisplayed(); } }); } catch (TimeoutException te) { isLoaded = false; } return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Checks if is displayed by xpath./*from www . j a v a 2s . com*/ * * @param driver the driver * @param fieldname the fieldname * @param timeOut the time out * @return true, if is displayed by xpath */ public static boolean isDisplayedByXpath(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) { return d.findElement(By.xpath(fieldname)).isDisplayed(); } }); } catch (TimeoutException te) { isLoaded = false; } return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Select option by text./*w ww . j a v a2 s . c o m*/ * @param driver the driver * @param selectId the select id * @param selectText the select text */ public static void selectOptionByText(final WebDriver driver, final String selectId, final String selectText) { logger.info("Select id:" + selectId + " ; selectText" + selectText); Select select = new Select(driver.findElement(By.id(selectId))); select.selectByVisibleText(selectText); }
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//from w ww . ja v a 2 s . com * @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/* w ww .ja va 2 s .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; }