Mixin: BrowserSteps

BrowserSteps

Steps for web applications.

Source:

Methods


<protected> _setChromeOpts( [chromeOpts])

Helper to set chrome options.

It composes chrome options list in next order:

  • user provided options
  • proxy options if they are not present in list
  • default config options if they are not present in list
Parameters:
Name Type Argument Default Description
chromeOpts array <optional>
[]

List of chrome options.

Source:

<async> closeAllBrowsers( [opts])

Step to close all browsers.

Parameters:
Name Type Argument Description
opts object <optional>

Step options.

Properties
Name Type Argument Default Description
check boolean <optional>
true

Flag to check that browser was closed.

Source:
Returns:
Type
Promise.<void>

<async> closeBrowser( [opts])

Step to close browser.

Parameters:
Name Type Argument Description
opts object <optional>

Step options.

Properties
Name Type Argument Default Description
switchPrev object <optional>
true

Flag to switch browser to last launched.

check boolean <optional>
true

Flag to check that browser was closed.

Source:
Throws:

If browser wasn't closed.

Type
AssertionError
Returns:

true if step is executed, false if skipped.

Type
Promise.<boolean>

<async> getCurrentBrowser( [opts])

Step to get current browser (webdriver instance).

Parameters:
Name Type Argument Description
opts object <optional>

Step options.

Properties
Name Type Argument Default Description
check boolean <optional>
true

Flag to check that there is launched browser.

Source:
Throws:

If no one browser is launched.

Type
Error
Returns:
  • Dictionary: key - browser uniq name, val - webdriver instance.
Type
object

<async> getLaunchedBrowsers( [opts])

Step to get launched browsers.

Parameters:
Name Type Argument Description
opts object <optional>

Step options.

Properties
Name Type Argument Default Description
check boolean <optional>
true

Flag to check that there are launched browsers.

Source:
Throws:

If no one browser is launched.

Type
Error
Returns:
  • Dictionary: key - browser uniq name, val - webdriver instance.
Type
object

<async> installSeleniumDrivers( [opts])

Step to install selenium drivers.

Parameters:
Name Type Argument Description
opts object <optional>

selenium-standalone options.

Source:
Throws:

If there was error during drivers installation.

Type
Error
Returns:
Type
Promise.<void>

<async> launchBrowser( [opts])

Step to launch browser.

Parameters:
Name Type Argument Description
opts object <optional>

Step options.

Properties
Name Type Argument Default Description
name string <optional>
random

Browser name.

webdriver object <optional>
CONF.webdriver

Webdriver config.

tryExisting boolean <optional>
false

Try to launch existing browser.

check boolean <optional>
true

Flag to check that browser was launched.

chromeOpts Array.<string> <optional>
[]

List of chrome options.

Source:
Throws:

If browser wasn't launched.

Type
AssertionError
Returns:

true if step is executed, false if skipped.

Type
Promise.<boolean>
Example
await $.launchBrowser();
await $.launchBrowser({ chromeOpts: ["headless", "user-data-dir=/path/to/dir"] });

<async> openApp( [opts])

Step to open application URL in browser.

Parameters:
Name Type Argument Description
opts object <optional>

Step options.

Source:
Throws:

If application URL is not defined.

Type
AssertionError
Returns:
Type
Promise.<void>

<async> openUrl(webUrl [, opts])

Step to open URL in browser.

Parameters:
Name Type Argument Description
webUrl string

URL which should be opened in browser.

opts object <optional>

Step options.

Properties
Name Type Argument Default Description
check boolean <optional>
true

Flag to check that URL is opened.

timeout number <optional>

Timeout to wait for URL will be opened in browser, sec. Default value is CONF.web.pageTimeout.

Source:
Throws:

If URL wasn't opened after timeout.

Type
Error
Returns:
Type
Promise.<void>

<async> restartBrowser( [opts])

Step to restart browser.

Parameters:
Name Type Argument Default Description
opts object <optional>
{}

Step options.

Source:
Returns:
Type
Promise.<void>

<async> setViewport( [opts])

Step to set browser viewport size.

Parameters:
Name Type Argument Description
opts object <optional>

Step options.

Properties
Name Type Argument Default Description
width number <optional>

Browser viewport width.

height number <optional>

Browser viewport height.

check boolean <optional>
true

Flag to check step result.

Source:
Throws:
  • If width or height values are not a number.

    Type
    AssertionError
  • If viewport size wasn't changed correctly.

    Type
    AssertionError
Returns:

true when step is executed.

Type
boolean

<async> startSeleniumServer( [opts])

Step to start selenium server. Step recall will be skipped if selenium server wasn't stopped before.

Parameters:
Name Type Argument Description
opts object <optional>

selenium-standalone options.

Source:
Throws:

If there was error on selenium start.

Type
Error
Returns:

true if step is executed, false if skipped.

Type
Promise.<boolean>

<async> stopSeleniumServer()

Step to stop selenium server. Step call will be skipped if selenium server wasn't started before.

Source:
Throws:

If there was error on selenium stop.

Type
Error
Returns:

true if step is executed, false if skipped.

Type
Promise.<boolean>

switchBrowser(name)

Step to switch to browser by name.

Parameters:
Name Type Description
string
name string

Browser uniq name.

Source:
Returns:
  • Webdriver instance.
Type
object