com.slickqa.webdriver.finders.AbstractFindByParentBy 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 java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebElement;
/**
* By implementing the abstract methods of this abstract class you can easily create a finder
* which looks for the value of an attribute in a list of elements.
*
* @author jcorbett
*/
public abstract class AbstractFindByParentBy extends By
{
public abstract boolean matches(WebElement e);
public abstract List getParentBy();
@Override
public List findElements(SearchContext context)
{
ArrayList possible_elements = new ArrayList();
for(By parentBy: getParentBy())
{
possible_elements.addAll(context.findElements(parentBy));
}
List retval = new ArrayList();
for (WebElement possible : possible_elements)
{
if (matches(possible))
{
retval.add(possible);
}
}
return retval;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy