How to Get Started using WebdriverIO with Experitest
Last Updated Jul 08, 2020 — Continuous Testing Expert
Webdriver is popular because it is backed by Selenium which means you can run test scripts on all browsers. While it brings all the advantages of Selenium, it eliminates the pain of writing Java-based scripts. It allows you to easily integrate it with multiple testing frameworks such as Appium to bring the best out of both worlds. Learn more about transitioning from Selenium to Appium, and how to enable your web testers with Digital.ai Continuous Testing.
WebdriverIO tutorial commands are simple and concise. The syntax is pretty clear. The wdio setup wizard walks you through the process of setting up your project. Using the Testrunner you can synchronously write asynchronous commands. Moreover, you can add hooks to perform a specific action during the test process. For instance, you can take a screenshot of an error message. The availability of a big community helps you to quickly resolve issues when you run into errors.
Here is a step-by-step tutorial on how to install and run test scripts using WebriverIO.
Step 1: Install Node.JS
To use this WebDriverIO tutorial, you should have Node.js and Node Package Manager (npm) installed on your machine. When you install Node.js, npm automatically gets installed.
Visit Node JS website and download the latest LTS version. The current LTS version is 12.18.0 and the npm version is 6.14.4
To install WebDriverIO CLI, type the following command in the command prompt
npm install @wdio/cli
When the installation completes, it will display the details of the package added.
Step 5: Create a WebDriverIO Config File
To execute test scripts using WebDriverIO, create a config file that contains the details of the tests, capabilities, and settings. To do so, enter the following command in the command prompt:
npx wdio config
The wdio config wizard opens up. Provide the required details such as the automation backend, framework, reporting tool, etc.
Where is your automation backend located? On my local machine ( When you want to run the tests in the cloud, you can specify the remote location here.)
Which framework do you want to use? Mocha
Synchronous or asynchronous? Sync
Where are test specs located? Choose the default
Which reporting tool to use? No
Want to add a test service to setup? Chromedriver
What is the base URL? https://experitest.com
It will display a message that the package is successfully installed and the configuration file is created successfully.
Step 6: Create specs
Step 7: Execute your tests
To execute the test script, type the following command:
npx wdio wdio.conf.js
The test script successfully launched the chrome browser, checked the title, and closed the browser.