Thursday, September 24Be an Automation Engineer

A basic example program using webdriverio with wdio test runner

Note: This example program is with wdio test runner configured.

1. How to Install?

WebdriverIO is a ‘npm’ package and runs on ‘Node.js‘. So, we need to install ‘Node.js’ and ‘npm’ in our machine before installing WebdriverIO.

Step by step process of installing ‘Node.js’ and ‘npm’ in our Windows / Mac machines.

2. Configure project using wdio configurator:

After installing Node.js, we need to configure project with wdio configurator.
Step by step process to configure webdriverio using wdio.

3. How to write Spec?

Now, create your test spec WdioTestSpec.js in ./test/specs folder.

describe(' page', function() {
    it('should have the right title - the fancy generator way', function () {
        var title = browser.getTitle();//Gets the title of webdriverio home page
        expect(title).toEqual('WebdriverIO - Selenium 2.0 javascript bindings for nodejs');//Asserting title
4. Folder structure would be:


5. How to Run?

Open wdio.conf.js and set your required browser.

  capabilities: [{
        maxInstances: 5,
        browserName: 'chrome'

By default the browser name would be ‘firefox’. But, we have changed the browserName to ‘chrome’.
Execute the below command to run spec.

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

You should see Chrome browser opens up and launching and browser closed.
The console output would be 1 passing (38.60s).
38.06 is the execution time of the test in seconds
You have successfully run for your first test using webdriverio

%d bloggers like this: