WebdriverIO - Wdio.conf.js file



WebdriverIO tests are controlled from the Configuration file. It is often considered the heart of WebdriverIO. It contains details on which spec files to be executed, browser on which the tests should run, global information - base URL, timeout, reports, screenshots and so on.

In WebdriverIO we do not execute a single test. We are required to trigger the Configuration file with the help of the Test Runner. Test Runner scans the information provided in the Configuration file and then triggers the tests accordingly.

To create a Configuration file, we have to run the below command −

npx wdio config -y

After this command has been executed successfully, the Configuration file called the wdio.conf.js gets created within our project.

The following screen will appear on your computer −

Wdio.conf

Within this file, we have to specify the path of the spec file that we want to execute within the specs parameter.

By default, the path provided is: ./test/specs/**/*.js. This means any .js file under the sub-folder specs (which is under the folder test) should be picked for execution.

The following screen will appear on your computer −

Path

To execute the test with the help of the wdio.conf.js file, we have to run the command −

npx wdio run wdio.conf.js

The following screen will appear on your computer −

Run Command

After the command has been executed successfully, the page title of the application launched is obtained in the console.

However, a lot of the logs got captured in the console. This is because the parameter logLevel is set to info by default in the wdio.conf.js file.

The following screen will appear on your computer −

LogLevel

In order to get rid of some of the logs and to obtain only those which the test case directs, we can set this parameter to silent.

The following screen will appear on your computer −

Get Rid

Again run the Configuration file with the following command −

npx wdio run wdio.conf.js

The following screen will appear on your computer −

Again Run

After the command has been executed successfully, we find lesser logs and the page title of the application launched - About Careers at Tutorials Point - Tutorialspoint is obtained in the console.

Advertisements