JSPM

webdriver

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1938486
  • Score
    100M100P100Q214753F
  • License MIT

A Node.js bindings implementation for the W3C WebDriver and Mobile JSONWire Protocol

Package Exports

  • webdriver
  • webdriver/build/request
  • webdriver/protocol/appium.json
  • webdriver/protocol/mjsonwp.json
  • webdriver/protocol/webdriver.json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (webdriver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

WebDriver

A lightweight, non-opinionated implementation of the WebDriver specification including mobile commands supported by Appium

There are tons of Selenium and WebDriver binding implementations in the Node.js world. Every one of them have an opinionated API and recommended way to use. This binding is the most non-opinionated you will find as it just represents the WebDriver specification and doesn't come with any extra or higher level abstraction. It is lightweight and comes with support for the WebDriver specification and Appiums Mobile JSONWire Protocol.

Example

The following example demonstrates a simple Google Search scenario:

import WebDriver from 'webdriver'

;(async () => {
    const client = await WebDriver.newSession({
        path: '/',
        capabilities: { browserName: 'firefox' }
    })

    await client.navigateTo('https://www.google.com/ncr')

    const searchInput = await client.findElement('css selector', '#lst-ib')
    await client.elementSendKeys(searchInput['element-6066-11e4-a52e-4f735466cecf'], 'WebDriver')

    const searchBtn = await client.findElement('css selector', 'input[value="Google Search"]')
    await client.elementClick(searchBtn['element-6066-11e4-a52e-4f735466cecf'])

    console.log(await client.getTitle()) // outputs "WebDriver - Google Search"

    await client.deleteSession()
})()

Configuration

To create a WebDriver session call the newSession method on the WebDriver class and pass in your configurations:

import WebDriver from 'webdriver'
const client = await WebDriver.newSession(options)

The following options are available:

capabilities

Defines the capabilities you want to run in your Selenium session.

Type: Object
Required: true

logLevel

Level of logging verbosity.

Type: String
Default: silent
Options: silent | error | warn | info | debug

logOutput

Pipe logs into a file.

Type: String|Writable
Default: null

protocol

Protocol to use when communicating with the Selenium standalone server (or driver).

Type: String
Default: http Options: http | https

host

Host of your WebDriver server.

Type: String
Default: 0.0.0.0

port

Port your WebDriver server is on.

Type: Number
Default: 4444

path

Path to WebDriver server.

Type: String
Default: /wd/hub

baseUrl

Shorten url command calls by setting a base url.

Type: String
Default: null

connectionRetryTimeout

Timeout for any request to the Selenium server.

Type: Number
Default: 90000

connectionRetryCount

Count of request retries to the Selenium server.

Type: Number
Default: 2