|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openqa.selenium.By
public abstract class By
Mechanism used to locate elements within a document. In order to create your own locating
mechanisms, it is possible to subclass this class and override the protected methods as required,
though it is expected that that all subclasses rely on the basic finding mechanisms provided
through static methods of this class:
public WebElement findElement(WebDriver driver) {
WebElement element = driver.findElement(By.id(getSelector()));
if (element == null)
element = driver.findElement(By.name(getSelector());
return element;
}
Nested Class Summary | |
---|---|
static class |
By.ByClassName
|
static class |
By.ByCssSelector
|
static class |
By.ById
|
static class |
By.ByLinkText
|
static class |
By.ByName
|
static class |
By.ByPartialLinkText
|
static class |
By.ByTagName
|
static class |
By.ByXPath
|
Constructor Summary | |
---|---|
By()
|
Method Summary | |
---|---|
static By |
className(java.lang.String className)
Finds elements based on the value of the "class" attribute. |
static By |
cssSelector(java.lang.String selector)
Finds elements via the driver's underlying W3 Selector engine. |
boolean |
equals(java.lang.Object o)
|
WebElement |
findElement(SearchContext context)
Find a single element. |
abstract java.util.List<WebElement> |
findElements(SearchContext context)
Find many elements. |
int |
hashCode()
|
static By |
id(java.lang.String id)
|
static By |
linkText(java.lang.String linkText)
|
static By |
name(java.lang.String name)
|
static By |
partialLinkText(java.lang.String linkText)
|
static By |
tagName(java.lang.String name)
|
java.lang.String |
toString()
|
static By |
xpath(java.lang.String xpathExpression)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public By()
Method Detail |
---|
public static By id(java.lang.String id)
id
- The value of the "id" attribute to search for
public static By linkText(java.lang.String linkText)
linkText
- The exact text to match against
public static By partialLinkText(java.lang.String linkText)
linkText
- The text to match against
public static By name(java.lang.String name)
name
- The value of the "name" attribute to search for
public static By tagName(java.lang.String name)
name
- The element's tagName
public static By xpath(java.lang.String xpathExpression)
xpathExpression
- The xpath to use
public static By className(java.lang.String className)
className
- The value of the "class" attribute to search for
public static By cssSelector(java.lang.String selector)
public WebElement findElement(SearchContext context)
context
- A context to use to find the element
public abstract java.util.List<WebElement> findElements(SearchContext context)
context
- A context to use to find the element
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |