# Class By

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, value): 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(): Object

- #### Returns Object

### toString

- toString(): string

- #### Returns string

### `Static` className

- className(name): By

- Locates elements that have a specific class name.

  #### Parameters

  - ##### name: string

    The class name to search for.

  #### Returns By

  The new locator.

  #### See

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

### `Static` css

- css(selector): By

- Locates elements using a CSS selector.

  #### Parameters

  - ##### selector: string

    The CSS selector to use.

  #### Returns By

  The new locator.

  #### See

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

### `Static` id

- id(id): 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, ...var_args): ((webdriver) => Promise<any>)

- Locates an elements by evaluating a 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) => Promise<any>)

  A new JavaScript-based locator function.

  - - (webdriver): Promise<any>

    - Locates an elements by evaluating a 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): By

- Locates link elements whose visible text matches the given string.

  #### Parameters

  - ##### text: string

    The link text to search for.

  #### Returns By

  The new locator.

### `Static` name

- name(name): 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): By

- Locates link elements whose 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): By

- Locates elements with a given tag name.

  #### Parameters

  - ##### name: string

    The tag name to search for.

  #### Returns By

  The new locator.

  #### Deprecated

  Use () By.css(tagName) instead.

### `Static` xpath

- xpath(xpath): 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.

  #### Parameters

  - ##### xpath: string

    The XPath selector to use.

  #### Returns By

  The new locator.

  #### See

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

Generated using TypeDoc