|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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;
}
| Constructor Summary | |
|---|---|
By()
|
|
| Method Summary | |
|---|---|
static By |
className(java.lang.String className)
Finds elements based on the value of the "class" attribute. |
boolean |
equals(java.lang.Object o)
|
WebElement |
findElement(SearchContext context)
Find a single element. |
WebElement |
findElement(WebDriver driver)
Deprecated. use findElement(SearchContext) instead |
abstract java.util.List<WebElement> |
findElements(SearchContext context)
Find many elements. |
java.util.List<WebElement> |
findElements(WebDriver driver)
Deprecated. use findElements(SearchContext) instead |
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)
|
static By |
xpath(java.lang.String xpathExpression)
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, 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 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 java.util.List<WebElement> findElements(WebDriver driver)
driver - A driver to use to find the element
public WebElement findElement(WebDriver driver)
driver - A driver to use to find the element
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||