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.Locator
Locates 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.Locator
Locates 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.Locator
invalid selector
error. An
implementation may, however, emulate the CSS selector API.Parameters |
---|
|
Returns |
|
code »webdriver.By.id ( id ) ⇒ !webdriver.Locator
Locates an element by its ID.
!webdriver.Locator
Parameters |
---|
|
Returns |
|
code »webdriver.By.js ( script, var_args ) ⇒ function(!webdriver.WebDriver): !webdriver.promise.Promise
Locates 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.Promise
JavaScript expression
.
The result of this expression must be an element or list of elements.code »webdriver.By.linkText ( text ) ⇒ !webdriver.Locator
Locates link elements whose visible
text
matches the given string.
!webdriver.Locator
visible
text
matches the given string.Parameters |
---|
|
Returns |
|
code »webdriver.By.name ( name ) ⇒ !webdriver.Locator
Locates elements whose name
attribute has the given value.
!webdriver.Locator
name
attribute has the given value.Parameters |
---|
|
Returns |
|
code »webdriver.By.partialLinkText ( text ) ⇒ !webdriver.Locator
Locates link elements whose visible
text
contains the given substring.
!webdriver.Locator
visible
text
contains the given substring.Parameters |
---|
|
Returns |
|
code »webdriver.By.tagName ( text ) ⇒ !webdriver.Locator
Locates elements with a given tag name. The returned locator is
equivalent to using the getElementsByTagName
DOM function.
!webdriver.Locator
getElementsByTagName
DOM function.Parameters |
---|
|
Returns |
|
code »webdriver.By.xpath ( xpath ) ⇒ !webdriver.Locator
Locates 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.Locator
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.Parameters |
---|
|
Returns |
|