Skip to content

ElementWrapper class

Wrapper object of all found elements. This list mimics the behaviour of Element by exposing similar methods. The call of these methods gets delegated to first element. By default, the ElementWrapper acts as a proxy to the first matching element and hence it forwards function calls that belong to Element

API documentation for get.

NameTypeDescription
retryIntervalnumberRetry Interval in milliseconds (defaults to global settings).
retryTimeoutnumberRetry Timeout in milliseconds (defaults to global settings).
TypeDescription
Array<Element>All elements mathing the selector.

Describes the operation performed. The description is the same that is printed when performing the operation in REPL.

link('google').description // prints "'Link with text google'"

This API does not have any parameters.

TypeDescription
stringDescription of the current command that fetched this element(wrapper).

Checks existence for element. exists() waits for retryTimeout before deciding that the page is loaded. (NOTE: exists() returns boolean from version 0.4.0)

// To 'short-circuit' non existence. However this should be done only if there is no network calls/reloads.
element.exists(0,0)
link('google').exists()
link('google').exists(1000)
NameTypeDescription
retryIntervalnumberRetry Interval in milliseconds (defaults to global settings).
retryTimeoutnumberRetry Timeout in milliseconds (defaults to global settings).
TypeDescription
booleantrue if exists, else false.

Gets the innerText of the element

This API does not have any parameters.

TypeDescription
stringinnerText of the element

Checks if element is visually visible. isVisible() is false when the element is overshadowed by another element, or if the element is outside the viewport.

NameTypeDescription
retryIntervalnumberRetry Interval in milliseconds (defaults to global settings).
retryTimeoutnumberRetry Timeout in milliseconds (defaults to global settings).
TypeDescription
booleantrue if visible, else false.

Checks if element is disabled

NameTypeDescription
retryIntervalnumberRetry Interval in milliseconds (defaults to global settings).
retryTimeoutnumberRetry Timeout in milliseconds (defaults to global settings).
TypeDescription
booleantrue if disabled, else false.

Checks if element is draggable.

NameTypeDescription
retryIntervalnumberRetry Interval in milliseconds (defaults to global settings).
retryTimeoutnumberRetry Timeout in milliseconds (defaults to global settings).
TypeDescription
booleantrue if disabled, else false.

Read attribute value of the element found.

link('google').attribute('alt')
NameTypeDescription
namestring
TypeDescription
stringvalue of attribute

DOM element getter. Implicitly wait for the element to appears with timeout of 10 seconds.

// To loop over all the elements
let elements = await $('a').elements();
for (element of elements) {
console.log(await element.text());
}
textBox('username').value()
(await textBox('username').elements())[0].value() # same as above
$('.class').text()
(await $('.class').elements())[0].text() # same as above
let element = await $('a').element(0);
console.log(await element.text());
NameTypeDescription
retryIntervalnumberRetry Interval in milliseconds (defaults to global settings).
retryTimeoutnumberRetry Timeout in milliseconds (defaults to global settings).
TypeDescription
Array<Element>Array of all elements matching the selector.

DOM element getter. Implicitly wait for the element to appears with timeout of 10 seconds.

NameTypeDescription
indexnumberZero-based index of element to return
retryIntervalnumberRetry Interval in milliseconds (defaults to global settings).
retryTimeoutnumberRetry Timeout in milliseconds (defaults to global settings).
TypeDescription
ElementFirst element that matches the selector.