com.slickqa.webdriver.finders.FindByAttributeValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of slick-webdriver-java Show documentation
Show all versions of slick-webdriver-java Show documentation
This is a wrapper and utilities for using webdriver / selenium in Java.
package com.slickqa.webdriver.finders;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.util.ArrayList;
import java.util.Arrays;
/**
*
* @author jcorbett
*/
public class FindByAttributeValue extends AbstractFindByParentBy
{
String attribute;
String attributeValue;
public FindByAttributeValue(String attribute, String attributeValue)
{
this.attribute = attribute;
this.attributeValue = attributeValue;
}
@Override
public String toString()
{
return String.format("By attribute '%s' with value '%s'.", attribute, attributeValue);
}
@Override
public boolean matches(WebElement e)
{
String attrValue = e.getAttribute(attribute);
return attrValue != null && attrValue.equals(attributeValue);
}
@Override
public ArrayList getParentBy()
{
return new ArrayList(Arrays.asList(tagName("img"), tagName("input"), tagName("table"), tagName("tr"), tagName("td"), tagName("div")));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy