Home Reference Source
import Page from 'pagewalker/lib/page/page.js'
public class | source

Page

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public get
this get was deprecated.
public get
public get

url: string: *

URL of current page

public get
public get
Private Members
private

_assert: *

private
private
private get

context: *

Method Summary

Public Methods
public

assertScreen(identifier: *, options: *): Assert

public
public

find(args: ...*): Finder

Create and Return new Finder object with given finder-condition

public

Get the HTML source of current page.

public

inIframe(finderForIframe: Finder): Page

Create and Return new Page object in given iframe context.

public

load(url: *, options: {}): Promise

Load new page which is URL given, and returned Promise is resolved when finished load.

public
public

Reload current page.

public

Take a screenshot of this page.

public
public

waitForAlert(alertOptioin: object, action: function): Promise

public

waitForBrowserSocket(socketOption: object, action: function): Promise

public

waitForConfirm(confirmOption: object, action: function): Promise

public

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'

public

waitForFinder(finder: Finder, action: function): Promise

Wait for appearance of element specified by Finder object.

public

Wait new-window opend and resolve the promise with Window object.

public

Wait loading for contents in new page.

public

waitForSelector(cssSelector: string, action: function): Promise

Wait for appearance of element specified by css-selector.

public

wget(url: *): *

Download file that url given.

Private Methods
private

newPromiseWithCheckReady(func: *, action: *): *

if window.isReadyForPage is false, return failed promise.

Public Constructors

public constructor() source

Public Members

public get assert: Assert: * source

this get was deprecated.

Return:

Assert

Assert Object

public get browserPage: BrowserPage: * source

Return:

BrowserPage

BrowserPage Object(Instance will be relayed on Browser used)

public get url: string: * source

URL of current page

Return:

string

public get webContents: object: * source

Return:

object

Page Object provided by Each Browser

public get window: Window: * source

Return:

Window

Window Object which contains this page.

Private Members

private _assert: * source

private _browserPage: * source

private _context: * source

private get context: * source

Public Methods

public assertScreen(identifier: *, options: *): Assert source

Params:

NameTypeAttributeDescription
identifier *
options *

Return:

Assert

Assert Object

public executeJs(code: string): Promise source

Params:

NameTypeAttributeDescription
code string

JavaScript Code for executing this page.

Return:

Promise

public find(args: ...*): Finder source

Create and Return new Finder object with given finder-condition

Params:

NameTypeAttributeDescription
args ...*

Return:

Finder

public getSourceHTML(): Promise source

Get the HTML source of current page.

Return:

Promise

resolved by current HTML source.

public inIframe(finderForIframe: Finder): Page source

Create and Return new Page object in given iframe context.

Params:

NameTypeAttributeDescription
finderForIframe Finder

finder object for iframe

Return:

Page

Example:

  const pageInIframe = page.inIframe(page.find("iframe").first());
  await pageInIframe.find("h3").text()

public load(url: *, options: {}): Promise source

Load new page which is URL given, and returned Promise is resolved when finished load.

Params:

NameTypeAttributeDescription
url *
options {}
  • optional
  • default: {}

Return:

Promise

public openDevTools(): * source

Return:

*

public reload(): Promise<object> source

Reload current page.

Return:

Promise<object>

public takeScreenshot(fileName: String): Promise source

Take a screenshot of this page.

Params:

NameTypeAttributeDescription
fileName String

fileName for saving as it in config.screentshotsDir. If absolutePath is given, save to it.

Return:

Promise

resolved when taken, the value is absolute filePath

public waitForAjaxDone(action: function): Promise source

Params:

NameTypeAttributeDescription
action function

A function representing the operation of sending Ajax request

Return:

Promise

public waitForAlert(alertOptioin: object, action: function): Promise source

Params:

NameTypeAttributeDescription
alertOptioin object

specify message property(default undefined)

action function

A function representing the operation of open alert dialog

Return:

Promise

Example:

  await page.waitAlertDialog({ message: "You are wrong!" }, ()=>{
    page.find("button.submit-form").click()
  })

public waitForBrowserSocket(socketOption: object, action: function): Promise source

Params:

NameTypeAttributeDescription
socketOption object

specify channel property, and timeout property.

action function

A function representing the operation of sending Browser Socket Message

Return:

Promise

public waitForConfirm(confirmOption: object, action: function): Promise source

Params:

NameTypeAttributeDescription
confirmOption object

specify message property(default undefined), and isClickOK property(default true)

action function

A function representing the operation of open confirm dialog

Return:

Promise

Example:

  await page.waitConfirmDialog({ 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()
    })
  })

public waitForDownload(action: function, options: object): Promise<object> source

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'

Params:

NameTypeAttributeDescription
action function

A function representing the operation of file download

options object

options for downloading

Return:

Promise<object>

object have property "filename" and "savedFilePath"

Example:

  const item = await page.waitForDownload(()=>{
    ...
  })
  assert.equal(await (util.promisify(fs.readFile))(item.savedFilePath, 'utf-8'), ...);

public waitForFinder(finder: Finder, action: function): Promise source

Wait for appearance of element specified by Finder object.

Params:

NameTypeAttributeDescription
finder Finder

Finder object for finding element.

action function
  • A function representing the operation

Return:

Promise

public waitForNewWindow(action: function): Promise source

Wait new-window opend and resolve the promise with Window object.

Params:

NameTypeAttributeDescription
action function

A function representing the operation of open new window

Return:

Promise

Example:

  const newWin = await page.waitForNewWindow(()=>{
    ...
  })
  newWin.page.find(...).click();
  newWin.close();

public waitForPageLoad(action: function): Promise source

Wait loading for contents in new page.

Params:

NameTypeAttributeDescription
action function

A function representing the operation of loading new page.

Return:

Promise

public waitForSelector(cssSelector: string, action: function): Promise source

Wait for appearance of element specified by css-selector.

Params:

NameTypeAttributeDescription
cssSelector string

CSS Selector string for finding element.

action function
  • A function representing the operation

Return:

Promise

public wget(url: *): * source

Download file that url given. This method operates outside of browser.

Params:

NameTypeAttributeDescription
url *

Return:

*

Private Methods

private newPromiseWithCheckReady(func: *, action: *): * source

if window.isReadyForPage is false, return failed promise. if window.isReadyForPage is true, invoke given "func". And "resolve" which is passed to "func" is resolved, "action" will be called.

Params:

NameTypeAttributeDescription
func *
action *

Return:

*