Constructor
new Element(driver, elObject)
Constructor. You never have to run this yourself, since both Driver#findElement
and Driver#findElements will run new Element()
for you.
Parameters:
Name | Type | Description |
---|---|---|
driver |
Driver |
The driver that originally created this element |
elObject |
object |
An element object as it was returned by the webdriver. |
- Mixes In:
- Source:
Extends
Members
(static) Key
Constant returning special KEY characters (enter, etc.) Constant are from the global variable KEY
- Source:
Example
var el = await driver.findElementCss('#input')
await e.sendKeys("This is a search" + Element.Key.ENTER)
Methods
(async) waitFor()
Alias to Driver's waitFor function
- Source:
(async) isSelected() → {Promise.<boolean>}
Check that the element is selected
- Source:
(async) getAttribute(name) → {Promise.<string>}
Get attribute called name
from element
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
The name of the attribute to be fetched |
- Source:
(async) getProperty(name) → {Promise.<string>}
Get property called name
from element
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
The name of the property to be fetched |
- Source:
(async) getCssValue(name) → {Promise.<string>}
Get css value from element
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
The name of the CSS value to be fetched |
- Source:
(async) getText() → {Promise.<string>}
Get text value from element
- Source:
(async) getTagName() → {Promise.<string>}
Get tag name from element
- Source:
(async) getRect() → {Promise.<string>}
Get rect from element
- Source:
(async) isEnabled() → {Promise.<boolean>}
Check that the element is enabled
- Source:
(async) click() → {Promise.<Element>}
Click on an element
- Source:
(async) clear() → {Promise.<Element>}
Clear an element
- Source:
(async) sendKeys() → {Promise.<Element>}
Send keys to an element
- Source:
Example
var el = await driver.findElementCss('#input')
await e.sendKeys("This is a search" + Element.Key.ENTER)
(async) takeScreenshot(scroll) → {Promise.<Buffer>}
Take screenshot of the element
Parameters:
Name | Type | Default | Description |
---|---|---|---|
scroll |
boolean | true |
If true (by default), it will scroll to the element |
- Source:
(async) findElement(using, value) → {Promise.<Element>}
Find an element within this element
Note that you are encouraged to use one of the helper functions:
findElementCss()
, findElementLinkText()
, findElementPartialLinkText()
,
findElementTagName()
, findElementXpath()
Parameters:
Name | Type | Description |
---|---|---|
using |
string |
It can be |
value |
string |
The parameter to the |
- Source:
Example
// Find the element using the driver's `findElement()` call
var ul = await driver.findElement({ Driver.Using.CSS, value: 'ul' )
// Find the first LI element within the found UL
var items = await ul.findElement({ Driver.Using.CSS, value: 'li')
(async) findElements(using, value) → {Promise.<Array.<Element>>}
Find several elements within this element
Note that you are encouraged to use one of the helper functions:
findElementCss()
, findElementLinkText()
, findElementPartialLinkText()
,
findElementTagName()
, findElementXpath()
Parameters:
Name | Type | Description |
---|---|---|
using |
string |
It can be |
value |
string |
The parameter to the |
- Source:
Example
// Find the element using the driver's `findElement()` call
var ul = await driver.findElement({ Driver.Using.CSS, value: 'ul' )
// Find ALL LI sub-elements within the found UL element
var items = await ul.findElements({ Driver.Using.CSS, value: 'li')
(async) findElementCss(value)
Find first element matching CSS
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The CSS expression |
- Overrides:
- Source:
(async) findElementLinkText(value)
Find first element matching text
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The text to match |
- Overrides:
- Source:
Example
var a = driver.findElementLinkText('cick here')
// or...
var el = driver.findElementCss('#something') // or
var l = item.findElementLinkText('click here')
(async) findElementPartialLinkText(value)
Find first element matching link text
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The link text to match |
- Overrides:
- Source:
Example
var a = driver.findElementPartialLinkText('cick here')
// or...
var el = driver.findElementCss('#something') // or
var l = item.findElementPartialLinkText('click here')
(async) findElementTagName(value)
Find first element matching tag name
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The tag name to match |
- Overrides:
- Source:
Example
var item = driver.findElementTagName('item') // or
var subItem = item.findElementTagName('subitem')
(async) findElementXpath(value)
Find first element matching xpath
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The xpath to match |
- Overrides:
- Source:
Example
var item = driver.findElementXpath('/html/body/form[1]') // or
var subItem = item.findElementXpath('/div/div/subitem')
(async) findElementsCss(value)
Find all elements matching CSS
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The CSS expression |
- Overrides:
- Source:
Example
var allItems = driver.findElementsCss('.list')
var item = allItems[0]
var allTitles = item.findElementsCss('.title')
(async) findElementsLinkText(value)
Find all elements matching text
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The text to match |
- Overrides:
- Source:
Example
var links = driver.findElementsLinkText('cick here')
// or...
var el = driver.findElementCss('#something') // or
var links = item.findElementsLinkText('click here')
(async) findElementsPartialLinkText(value)
Find all elements matching link text
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The link text to match |
- Overrides:
- Source:
Example
var links = driver.findElementsPartialLinkText('cick here')
// or...
var el = driver.findElementCss('#something') // or
var links = item.findElementsPartialLinkText('click here')
(async) findElementsTagName(value)
Find all elements matching tag name
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The tag name to match |
- Overrides:
- Source:
Example
var items = driver.findElementsTagName('item') // or
var el = items[0]
var subItem = el.findElementsTagName('subitem')
(async) findElementsXpath(value)
Find all elements matching xpath
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
The xpath to match |
- Overrides:
- Source: