Class DefaultElementLocator
- java.lang.Object
-
- org.openqa.selenium.support.pagefactory.DefaultElementLocator
-
- All Implemented Interfaces:
ElementLocator
- Direct Known Subclasses:
AjaxElementLocator
public class DefaultElementLocator extends java.lang.Object implements ElementLocator
The default element locator, which will lazily locate an element or an element list on a page. This class is designed for use with thePageFactoryand understands the annotationsFindByandCacheLookup.
-
-
Constructor Summary
Constructors Constructor Description DefaultElementLocator(org.openqa.selenium.SearchContext searchContext, java.lang.reflect.Field field)Creates a new element locator.DefaultElementLocator(org.openqa.selenium.SearchContext searchContext, AbstractAnnotations annotations)Use this constructor in order to process custom annotations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.openqa.selenium.WebElementfindElement()Find the element.java.util.List<org.openqa.selenium.WebElement>findElements()Find the element list.protected booleanshouldCache()Returns whether the element should be cached.java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultElementLocator
public DefaultElementLocator(org.openqa.selenium.SearchContext searchContext, java.lang.reflect.Field field)Creates a new element locator.- Parameters:
searchContext- The context to use when finding the elementfield- The field on the Page Object that will hold the located value
-
DefaultElementLocator
public DefaultElementLocator(org.openqa.selenium.SearchContext searchContext, AbstractAnnotations annotations)Use this constructor in order to process custom annotations.- Parameters:
searchContext- The context to use when finding the elementannotations- AbstractAnnotations class implementation
-
-
Method Detail
-
findElement
public org.openqa.selenium.WebElement findElement()
Find the element.- Specified by:
findElementin interfaceElementLocator
-
findElements
public java.util.List<org.openqa.selenium.WebElement> findElements()
Find the element list.- Specified by:
findElementsin interfaceElementLocator
-
shouldCache
protected boolean shouldCache()
Returns whether the element should be cached.- Returns:
trueif the element should be cached
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-