Typings for lib/by.js Describes a mechanism for locating an element on the page.

final

### Hierarchy

- By

## Index

### Constructors

- constructor

### Properties

- using
- value

### Methods

- toObject
- toString
- className
- css
- id
- js
- linkText
- name
- partialLinkText
- tagName
- xpath

## Constructors

### constructor

- new By(using: string, value: string): By

- #### Parameters

  - ##### using: string

    the name of the location strategy to use.

  - ##### value: string

    the value to search for.

  #### Returns By

## Properties

### using

using: string

### value

value: string

## Methods

### toObject

- toObject(): <internal>.Object

- #### Returns <internal>.Object

### toString

- toString(): string

- override

  #### Returns string

### Static className

- className(name: string): By

- Locates elements that have a specific class name.

  see

    http://www.w3.org/TR/2011/WD-html5-20110525/elements.html#classes

  see

    http://www.w3.org/TR/CSS2/selector.html#class-html

  #### Parameters

  - ##### name: string

    The class name to search for.

  #### Returns By

  The new locator.

### Static css

- css(selector: string): By

- Locates elements using a CSS selector.

  see

    http://www.w3.org/TR/CSS2/selector.html

  #### Parameters

  - ##### selector: string

    The CSS selector to use.

  #### Returns By

  The new locator.

### Static id

- id(id: string): By

- Locates eleemnts by the ID attribute. This locator uses the CSS selector `*[id='$ID']`, not `document.getElementById`.

  #### Parameters

  - ##### id: string

    The ID to search for.

  #### Returns By

  The new locator.

### Static js

- js(script: string | Function, ...var_args: any[]): (webdriver: WebDriver) => Promise<any>

- Locates an elements by evaluating a {@linkplain WebDriver#executeScript JavaScript expression}. The result of this expression must be an element or list of elements.

  #### Parameters

  - ##### script: string | Function

    The script to execute.

  - ##### Rest ...var_args: any[]

    The arguments to pass to the script.

  #### Returns (webdriver: WebDriver) => Promise<any>

      A new JavaScript-based locator function.

  - - (webdriver: WebDriver): Promise<any>

    - Locates an elements by evaluating a {@linkplain WebDriver#executeScript JavaScript expression}. The result of this expression must be an element or list of elements.

      #### Parameters

      - ##### webdriver: WebDriver

      #### Returns Promise<any>

          A new JavaScript-based locator function.

### Static linkText

- linkText(text: string): By

- Locates link elements whose {@linkplain WebElement#getText visible text} matches the given string.

  #### Parameters

  - ##### text: string

    The link text to search for.

  #### Returns By

  The new locator.

### Static name

- name(name: string): By

- Locates elements whose `name` attribute has the given value.

  #### Parameters

  - ##### name: string

    The name attribute to search for.

  #### Returns By

  The new locator.

### Static partialLinkText

- partialLinkText(text: string): By

- Locates link elements whose {@linkplain WebElement#getText visible text} contains the given substring.

  #### Parameters

  - ##### text: string

    The substring to check for in a link's visible text.

  #### Returns By

  The new locator.

### Static tagName

- tagName(name: string): By

- Locates elements with a given tag name.

  deprecated

    Use {@link By.css() By.css(tagName)} instead.

  #### Parameters

  - ##### name: string

    The tag name to search for.

  #### Returns By

  The new locator.

### Static xpath

- xpath(xpath: string): By

- Locates elements matching a XPath selector. Care should be taken when using an XPath selector with a 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.

  see

    http://www.w3.org/TR/xpath/

  #### Parameters

  - ##### xpath: string

    The XPath selector to use.

  #### Returns By

  The new locator.

Generated using TypeDoc