Class: Element

Element


new Element(name, selector, page)

Creates a new instance of Element.

Element binds DOM element in browser context with virtual element in test.

Parameters:
Name Type Description
name string

Element name.

selector object

CSS selector of DOM element.

page Page

Page with element.

Source:

Methods


_getDriver()

Helper to get webdriver.

Source:
Returns:

webdriver instance

Type
object

<async> click( [opts])

Clicks element in browser.

Parameters:
Name Type Argument Description
opts object <optional>

Options.

Properties
Name Type Argument Default Description
now boolean <optional>
false

Make it immediately.

timeout number <optional>
<nullable>

Time to wait for element visibility, sec.

scroll boolean <optional>
true

Scroll to element.

Source:
Returns:
Type
Promise

<async> clone( [opts])

Clones element with custom properties.

Parameters:
Name Type Argument Description
opts object <optional>

Clone options.

Properties
Name Type Argument Description
name string <optional>

Element name.

selector object <optional>

CSS selector of DOM element.

page Page <optional>

Page with element.

Source:
Returns:

Cloned element.

Type
Element

<async> getCount()

Gets count of elements in browser.

Source:
Returns:

Count of elements

Type
Promise.<integer>

<async> getElement()

Gets webdriver element.

Source:
Returns:

Webdriver element.

Type
Promise.<object>

<async> getElements()

Gets webdriver elements.

Source:
Returns:

Webdriver elements.

Type
Promise.<array.<object>>

<async> getText( [opts])

Gets text content of DOM element.

Parameters:
Name Type Argument Description
opts object <optional>

Options.

Properties
Name Type Argument Default Description
now boolean <optional>
false

Make it immediately.

timeout number <optional>
<nullable>

Time to wait for element visibility, sec.

Source:
Returns:

Text value or null.

Type
Promise.<string>

<async> isExist()

Defines whether element is exist or no.

Source:
Returns:

true if element is exist, false otherwise.

Type
Promise.<boolean>

<async> isSelected( [opts])

Defines whether element is selected or no.

Parameters:
Name Type Argument Description
opts object <optional>

Options.

Properties
Name Type Argument Default Description
now boolean <optional>
false

Make it immediately.

timeout number <optional>
<nullable>

Time to wait for element visibility, sec.

Source:
Returns:

true if element is selected, false otherwise.

Type
Promise.<boolean>

isVisible()

Defines whether element is visible or no.

Source:
Returns:

true if element is visible, false otherwise.

Type
Promise.<boolean>

<async> location()

Gets DOM element location with attributes: x, y, midX, midY, width, height.

Source:
Returns:

Location of element.

Type
Promise.<object>

<async> pClick( [opts])

Clicks element in browser via pointer events.

Parameters:
Name Type Argument Description
opts object <optional>

Options.

Properties
Name Type Argument Default Description
now boolean <optional>
false

Make it immediately.

timeout number <optional>
<nullable>

Time to wait for element visibility, sec.

scroll boolean <optional>
true

Scroll to element.

Source:
Returns:
Type
Promise

<async> scrollIntoView( [opts])

Scrolls element into browser viewport.

Parameters:
Name Type Argument Description
opts object <optional>

Options.

Properties
Name Type Argument Default Description
now boolean <optional>
false

Make it immediately.

timeout number <optional>
<nullable>

Time to wait for element visibility, sec.

Source:
Returns:
Type
Promise

<async> setText(text [, opts])

Sets text to DOM element.

Parameters:
Name Type Argument Description
text string

Text value to assign.

opts object <optional>

Options.

Properties
Name Type Argument Default Description
now boolean <optional>
false

Make it immediately.

timeout number <optional>
<nullable>

Time to wait for element visibility, sec.

scroll boolean <optional>
true

Scroll to element.

enter boolean <optional>
false

Send Enter after text.

Source:
Returns:
Type
Promise

<async> tap( [opts])

Taps element in browser.

Parameters:
Name Type Argument Description
opts object <optional>

Options.

Properties
Name Type Argument Default Description
now boolean <optional>
false

Make it immediately.

timeout number <optional>
<nullable>

Time to wait for element visibility, sec.

scroll boolean <optional>
true

Scroll to element.

Source:
Returns:
Type
Promise

<async> waitForExist( [timeout])

Waits for element is exist.

Parameters:
Name Type Argument Description
timeout number <optional>

Timeout to wait, sec.

Source:
Throws:

If element doesn't exist after timeout.

Type
TimeoutError
Returns:
Type
Promise

<async> waitForInvisible( [timeout])

Waits for element is invisible.

Parameters:
Name Type Argument Description
timeout number <optional>

Timeout to wait, sec.

Source:
Throws:

If element is still visible after timeout.

Type
TimeoutError
Returns:
Type
Promise

<async> waitForNonExist( [timeout])

Waits for element isn't exist.

Parameters:
Name Type Argument Description
timeout number <optional>

Timeout to wait, sec.

Source:
Throws:

If element is still exist after timeout.

Type
TimeoutError
Returns:
Type
Promise

<async> waitForVisible( [timeout])

Waits for element is visible.

Parameters:
Name Type Argument Description
timeout number <optional>

Timeout to wait, sec.

Source:
Throws:

If element isn't visible after timeout.

Type
TimeoutError
Returns:
Type
Promise