In this article, we will understand how to setup a Webdriver IO Test Automation Project in our System.

Before going into setup let us understand,

What is Webdriver IO?

WebdriverIO is an Automation framework which is built to automate web and mobile applications.

It is robust and scalable.

Advantages of using webdriver IO

  1. We can automate modern web applications written in frameworks like vue, react, angular, etc.
  2. We can also automate native/hybrid mobile applications.
  3. It has lot of integrations and plugins which is easy to use.

Steps for Set up

Pre-requisite

1. Create a folder.

2. Open the folder in the visual studio code IDE.

3. Open the terminal.

4. Create a package.json file using the command npm init -y

5. We need to install webdriver IO. So run the command

npm i @wdio/cli

6. Webdriver IO will get installed. Next we need to generate the config file. This file is important in this framework. We call this as a runner file. To generate this file run the below command in terminal and hit enter

npx wdio config

Now in the terminal, the configuration helper will ask a few questions on how you want to set up your config file. we need to provide the appropriate options for it. At the end, it will gather all the config options given by you and install it inside your project.

All the configurations will get installed automatically by webdriver io cli.

Screenshot

Now the Webdriver IO configuration file will be created. Test folder with sample tests and page objects folder with all the object repositories will be created.

Folder structure

We can also generate the Webdriver IO configuration file with default options by running the command

npx wdio config -y

There is no need to answer the questions which was asked while running the command npx wdio config. If you want to customize your configurations then go for this command.

How to run the webdriver IO Test

npx wdio run ./wdio.conf.js

We can run the webdriver IO Test using the command. It will run all the tests that are written in the tests folder. by default the configuration will be set in the wdio.conf.js file. We can mention the test/spec file specifically to be run in the spec object in the config file

specs: [
        './test/specs/**/*.js'
    ],

To run a specific spec file then run the below command

npx wdio run ./wdio.conf.js --spec specfilname.js

Hope this article helps you in setting up webdriver IO in your system.

Thanks Happy learning...