Over a million developers have joined DZone.

Accelerating Multi-Browser Testing

DZone's Guide to

Accelerating Multi-Browser Testing

Webdriver.io is a relatively new cool kid on the webdriver-based testing frameworks block with enough to differentiate itself and help us focus on creating reliable GUI tests.

· Agile Zone
Free Resource

Reduce testing time & get feedback faster through automation. Read the Benefits of Parallel Testing, brought to you in partnership with Sauce Labs.

There are a lot of webdriver-based testing frameworks out there. Webdriver.io is a relatively new cool kid on the block. It has enough to differentiate itself and helps us to focus on creating reliable GUI tests. A few highlights on what this framework comes with:

  1. Out-of-the-box ES 2015 support – leverage all the goodness that ES6/ES2015 offers.
  2. Out-of-the-box promises support – This framework uses Q.js internally, and every single command represents a promise. The second command will be executed only after the first command promise is resolved.
  3. Out-of-the-box Sauce Labs runner service – to run tests on Sauce Labs
  4. Out-of-the-box parallel test runner (wdio) – to run tests across multiple OS/Browser mixes in parallel
  5. A rich set of APIs makes the test code short and concise

These advantages help organizations focus on their core responsibility — to automate their verification process quickly instead of developing and maintaining custom libraries to support automation efforts (more productivity — we all love it).

Design Pattern

Regardless of the tool of choice, I recommend following the Page Object pattern for reliable tests. ES 2015 support makes it easy to achieve that design. Tests will run on multiple platforms based on the configuration:


Step 1: Define the UI Map

  • The UI map is used to hide HTML implementations from consuming Page Objects for easier maintenance.
  • Since webdriver.io supports ES 2015, we are using the class and getter method to access the elements.


Step 2: Define Page Object APIs

Page Object allows APIs to perform actions on the page, and provides access to the current state of the underlying page. In the implementation below, we import the UI map and expose the actions (APIs) for the test.


Step 3: Define Tests

In this example, we use Mocha (TDD style) for defining the tests, and Chai for assertions. Import the Page Object (using a little dependency injection here) and calling those APIs to Navigate to Google and Search for an item.


Step 4: Sauce Labs Integration

Create a config file and provide your Sauce Labs credentials:


You can use the Sauce Labs Platform Configurator to create the necessary configuration. The final configuration would look like:


Step 5: Run Your Tests

Run this command from your tests directory:

node_modules/webdriverio/bin/wdio ./wdio.conf.sauce.js

The tests run in parallel, with results being updated automatically.

Image title


This source code is available in my GitHub account for reference.

The Agile Zone is brought to you in partnership with Sauce Labs. Discover how to optimize your DevOps workflows with our cloud-based automated testing infrastructure.

page object pattern ,labs ,frameworks ,dependency ,testing ,tests ,tdd ,gui ,injection

Published at DZone with permission of Sahas Subramanian, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}