Constructor
new By(using, value)
Name | Type | Description |
---|---|---|
using | string | the name of the location strategy to use. |
value | string | the value to search for. |
Members
using :string
- string
value :string
- string
Methods
toString()
(static) className(name) → (non-null) {By}
Locates elements that have a specific class name.
Name | Type | Description |
---|---|---|
name | string | The class name to search for. |
The new locator.
- Type:
- By
(static) css(selector) → (non-null) {By}
Locates elements using a CSS selector.
Name | Type | Description |
---|---|---|
selector | string | The CSS selector to use. |
The new locator.
- Type:
- By
(static) id(id) → (non-null) {By}
Locates elements by the ID attribute. This locator uses the CSS selector *[id="$ID"]
, not document.getElementById
.
Name | Type | Description |
---|---|---|
id | string | The ID to search for. |
The new locator.
- Type:
- By
(static) js(scriptnon-null, …var_args)
Locates elements by evaluating a script
that defines the body of a JavaScript function. The return value of this function must be an element or an array-like list of elements. When this locator returns a list of elements, but only one is expected, the first element in this list will be used as the single element value.
Name | Type | Attributes | Description |
---|---|---|---|
script | string | | The script to execute. | |
var_args | * | <repeatable> | The arguments to pass to the script. |
(static) linkText(text) → (non-null) {By}
Locates link elements whose visible text matches the given string.
Name | Type | Description |
---|---|---|
text | string | The link text to search for. |
The new locator.
- Type:
- By
(static) name(name) → (non-null) {By}
Locates elements whose name
attribute has the given value.
Name | Type | Description |
---|---|---|
name | string | The name attribute to search for. |
The new locator.
- Type:
- By
(static) partialLinkText(text) → (non-null) {By}
Locates link elements whose visible text contains the given substring.
Name | Type | Description |
---|---|---|
text | string | The substring to check for in a link's visible text. |
The new locator.
- Type:
- By
(static) tagName(name) → (non-null) {By}
Locates elements with a given tag name.
Name | Type | Description |
---|---|---|
name | string | The tag name to search for. |
The new locator.
- Type:
- By
(static) xpath(xpath) → (non-null) {By}
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.
Name | Type | Description |
---|---|---|
xpath | string | The XPath selector to use. |
The new locator.
- Type:
- By