selenium-assistant

A node module that helps using browsers with selenium

  • Selenium Assistant
  • Travis CI Support
  • Contributing
  • Reference Docs
  • Modules
  • selenium-assistant
  • Classes
  • Browser
  • LocalBrowser
  • SauceLabsBrowser
  • SeleniumAssistant

LocalBrowser extends Browser

The LocalBrowser class is an abstract class that is overriden by browser classes that are supported (Chrome, Firefox, Opera and Safari).

Constructor

new LocalBrowser(config, release, blacklist)

Construct a new local browser.

Parameters
config DriverConfig

The config for the browser.

release String

Release name of the browser, must be 'stable', 'beta' or 'unstable'.

blacklist Object

This is a list of browser versions => driver versions which is used to blacklist a browser from be made available. This is not assurance of a browser working but may be used more actively to block bad browser support in the future.

Instance Methods

(static) this.getPrettyReleaseNames() → Object

This returns an object consisting of the supported releases and the matching browser release name.

For example, Chrome is: { stable: 'Stable', beta: 'Beta', unstable: 'Dev' }

Returns Object

Returns an object containing release names as keys and a user friendly release name as the value.

this.addCapability(key, value)

You can define capabilities here that will be given to the WebDriver builder when getSeleniumDriverBuilder() or getSeleniumDriver() is called.

Parameters
key String

The capability key.

value String

The capability value.

this.getDriverModule() → String|null

Some browsers require an executable be available on the current path to work with Selenium. If this is the case, there may be an NPM module that can download and add the executable to the path. This method returns the name of the appropriate NPM module for this browser.

For example, Chrome uses the 'chromedriver' npm module and Firefox uses the 'geckodriver' module.

Returns String | null

The name of the NPM driver module to use with this browser. Null is returned if there is no driver module.

this.getExecutablePath() → String|null

Get the path of the browser executable if known.

Returns String | null

The path of the browsers executable. Null if it's unknown.

this.getId() → String

Get the Selenium ID of the browser (i.e. 'chrome', 'firefox', 'edge' etc.).

Returns String

Selenium ID of this browser.

this.getPrettyName() → String

A user friendly name for the browser. This is largely useful for console logging. LocalBrowsers will also include the appropriate release name.

Returns String

A user friendly name for the browser.

this.getRawVersionString() → String

This is the raw output of a browsers version number (i.e. running the browser executable with --version).

This provides more information than major release number returned by getVersionNumber().

Returns String

Raw string of the browser version.

this.getReleaseName() → String

The release name for this browser. This will be either 'stable', 'beta' or 'unstable'.

Useful if you only want to test, or not test, on a particular release type, i.e. only test of stable releases of browsers.

Returns String

Release name of this browser. 'stable', 'beta' or 'unstable'.

this.getSeleniumDriver() → Promise.<WebDriver>

This method resolves to a raw WebDriver instance.

Returns Promise.<WebDriver>

A WebDriver Instance, see selenium-webdriver.ThenableWebDriver for more info.

this.getSeleniumDriverBuilder() → WebDriverBuilder

This method returns the preconfigured WebDriver Builder.

This is useful if you wish to customise the builder with additional options (i.e. customise the proxy of the driver.)

Returns WebDriverBuilder

A WebDriver Builder instance, see selenium-webdriver.Builder for more info.

this.getSeleniumOptions() → SeleniumOptions

The selenium options passed to WebDriver's Builder.

For Chrome, this will return an instance of selenium-webdriver/chrome, for Firefox it would return an instance of selenium-webdriver/firefox.

Returns SeleniumOptions

An instance of the appropriate selenium-webdriver options for this browser.

this.getVersionNumber() → Integer

The major version of the browser if known.

Returns Integer

Major version number of this browser if it can be found, -1 otherwise.

this.isBlackListed() → Boolean

This method is largely used internally to determine if a browser should be made available or not.

This method will only blacklist a browser if there is a known bad browser

  • driver module combination.
Returns Boolean

Whether this browser is blacklisted or not from being included in available browsers.

this.isValid() → Boolean

This method returns true if the browser executable can be found and the browser version is expected to work with the current installed browser driver, otherwise false is returned.

Returns Boolean

True if a WebDriver can be built and used.

this.setSeleniumOptions(options)

If changes are made to the selenium options, call this method to set them before calling getSeleniumDriver().

Parameters
options SeleniumOptions

An instance of a selenium-webdriver options class.

image/svg+xml Group 3 Group 3 Created with Sketch.