Elements

session.findElement(strategy, selector)

Search for an element on the page, starting from the document root.

PARAMETERS

  • strategy: LocatorStrategy - Strategy for emelent lookup

  • selector: string - Selector string

RETURNS

Promise<Element>

EXAMPLES

const element = await session.findElement('css selector', 'h2');
// element = <webdriver element>

SEE ALSO

session.findElements(strategy, selector)

Search for multiple elements on the page, starting from the document root. The located elements will be returned as a WebElement JSON objects. The table below lists the locator strategies that each server should support. Elements should be returned in the order located in the DOM.

PARAMETERS

  • strategy: LocatorStrategy - Strategy for emelent lookup

  • selector: string - Selector string

RETURNS

Promise<Element[]>

EXAMPLES

SEE ALSO

session.getActiveElement()

Get the element on the page that currently has focus.

RETURNS

Promise<Element>

EXAMPLES

SEE ALSO

Element

This object represents a WebDriver element.

SEE ALSO

element.findElement(strategy, selector)

Search for an element on the page, starting from the referenced web element.

PARAMETERS

  • strategy: LocatorStrategy - Strategy for element lookup

  • selector: string - Selector string

RETURNS

Promise<Element>

EXAMPLES

SEE ALSO

element.findElements(strategy, selector)

Search for multiple elements on the page, starting from the referenced web element. The located elements will be returned as a WebElement JSON objects. The table below lists the locator strategies that each server should support. Elements should be returned in the order located in the DOM.

PARAMETERS

  • strategy: LocatorStrategy - Strategy for emelent lookup

  • selector: string - Selector string

RETURNS

Promise<Element[]>

EXAMPLES

SEE ALSO

element.isSelected()

Determines if the referenced element is selected or not. This operation only makes sense on input elements of the Checkbox- and Radio Button states, or on option elements.

RETURNS

Promise<boolean>

EXAMPLES

SEE ALSO

element.getAttribute(attributeName)

Returns the attribute value of the referenced web element.

PARAMETERS

  • attributeName: string - Element attribute name

RETURNS

Promise<string>

EXAMPLES

SEE ALSO

element.getProperty(propertyName)

Returns the property of the referenced web element.

PARAMETERS

  • propertyName: string - Element property name

RETURNS

Promise<string>

EXAMPLES

SEE ALSO

element.getCssValue(propertyName)

Returns the computed value of the given CSS property for the element.

PARAMETERS

  • propertyName: string - Name of CSS property

RETURNS

Promise<string>

EXAMPLES

SEE ALSO

element.getText()

Returns the visible text for the element.

RETURNS

Promise<string>

EXAMPLES

SEE ALSO

element.getTagName()

Returns the tagName of a Element

RETURNS

Promise<string>

EXAMPLES

SEE ALSO

element.getRect()

Returns the dimensions and coordinates of the referenced element

RETURNS

Promise<ElementRect>

EXAMPLES

SEE ALSO

element.isEnabled()

Determines if the referenced element is enabled or not.

RETURNS

Promise<boolean>

EXAMPLES

SEE ALSO

element.click()

Click on an element.

RETURNS

Promise<void>

EXAMPLES

SEE ALSO

element.clear()

Clear content of an element.

RETURNS

Promise<void>

EXAMPLES

SEE ALSO

element.sendKeys(text)

Send a sequence of key strokes to an element.

PARAMETERS

  • text: string - Input text to be typed in element

RETURNS

Promise<void>

EXAMPLES

SEE ALSO

LocatorStrategy

Strategy for searching element on the page

POSSIBLE VALUES

  • 'css selector'

  • 'link text'

  • 'partial link text'

  • 'tag name'

  • 'xpath'

ElementRect

An object defining the Element Rect.

PROPERTIES

  • x: number - X axis position of the top-left corner of the element relative to the current browsing context’s document element in CSS pixels

  • y: number - Y axis position of the top-left corner of the element relative to the current browsing context’s document element in CSS pixels

  • width: number - Height of the element’s bounding rectangle in CSS pixels

  • height: number - Width of the web element’s bounding rectangle in CSS pixels

Last updated

Was this helpful?