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 optsobject <optional>
Options.
Properties
Name Type Argument Default Description nowboolean <optional>
false Make it immediately.
timeoutnumber <optional>
<nullable>
Time to wait for element visibility, sec.
scrollboolean <optional>
true Scroll to element.
- Source:
Returns:
- Type
- Promise
-
<async> clone( [opts])
-
Clones element with custom properties.
Parameters:
Name Type Argument Description optsobject <optional>
Clone options.
Properties
Name Type Argument Description namestring <optional>
Element name.
selectorobject <optional>
CSS selector of DOM element.
pagePage <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 optsobject <optional>
Options.
Properties
Name Type Argument Default Description nowboolean <optional>
false Make it immediately.
timeoutnumber <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:
trueif element is exist,falseotherwise.- Type
- Promise.<boolean>
-
<async> isSelected( [opts])
-
Defines whether element is selected or no.
Parameters:
Name Type Argument Description optsobject <optional>
Options.
Properties
Name Type Argument Default Description nowboolean <optional>
false Make it immediately.
timeoutnumber <optional>
<nullable>
Time to wait for element visibility, sec.
- Source:
Returns:
trueif element is selected,falseotherwise.- Type
- Promise.<boolean>
-
isVisible()
-
Defines whether element is visible or no.
- Source:
Returns:
trueif element is visible,falseotherwise.- 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 optsobject <optional>
Options.
Properties
Name Type Argument Default Description nowboolean <optional>
false Make it immediately.
timeoutnumber <optional>
<nullable>
Time to wait for element visibility, sec.
scrollboolean <optional>
true Scroll to element.
- Source:
Returns:
- Type
- Promise
-
<async> scrollIntoView( [opts])
-
Scrolls element into browser viewport.
Parameters:
Name Type Argument Description optsobject <optional>
Options.
Properties
Name Type Argument Default Description nowboolean <optional>
false Make it immediately.
timeoutnumber <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 textstring Text value to assign.
optsobject <optional>
Options.
Properties
Name Type Argument Default Description nowboolean <optional>
false Make it immediately.
timeoutnumber <optional>
<nullable>
Time to wait for element visibility, sec.
scrollboolean <optional>
true Scroll to element.
enterboolean <optional>
false Send
Enterafter text.- Source:
Returns:
- Type
- Promise
-
<async> tap( [opts])
-
Taps element in browser.
Parameters:
Name Type Argument Description optsobject <optional>
Options.
Properties
Name Type Argument Default Description nowboolean <optional>
false Make it immediately.
timeoutnumber <optional>
<nullable>
Time to wait for element visibility, sec.
scrollboolean <optional>
true Scroll to element.
- Source:
Returns:
- Type
- Promise
-
<async> waitForExist( [timeout])
-
Waits for element is exist.
Parameters:
Name Type Argument Description timeoutnumber <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 timeoutnumber <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 timeoutnumber <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 timeoutnumber <optional>
Timeout to wait, sec.
- Source:
Throws:
-
If element isn't visible after timeout.
- Type
- TimeoutError
Returns:
- Type
- Promise