API Docs for: 0.2.7
Show:

ActiveWindow Class

Extends WindowHandler
Module: Navigation
Parent Module: WebDriver

Active window object

Constructor

ActiveWindow

(
  • driver
  • id
)

Parameters:

Methods

_logMethodCall

(
  • event
)
private

Inherited from WindowHandler but overwritten in lib/activeWindow.js:47

Logs a method call by an event

Parameters:

_requestJSON

(
  • method
  • path
  • [body]
)
private

Performs a context dependent JSON request for the current session. The result is parsed for errors.

Parameters:

Returns:

:

activate

()

Activate the current window

alert

() Alert

Get the Alert object. Direct-access. No need to wait.

Returns:

areaScreenshot

(
  • [x=0]
  • [y=0]
  • [width=document.width-x]
  • [height=document.height-y]
  • [options]
)
Buffer deprecated

Defined in lib/activeWindow.js:233

Deprecated: Use captureArea.

Captures a specific area of the document

Parameters:

  • [x=0] Int optional

    X-coordinate for area

  • [y=0] Int optional

    Y-coordinate for area

  • [width=document.width-x] Int optional

    Width of area to be captured

  • [height=document.height-y] Int optional

    Height of area to be captured

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

Returns:

Buffer:

Binary image buffer

asyncExecute

(
  • script
  • [args]
)

Execute a script asynchronously on the browser.

Source should be either a function body as a string or a function. Keep in mind that if it is a function it will not have access to any variables from the node.js process.

Parameters:

captureArea

(
  • [x=0]
  • [y=0]
  • [width=document.width-x]
  • [height=document.height-y]
  • [options]
)
Buffer

Captures a specific area of the document

Parameters:

  • [x=0] Int optional

    X-coordinate for area

  • [y=0] Int optional

    Y-coordinate for area

  • [width=document.width-x] Int optional

    Width of area to be captured

  • [height=document.height-y] Int optional

    Height of area to be captured

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

Returns:

Buffer:

Binary image buffer

captureDocument

(
  • [options]
)
Buffer

Captures the complete document

Parameters:

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

Returns:

Buffer:

Binary image buffer

captureViewPort

(
  • [options]
)
Buffer

Captures the currently visible view-port

Parameters:

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

Returns:

Buffer:

Binary image buffer

close

()

Close the current window

compareArea

(
  • title
  • [x=0]
  • [y=0]
  • [width=document.width-x]
  • [height=document.height-y]
  • [options]
)
Boolean | Null

Compares an area of the document with a previous screenshot, showing differences between them

Parameters:

  • title String

    Unique title for comparison

  • [x=0] Int optional

    X-coordinate for area

  • [y=0] Int optional

    Y-coordinate for area

  • [width=document.width-x] Int optional

    Width of area to be captured

  • [height=document.height-y] Int optional

    Height of area to be captured

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

    • [compare] Object optional

      Options for the comparison. See Blink-Diff documentation.

      • [id=1] Object optional
        Additional identifier to differentiate comparisons even more.

Returns:

Boolean | Null:

Are the screenshots the same? (NULL if there is nothing to compare to)

compareDocument

(
  • title
  • [options]
)
Boolean | Null

Compares the document with a previous screenshot, showing differences between them

Parameters:

  • title String

    Unique title for comparison

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

    • [compare] Object optional

      Options for the comparison. See Blink-Diff documentation.

      • [id=1] Object optional
        Additional identifier to differentiate comparisons even more.

Returns:

Boolean | Null:

Are the screenshots the same? (NULL if there is nothing to compare to)

compareViewPort

(
  • title
  • [options]
)
Boolean | Null

Compares the view-port with a previous screenshot, showing differences between them

Parameters:

  • title String

    Unique title for comparison

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

    • [compare] Object optional

      Options for the comparison. See Blink-Diff documentation.

      • [id=1] Object optional
        Additional identifier to differentiate comparisons even more.

Returns:

Boolean | Null:

Are the screenshots the same? (NULL if there is nothing to compare to)

documentScreenshot

(
  • [options]
)
Buffer deprecated

Defined in lib/activeWindow.js:157

Deprecated: Use captureDocument.

Captures the complete document

Parameters:

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

Returns:

Buffer:

Binary image buffer

execute

(
  • script
  • [args]
)

Execute a script on the browser and return the result.

Source should be either a function body as a string or a function. Keep in mind that if it is a function it will not have access to any variables from the node.js process.

Parameters:

Returns:

:

frame

() Frame

Get the Frame object. Direct-access. No need to wait.

Returns:

getActiveElement

() Element

Get the element on the page that currently has focus

Returns:

getElement

(
  • selector
  • [selectorType='css
)
Element

Get an element via a selector. Will throw an error if the element does not exist.

Parameters:

Returns:

getElements

(
  • selector
  • [selectorType='css
)
Array.

Get elements via a selector.

Parameters:

Returns:

Array.:

getId

() String

Get the value of the element id. Should the id resolve to 'current', then it will request the actual id.

Returns:

getPosition

() Object

Get the position of a window

Returns:

Object:

{x: number, y: number}

getScrollPosition

() Object

Gets the scroll coordinates

Returns:

Object:

Position as { x:, y: }

getSize

() Object

Get the size of a window

Returns:

Object:

{width: number, height: number}

getSource

() String

Get the current page source

Returns:

getTitle

() String

Get the current page title

Returns:

hasElement

(
  • selector
  • [selectorType='css
)
Boolean

Does a specific element exist?

Parameters:

Returns:

id

() String

Get the value of the element id. Direct-access. No need to wait.

Returns:

init

(
  • horizontalPadding
)

Provided by the WebDriver module.

Defined in lib/scripts/devicePixelRatio.js:7

Initialize the device-pixel-ratio determination, collecting information that need to be reverted later on and modifying the document for device-pixel-ratio data.

Parameters:

  • horizontalPadding Int

init

(
  • horizontalPadding
)

Provided by the WebDriver module.

Defined in lib/scripts/stitching.js:3

Initializes the stitching determination. It gathers the current document state, and it will modify the document as needed.

Parameters:

  • horizontalPadding Int

init

(
  • needsStitching
)

Provided by the WebDriver module.

Defined in lib/scripts/screenshot.js:3

Initializes screenshots and gathers data to revert changes. This function will also gather information required for screenshots like dimensions of document and view-port.

Parameters:

maximize

()

Maximize a window

mouse

() GlobalMouse

Get the global-mouse object. Direct-access. No need to wait.

Returns:

navigator

() Navigator

Get the Navigator object. Direct-access. No need to wait.

Returns:

position

(
  • x
  • y
)

Position a window

Parameters:

resize

(
  • width
  • height
)

Get the size of a window

Parameters:

revert

(
  • initData
)

Provided by the WebDriver module.

Defined in lib/scripts/devicePixelRatio.js:60

Reverts all changes done to the document in the init

Parameters:

  • initData Object

    Data gathered during init-phase

revert

(
  • initData
)

Provided by the WebDriver module.

Defined in lib/scripts/screenshot.js:72

Reverts changes done to the document during the screenshot process

Parameters:

  • initData Object

    Data gathered during init-phase

revert

(
  • initData
)

Provided by the WebDriver module.

Defined in lib/scripts/stitching.js:45

Revert changes done to the document during the init-phase

Parameters:

  • initData Object

    Data gathered during init-phase

saveScreenshot

(
  • path
  • [options.horizontalPadding=0]
  • [options.eachFn]
  • [options.completeFn]
  • [options.blockOuts]
  • [options.blockOutColor=black]
  • [options.wait=100]
  • [options]
)

Take a screenshot of the current page and save to a file

Parameters:

  • path String

    Path where the file should be saved to

  • [options.horizontalPadding=0] Int optional

    Padding of the document for adjustment

  • [options.eachFn] Function optional

    Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

  • [options.completeFn] Function optional

    Will execute method on client after all screenshots are taken.

  • [options.blockOuts] Object[] | Element[] | String[] optional

    List of areas/elements that should be blocked-out

  • [options.blockOutColor=black] Object optional

    Color to be used for blocking-out areas {red, green, blue, alpha}

  • [options.wait=100] Int optional

    Wait in ms before each screenshot

  • [options] Object optional

scrollBy

(
  • [x=0]
  • [y=0]
)

Scrolls by a specific coordinate, relative to the current position

Parameters:

scrollTo

(
  • [x=0]
  • [y=0]
)

Scrolls to a specific coordinate

Parameters:

sendKeys

(
  • str
)

Type a string of characters into the browser

Note: Modifier keys is kept between calls, so mouse interactions can be performed while modifier keys are depressed.

Parameters:

takeScreenshot

(
  • [options]
)
Buffer deprecated

Take a screenshot of the current page

Parameters:

Returns:

Buffer:

Binary image buffer

touch

() GlobalTouch

Get the global-touch object. Direct-access. No need to wait.

Returns:

viewPortScreenshot

(
  • [options]
)
Buffer deprecated

Defined in lib/activeWindow.js:193

Deprecated: Use captureViewPort.

Captures the currently visible view-port

Parameters:

  • [options] Object optional
    • [horizontalPadding=0] Int optional

      Padding of the document for adjustment

    • [eachFn] Function optional

      Will execute method on client before each screenshot is taken. First parameter is index of screenshot.

    • [completeFn] Function optional

      Will execute method on client after all screenshots are taken.

    • [blockOuts] Object[] | Element[] | String[] optional

      List of areas/elements that should be blocked-out

    • [blockOutColor=black] Object optional

      Color to be used for blocking-out areas {red, green, blue, alpha}

    • [wait=100] Int optional

      Wait in ms before each screenshot

Returns:

Buffer:

Binary image buffer