Members
assert
- Source:
- Deprecated:
- Yes
browserPage
- Source:
url
- Description:
URL of current page
- Source:
URL of current page
webContents
- Source:
window
- Source:
Methods
assertScreen(identifier, options) → {Promise}
- Description:
Assert that the current screen is equal to the expected screenshot. The screenshot is compared against "(screenshotsDir)/expected/(browserVariant)/(identifier).png",
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
identifier |
String | identifier used as the screenshot fileName |
options |
object | overrides config.assertion (ssimThreshold, diffThreshold) |
Returns:
If the screenshot matches expected, Promise is resolved. If not matches, Promise is rejected.
- Type
- Promise
executeJs(code) → {Promise}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
code |
string | JavaScript Code for executing this page. |
Returns:
- Type
- Promise
find() → {Finder}
- Description:
Create and Return new Finder object with given finder-condition
- Source:
Returns:
- Type
- Finder
getSourceHTML() → {Promise}
- Description:
Get the HTML source of current page.
- Source:
Returns:
resolved by current HTML source.
- Type
- Promise
inIframe(finderForIframe) → {Page}
- Description:
Create and Return new Page object in given iframe context.
- Source:
Example
const pageInIframe = page.inIframe(page.find("iframe").first());
await pageInIframe.find("h3").text()
Parameters:
| Name | Type | Description |
|---|---|---|
finderForIframe |
Finder | finder object for iframe |
Returns:
- Type
- Page
load() → {Promise}
- Description:
Load new page which is URL given, and returned Promise is resolved when finished load.
- Source:
Returns:
- Type
- Promise
reload() → {Promise.<object>}
- Description:
Reload current page.
- Source:
Returns:
- Type
- Promise.<object>
setExtraHTTPHeaders(headers) → {Promise}
- Description:
Set HTTP Headers for all requests in this page.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
headers |
* |
Returns:
- Type
- Promise
takeScreenshot(fileName) → {Promise}
- Description:
Take a screenshot of this page.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
fileName |
String | fileName for saving as it in config.screentshotsDir. If absolutePath is given, save to it. |
Returns:
resolved when taken, the value is absolute filePath
- Type
- Promise
waitForAlert(alertOptioin, action) → {Promise}
- Source:
Example
await page.waitAlertDialog({ message: "You are wrong!" }, ()=>{
page.find("button.submit-form").click()
})
Parameters:
| Name | Type | Description |
|---|---|---|
alertOptioin |
object | specify message property(default undefined), and timeout property(msec. default config.mocha.timeout) |
action |
function | A function representing the operation of open alert dialog |
Returns:
- Type
- Promise
waitForBrowserSocket(socketOption, action) → {Promise}
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
socketOption |
object | specify channel property, and timeout property(msec. default config.mocha.timeout). |
action |
function | A function representing the operation of sending Browser Socket Message |
Returns:
- Type
- Promise
waitForConfirm(confirmOption, action) → {Promise}
- Source:
Example
await page.waitConfirm({ message: "Are you OK?", isClickOK: false }, ()=>{
page.find("button.submit-form").click()
})
await page.waitLoading(async ()=>{
await page.waitForConfirm(async ()=>{
await page.find("button.submit-form").click()
})
})
Parameters:
| Name | Type | Description |
|---|---|---|
confirmOption |
object | specify message property(default undefined), isClickOK property(default true), and timeout property(msec. default config.mocha.timeout) |
action |
function | A function representing the operation of open confirm dialog |
Returns:
- Type
- Promise
waitForDownload(action, options) → {Promise.<object>}
- Description:
Wait file-download completed and resolve the promise with result object(contains filename, savedFilePath) A File is saved in config.fileDownloadDir with timestamp string like '20171225002540_print.pdf'
- Source:
Example
const item = await page.waitForDownload(()=>{
...
})
assert.equal(await (util.promisify(fs.readFile))(item.savedFilePath, 'utf-8'), ...);
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
action |
function | A function representing the operation of file download |
|||||||||
options |
object | options for downloading Properties
|
Returns:
object have property "filename" and "savedFilePath"
- Type
- Promise.<object>
waitForFinder(finder, action, options) → {Promise}
- Description:
Wait for appearance of element specified by Finder object.
- Source:
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
finder |
Finder | Finder object for finding element. |
||||||
action |
function |
|
||||||
options |
object |
Properties
|
Returns:
- Type
- Promise
waitForNewWindow(action, options) → {Promise}
- Description:
Wait new-window opend and resolve the promise with Window object.
- Source:
Example
const newWin = await page.waitForNewWindow(()=>{
...
})
newWin.page.find(...).click();
newWin.close();
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
action |
function | A function representing the operation of open new window |
||||||
options |
object |
Properties
|
Returns:
- Type
- Promise
waitForPageLoad(action, options) → {Promise}
- Description:
Wait loading for contents in new page.
- Source:
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
action |
function | A function representing the operation of loading new page. |
||||||
options |
object |
Properties
|
Returns:
- Type
- Promise
waitForSelector(cssSelector, action, options) → {Promise}
- Description:
Wait for appearance of element specified by css-selector.
- Source:
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
cssSelector |
string | CSS Selector string for finding element. |
||||||
action |
function |
|
||||||
options |
object |
Properties
|
Returns:
- Type
- Promise
wget()
- Description:
Download file that url given. This method operates outside of browser.
- Source: