Constructor
new SeleniumDriver(options)
Create a new SeleniumDriver object
- Source:
Parameters:
Name | Type | Description |
---|---|---|
options |
DriverOptions
|
Options to initialize this driver |
Methods
_matchText(search, exact) → {string}
Construct dynamic statement depending on search
type for a positive match
- Source:
Parameters:
Name | Type | Description |
---|---|---|
search |
string
|
RegExp
|
String to base statement construction |
exact |
boolean
|
If exact use wording |
Returns:
- Type:
-
string
- Constructed statement
_matchTextNot(search, exact) → {string}
Construct dynamic statement depending on search
type for a negative match
- Source:
Parameters:
Name | Type | Description |
---|---|---|
search |
string
|
RegExp
|
String to base statement construction |
exact |
boolean
|
If exact use wording |
Returns:
- Type:
-
string
- Constructed statement
_pagePath(page)
Ensure page
begins with a slash
- Source:
Parameters:
Name | Type | Description |
---|---|---|
page |
string
|
(async) click(selector)
Click an element specified by css selector
- Source:
Parameters:
Name | Type | Description |
---|---|---|
selector |
string
|
CSS selector to be clicked |
Throws:
-
- Unable to click selector:
'${selector}'
- Unable to click selector:
- Type
-
Error
(async) elementSelector(element) → {string}
Build accurate element selector based on DOM attributes
- Source:
Parameters:
Name | Type | Description |
---|---|---|
element |
selenium-webdriver.WebElement
|
Expects selenium-webdriver.WebElement |
Returns:
- Type:
-
string
${tag}#${id}.${class}
(async) error(msg)
Handle error with msg
. Save browser logs and screenshot to DriverOptions
.debugDirectory
- Source:
Parameters:
Name | Type | Description |
---|---|---|
msg |
string
|
Message for this error. Used for debug dir name and thrown error message |
Throws:
-
msg
+ debug info
- Type
-
Error
(async) expectElement(selector, contentopt, exactopt) → {selenium-webdriver.WebElement}
Wait for element specified by css selector
and optional content
.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
selector |
string
|
CSS selector of expected element |
||
content |
string
|
RegExp
|
<optional> |
Optional content to also be expected within element text |
|
exact |
boolean
|
<optional> |
false |
If |
Throws:
-
- No element with selector:
'${selector}'
- No element with selector:
- Type
-
Error
(async) expectPage(page, exactopt)
Wait for current path to be, match, or contain page
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
page |
string
|
RegExp
|
Page path to wait for |
||
exact |
boolean
|
<optional> |
false |
If |
Throws:
-
- Page did not match:
'${page}'
- Page did not match:
- Type
-
Error
(async) expectStale(element)
Wait for specified element
to become stale
- Source:
Parameters:
Name | Type | Description |
---|---|---|
element |
selenium-webdriver.WebElement
|
Expects selenium-webdriver.WebElement |
Throws:
-
- Element is not stale:
'${await this.elementSelector(element)}'
- Element is not stale:
- Type
-
Error
(async) expectTitle(title, exactopt)
Wait for page title to be, contain, or match title
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
title |
string
|
RegExp
|
Title to wait for |
||
exact |
boolean
|
<optional> |
false |
If |
Throws:
-
- Title did not match:
'${title}'
- Title did not match:
- Type
-
Error
(async) fillIn(selector, value, enteropt)
Fill in an element with value
specified by css selector
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
selector |
string
|
CSS selector of element to receive keys |
||
value |
string
|
Value to be sent to element as keys |
||
enter |
boolean
|
<optional> |
false |
Flag to also send the |
Throws:
-
- Unable to send keys to selector:
'${selector}'
- Unable to send keys to selector:
- Type
-
Error
(async) scrollTo(element)
Scroll to element
- Source:
Parameters:
Name | Type | Description |
---|---|---|
element |
selenium-webdriver.WebElement
|
WebElement to scroll to |
(async) select(selector, value)
Select an option with value or text value
specified by css selector
- Source:
Parameters:
Name | Type | Description |
---|---|---|
selector |
string
|
CSS selector of |
value |
string
|
Value (or text) of an |
Throws:
-
- Unable to select value/text:
'${value}'
from selector:'${selector}'
- Unable to select value/text:
- Type
-
Error
(async) start()
Start this driver instance. Delete Cookies and visit homepage (see DriverOptions
.homePagePath
)
- Source:
(async) visit(page)
Visit specified page
- Source:
Parameters:
Name | Type | Description |
---|---|---|
page |
string
|
Path of page to visit |