WebdriverIO

WebdriverI/O

Selenium 2.0 bindings for NodeJS

Build Status Coverage Status

One Tool To Rule Them All:

Grunt Integration Gulp Integration Sublime Text Plugin Visual Regression Testing with Applitools Eyes WebRTC Analytics Plugin

What is WebdriverIO?

WebdriverIO lets you control a browser or a mobile application with just a few lines of code. Your test code will look simple, concise and easy to read. The integrated test runner let you write asynchronous commands in a synchronous way so that you don’t need to care about how to handle a Promise to avoid racing conditions. Additionally it takes away all the cumbersome setup work and manages the Selenium session for you.

Working with elements on a page has never been easier due to its synchronous nature. When fetching or looping over elements you can use just native JavaScript functions. With the $ and $$ functions WebdriverIO provides useful shortcuts which can also be chained in order to move deeper in the DOM tree without using complex xPath selectors.

The test runner also comes with a variety of hooks that allow you to interfere into the test process in order to e.g. take screenshots if an error occurs or modify the test procedure according to a previous test result. This is used by WebdriverIOs services to integrate your tests with 3rd party tools like Appium.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var expect = require('chai').expect;
describe('webdriver.io api page', function() {
it('should be able to filter for commands', function () {
browser.url('http://webdriver.io/api.html');
// filtering property commands
$('.searchbar input').setValue('getT');
// get all results that are displayed
var results = $$('.commands.property a').filter(function (link) {
return link.isVisible();
});
// assert number of results
expect(results.length).to.be.equal(3);
// check out second result
results[1].click();
expect($('.doc h1').getText()).to.be.equal('GETTEXT');
});
});

Get Started

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var webdriverio = require('webdriverio');
var options = { desiredCapabilities: { browserName: 'chrome' } };
var client = webdriverio.remote(options);
client
.init()
.url('https://duckduckgo.com/')
.setValue('#search_form_input_homepage', 'WebdriverIO')
.click('#search_button_homepage')
.getTitle().then(function(title) {
console.log('Title is: ' + title);
// outputs:
// "Title is: WebdriverIO (Software) at DuckDuckGo"
})
.end();

WebdriverIO as standalone package

WebdriverIO was designed to be as flexible and framework agnostic as possible. It can be applied in any context and serves not only the purpose of testing.

You can use it as scrapper tool to dynamically fetch website data in an automated way or integrate it in your own automation library. Popular examples of that are Spectron, Chimp or CodeceptJS.

Easy Test Setup

The wdio command line interface comes with a nice configuration utility that helps you to create your config file in less than a minute. It also gives and overview of all available 3rd party packages like framework adaptions, reporter and services and installs them for you.

WDIO configuration utility

How does it work?

WebdriverIO is an open source testing utility for nodejs. It makes it possible to write super easy selenium tests with Javascript in your favorite BDD or TDD test framework.

It basically sends requests to a Selenium server via the WebDriver Protocol and handles its response. These requests are wrapped in useful commands and can be used to test several aspects of your site in an automated way.

Run your tests in the cloud

Services like Sauce Labs or BrowserStack provide selenium testing on remote hosts. Be able to run tests on a wide collection of platforms, devices and browser combinations without any configuration in your environment.

WebdriverIO supports services including:

Sauce Labs BrowserStack TestingBot