Example usage for org.openqa.selenium By tagName

List of usage examples for org.openqa.selenium By tagName

Introduction

In this page you can find the example usage for org.openqa.selenium By tagName.

Prototype

public static By tagName(String tagName) 

Source Link

Usage

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Multiple elements displayed by Tag Name.
 * @param driver the driver/*ww  w . ja v  a  2  s .  c  o m*/
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isMultipleTagNameDisplayed(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) {

            List<WebElement> elmtList = driver.findElements(By.tagName(fieldname));
            boolean returnValue = false;
            returnValue = elmtList != null && elmtList.size() > 0 ? true : false;
            return returnValue;
        }
    });

    return isLoaded;
}

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   www  .  ja v  a2s  .  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

/**
 * <b> verify the particular value is displayed according to the attribute</b>
 *///from w w w . j  a v  a2 s. c om
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

/**
 * <b> verify the particular value is displayed according to the attribute</b>.
 * @param driver the driver//from w  w  w . ja  va 2s  .co m
 * @param tagName the tag name
 * @param attributeName the attribute name
 * @param attributeValue the attribute value
 * @return the web element
 */
public static WebElement retrieveElementByAttributeValue(final WebDriver driver, final String tagName,
        final String attributeName, final String attributeValue) {

    WebElement element = null;
    List<WebElement> elementList = driver.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 element by attribute value.//  ww w  .ja  v a2  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   w w w.  j  a v a2  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 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

/**
 * <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.  c  om*/
 * @param tagName the tag name
 * @param attributeName the attribute name
 * @param attributeValue the attribute value
 * @return the list
 */
public static List<WebElement> retrieveElementsByAttributeValueList(final WebDriver driver,
        final String tagName, final String attributeName, final String attributeValue) {

    List<WebElement> elementList = driver.findElements(By.tagName(tagName));
    List<WebElement> listElement = new ArrayList<WebElement>();

    for (WebElement webElement : elementList) {
        String valueAttribute = webElement.getAttribute(attributeName.trim());
        if (valueAttribute.trim().equalsIgnoreCase(attributeValue))
            listElement.add(webElement);
    }

    return listElement;
}

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 ww  .ja  v 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 elements by contains of attribute value.
 * @param driver the driver/*  ww w  .j av a 2s  . c  o m*/
 * @param tagName the tag name
 * @param attributeName the attribute name
 * @param attributeValue the attribute value
 * @return the list
 */
public static List<WebElement> retrieveElementsByContainsOfAttributeValue(final WebDriver driver,
        final String tagName, final String attributeName, final String attributeValue) {

    List<WebElement> elementListGroup = new ArrayList<WebElement>();
    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;
            elementListGroup.add(webElement);
        }
    }

    return elementListGroup;
}

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  ww.  j a va2 s  .  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;
}