- WebdriverIO Tutorial
- WebdriverIO - Home
- WebdriverIO - Introduction
- WebdriverIO - Prerequisite
- WebdriverIO - Architecture
- WebdriverIO - Getting Started with NodeJS
- WebdriverIO - Installation of NPM
- WebdriverIO - VS Code Installation
- WebdriverIO - Package.json
- WebdriverIO - Mocha Installation
- Selenium Standalone Server Installation
- WebdriverIO - Configuration File generation
- WebdriverIO - VS Code Intellisense
- WebdriverIO - Wdio.conf.js file
- WebdriverIO - Xpath Locator
- WebdriverIO - CSS Locator
- WebdriverIO - Link Text Locator
- WebdriverIO - ID Locator
- WebdriverIO - Tag Name Locator
- WebdriverIO - Class Name Locator
- WebdriverIO - Name Locator
- Expect Statement for Assertions
- WebdriverIO - Happy Path Flow
- WebdriverIO - General Browser Commands
- WebdriverIO - Handling Browser Size
- WebdriverIO - Browser Navigation Commands
- Handling Checkboxes & Dropdowns
- WebdriverIO - Mouse Operations
- Handling Child Windows/Pop ups
- WebdriverIO - Hidden Elements
- WebdriverIO - Frames
- WebdriverIO - Drag & Drop
- WebdriverIO - Double Click
- WebdriverIO - Cookies
- WebdriverIO - Handling Radio Buttons
- Chai Assertions on webelements
- WebdriverIO - Multiple Windows/Tabs
- WebdriverIO - Scrolling Operations
- WebdriverIO - Alerts
- WebdriverIO - Debugging Code
- WebdriverIO - Capturing Screenshots
- WebdriverIO - JavaScript Executor
- WebdriverIO - Waits
- WebdriverIO - Running Tests in Parallel
- WebdriverIO - Data Driven Testing
- Running Tests from command-line parameters
- Execute Tests with Mocha Options
- Generate HTML reports from Allure
- WebdriverIO Useful Resources
- WebdriverIO - Quick Guide
- WebdriverIO - Useful Resources
- WebdriverIO - Discussion
WebdriverIO - Running Tests in Parallel
We can run WebdriverIO tests in parallel mode. For this we have to create more than one spec file within the test folder. The numbers of threads in which parallel tests can run are defined by the parameters in the Configuration file - wdio.conf.js file.
The details on how to create a Configuration file are discussed in detail in the Chapter - Wdio.conf.js file and Chapter - Configuration File generation to store WebdriverIO settings.
Let us take a project having three spec files within the test folder. The following screen will appear on your computer −
To execute all these files in a parallel mode, we have to first specify './test/specs/**/*.js' under the specs field in the wdio.conf.js file. This means all the spec files within the test folder would get triggered on running the command given below −
npx wdio run wdio.conf.js.
The following screen will appear on your computer −
After the command has been executed successfully, we shall see all the three spec files - testcase1.js, testcase2.js and testcase3.js getting triggered for execution simultaneously.
The following screen will appear on your computer −
Also, the maxInstances field in the wdio.conf.js determines the maximum number of threads possible to trigger the parallel execution. By default, the value is set to 10. Here, we have three spec files, so the maxInstances = 10, holds true.
The following screen will appear on your computer −
There is another field called capabilities within the wdio.conf.js file. Within this, we have a parameter called the maxInstances. It determines the number of instances that can be opened simultaneously by the Chrome browser during the parallel run.
Let us set the value 3 for the parameter maxInstances outside the capabilities field and then set the value 2 for the field maxInstances inside the capabilities field. The value set for maxInstances within the capabilities overrides the value set for maxInstances outside the capabilities.
Run the following command −
npx wdio run wdio.conf.js
After the command has been executed successfully, we shall see two spec files - testcase1.js and testcase2.js getting triggered for execution simultaneously in Chrome. They are initially in RUNNING status.
Once the status of testcase2.js moved to PASSED, the third spec testcase3.js moved to the status of RUNNING. The following screen will appear on your computer −