List of usage examples for org.openqa.selenium WebElement findElements
@Override List<WebElement> findElements(By by);
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Is elements displayed by Tag Name. . . * @param driver the driver/*from w w w .j av a 2 s. c o m*/ * @param element the element * @param fieldname the fieldname * @param timeOut the time out * @return boolean */ public static boolean isElementTagNameDisplayed(final WebDriver driver, final WebElement element, final String fieldname, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { List<WebElement> elmtList = element.findElements(By.tagName(fieldname)); if (elmtList.size() > 0) { return true; } return false; } }); return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Is form elements Id displayed by Tag Name. . . * @param driver the driver/*from ww w .j av a2 s .c o m*/ * @param element the element * @param fieldname the fieldname * @param timeOut the time out * @return boolean */ public static boolean isElementIdDisplayed(final WebDriver driver, final WebElement element, final String fieldname, final int timeOut) { boolean isLoaded = false; isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { List<WebElement> elmtList = element.findElements(By.id(fieldname)); if (elmtList.size() > 0) { return true; } return false; } }); return isLoaded; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * <b> verify the particular value is displayed according to the attribute</b> *//*from ww w .ja v a 2s. c o m*/ public static WebElement retrieveElementByTagTextForSubElement(final WebDriver driver, final WebElement subElement, final String tagName, final String textValue) { WebElement element = null; List<WebElement> elementList = subElement.findElements(By.tagName(tagName)); for (WebElement webElement : elementList) { String value = webElement.getText().trim(); if (value.trim().equalsIgnoreCase(textValue)) return webElement; } return element; }
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/* w ww .ja v a2 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 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/*from ww w .j a v a 2 s.c o 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; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * <b> verify the particular value is displayed according to the attribute</b>. * @param driver the driver// w w w . j a v a 2 s. com * @param rootElement the root element * @param tagName the tag name * @param attributeName the attribute name * @param attributeValue the attribute value * @return the web element */ public static WebElement retrieveElementByAttributeValueByPassingElement(final WebDriver driver, final WebElement rootElement, final String tagName, final String attributeName, final String attributeValue) { WebElement element = null; List<WebElement> elementList = rootElement.findElements(By.tagName(tagName)); for (WebElement webElement : elementList) { String valueAttribute = webElement.getAttribute(attributeName.trim()); if (valueAttribute.trim().equalsIgnoreCase(attributeValue)) { return webElement; } } return element; }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Retrieve sub element by tag text.// ww w.j a va 2s. c o m * @param driver the driver * @param subElelement the sub elelement * @param tagName the tag name * @param textValue the text value * @param timeOut the time out * @return the web element */ public static WebElement retrieveSubElementByTagText(final WebDriver driver, final WebElement subElelement, final String tagName, final String textValue, final int timeOut) { elementTagText = null; (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { boolean isLoaded = false; List<WebElement> elementList = subElelement.findElements(By.tagName(tagName)); for (WebElement webElement : elementList) { String value = webElement.getText(); if (value.trim().equalsIgnoreCase(textValue)) { elementTagText = webElement; isLoaded = true; break; } } return isLoaded; } }); /* * WebElement element = null; List<WebElement> elementList = * driver.findElements(By.tagName(tagName)); for (WebElement webElement : elementList) { * String value = webElement.getText(); if(value.trim().equalsIgnoreCase(textValue)) return * webElement; } */ return elementTagText; }
From source file:com.epam.jdi.uitests.mobile.appium.elements.complex.BaseSelector.java
License:Open Source License
protected void selectAction(String name) { if (!hasLocator() && allLabels() == null) throw exception("Can't find option '%s'. No optionsNamesLocator and allLabelsLocator found", name); if (hasLocator() && getLocator().toString().contains("%s")) { new Clickable(fillByTemplate(getLocator(), name)).click(); return;/*from w w w. j av a 2 s . c om*/ } if (allLabels() != null) { selectFromList(allLabels().avatar.searchAll().getElements(), name); return; } List<WebElement> elements = getAvatar().searchAll().getElements(); WebElement element = elements.get(0); if (elements.size() == 1 && element.getTagName().equals("select")) if (getSelector().getOptions().size() > 0) { getSelector().selectByVisibleText(name); return; } else throw exception("<select> tag has no <option> tags. Please Clarify element locator (%s)", this); if (elements.size() == 1 && element.getTagName().equals("ul")) elements = element.findElements(By.tagName("li")); selectFromList(elements, name); }
From source file:com.epam.jdi.uitests.mobile.appium.elements.complex.BaseSelector.java
License:Open Source License
protected void selectAction(int num) { if (!hasLocator() && allLabels() == null) throw exception("Can't find option '%s'. No optionsNamesLocator and allLabelsLocator found", num); if (allLabels() != null) { selectFromList(allLabels().getWebElements(), num); return;// ww w .j a v a2 s .c o m } if (getLocator().toString().contains("%s")) { new Clickable(fillByTemplate(getLocator(), num)).click(); return; } List<WebElement> elements = getAvatar().searchAll().getElements(); WebElement element = elements.get(0); if (elements.size() == 1 && element.getTagName().equals("select")) if (getSelector().getOptions().size() > 0) { getSelector().selectByIndex(num - 1); return; } else throw exception("<select> tag has no <option> tags. Please Clarify element locator (%s)", this); if (elements.size() == 1 && element.getTagName().equals("ul")) elements = element.findElements(By.tagName("li")); selectFromList(elements, num); }
From source file:com.epam.jdi.uitests.mobile.appium.elements.complex.BaseSelector.java
License:Open Source License
public List<WebElement> getElementsFromTag() { List<WebElement> elements; try {//w w w .j a va 2s .c o m elements = getAvatar().searchAll().getElements(); } catch (Exception | Error ex) { return new ArrayList<>(); } WebElement element = elements.get(0); if (elements.size() == 1) switch (element.getTagName()) { case "select": return getSelector().getOptions(); case "ul": return element.findElements(By.tagName("li")); } return elements; }