Introduction

This a very minimal future proof JavaScript bindings that conform to the W3C WebDriver standard, which specifies a remote control protocol for web browsers.

Features

Getting started

1. Install the package

 
npm install w3c-webdriver

2. Install a browser driver for WebDriver protocol

For example in case of Google Chrome or its headless version you can do.

 
npm install chromedriver

Also you can manage the drivers using webdriver-manager

3. Start the driver as described in the docs

4. Control the browser through WebDriver protocol

 
const { newSession } = require('w3c-webdriver');

let session;

(async () => {
  try {
    session = await newSession({
      url: 'http://localhost:4444',
      capabilities: {
        alwaysMatch: {
          browserName: 'chrome'
        }
      }
    });
    await session.navigateTo('http://localhost:8080');
    const input = await session.findElement('css selector', '[name="first-name"]');
    await input.sendKeys('Hello World');
  } catch (err) {
    console.log(err.stack);
  } finally {
    session.deleteSession();
  }
})();

Contributors

We are using

We are using BrowserStack for testing the Selenium support of current package. BrowserStack loves open source and has sponsored thousands of projects. They offered us a free account as we're an open source project. This makes testing very easy on different browsers and various platforms including real mobile devices.

W3C WebDriver
v1.0.0