Namespace webdriver.By
code »A collection of factory functions for creating webdriver.Locator
instances.
Type Definitions
code »webdriver.By.Hash : ({className: string}|{css: string}|{id: string}|{js: string}|{linkText: string}|{name: string}|{partialLinkText: string}|{tagName: string}|{xpath: string})Short-hand expressions for the primary element locator strategies.
For example the following two statements are equivalent:
var e1 = driver.findElement(webdriver.By.id('foo'));
var e2 = driver.findElement({id: 'foo'});
Care should be taken when using JavaScript minifiers (such as the
Closure compiler), as locator hashes will always be parsed using
the un-obfuscated properties listed below.
({className: string}|{css: string}|{id: string}|{js: string}|{linkText: string}|{name: string}|{partialLinkText: string}|{tagName: string}|{xpath: string})
var e1 = driver.findElement(webdriver.By.id('foo'));
var e2 = driver.findElement({id: 'foo'});
Care should be taken when using JavaScript minifiers (such as the Closure compiler), as locator hashes will always be parsed using the un-obfuscated properties listed below.
Global Functions
code »webdriver.By.className ( className ) ⇒ !webdriver.LocatorLocates elements that have a specific class name. The returned locator
is equivalent to searching for elements with the CSS selector ".clazz".
!webdriver.Locator| Parameters |
|---|
|
| Returns |
|
code »webdriver.By.css ( selector ) ⇒ !webdriver.LocatorLocates elements using a CSS selector. For browsers that do not support
CSS selectors, WebDriver implementations may return an
invalid selector error. An
implementation may, however, emulate the CSS selector API.
!webdriver.Locatorinvalid selector error. An
implementation may, however, emulate the CSS selector API.| Parameters |
|---|
|
| Returns |
|
code »webdriver.By.id ( id ) ⇒ !webdriver.LocatorLocates an element by its ID.
!webdriver.Locator| Parameters |
|---|
|
| Returns |
|
code »webdriver.By.js ( script, var_args ) ⇒ function(!webdriver.WebDriver): !webdriver.promise.PromiseLocates an elements by evaluating a
JavaScript expression.
The result of this expression must be an element or list of elements.
function(!webdriver.WebDriver): !webdriver.promise.PromiseJavaScript expression.
The result of this expression must be an element or list of elements.code »webdriver.By.linkText ( text ) ⇒ !webdriver.LocatorLocates link elements whose visible
text matches the given string.
!webdriver.Locatorvisible
text matches the given string.| Parameters |
|---|
|
| Returns |
|
code »webdriver.By.name ( name ) ⇒ !webdriver.LocatorLocates elements whose name attribute has the given value.
!webdriver.Locatorname attribute has the given value.| Parameters |
|---|
|
| Returns |
|
code »webdriver.By.partialLinkText ( text ) ⇒ !webdriver.LocatorLocates link elements whose visible
text contains the given substring.
!webdriver.Locatorvisible
text contains the given substring.| Parameters |
|---|
|
| Returns |
|
code »webdriver.By.tagName ( text ) ⇒ !webdriver.LocatorLocates elements with a given tag name. The returned locator is
equivalent to using the getElementsByTagName DOM function.
!webdriver.LocatorgetElementsByTagName DOM function.| Parameters |
|---|
|
| Returns |
|
code »webdriver.By.xpath ( xpath ) ⇒ !webdriver.LocatorLocates elements matching a XPath selector. Care should be taken when
using an XPath selector with a webdriver.WebElement as WebDriver
will respect the context in the specified in the selector. For example,
given the selector "//div", WebDriver will search from the
document root regardless of whether the locator was used with a
WebElement.
!webdriver.Locatorwebdriver.WebElement as WebDriver
will respect the context in the specified in the selector. For example,
given the selector "//div", WebDriver will search from the
document root regardless of whether the locator was used with a
WebElement.| Parameters |
|---|
|
| Returns |
|