What is Webdriverio: A Complete Tutorial for Beginners

what is webdriverio, webdriverio tutorial, webdriverio vs cypress vs playwright,

WebdriverIO stands as a robust automation testing framework, offering a simplified approach to test web applications. 

With its user-friendly interface and support for multiple programming languages, WebdriverIO proves to be an excellent choice, particularly for beginners in the realm of test automation. 

In this comprehensive tutorial, we will delve into the core elements of WebdriverIO, guiding you through the seamless process of installation, setup, and utilization.

Let’s embark on a journey to uncover the power and potential of WebdriverIO as we demystify its inner workings and equip you with the knowledge and skills necessary to employ it effectively in your testing endeavors.

What is WebdriverIO?

WebdriverIO stands out as a leading open-source automation testing framework built on the robust foundation of Node.js. 

With its intuitive syntax, WebdriverIO empowers testers to effortlessly automate browser actions and interact with web elements. 

By adopting WebdriverIO, you can write tests in a concise and highly readable manner, ensuring efficient and effective testing of web applications across a wide range of browsers and platforms.

Why use WebdriverIO for Automation Testing?

WebdriverIO is a powerful tool for automation testing with a rich feature set, making it an ideal choice for efficient and effective web application testing.

Cross-Browser Compatibility

WebdriverIO allows you to write tests that can be executed across multiple browsers. It provides seamless integration with various browser drivers, enabling you to run your tests on different browsers and ensure consistent behavior across platforms.

Multi-Language Support

With WebdriverIO, you can write your test scripts in multiple programming languages, including JavaScript, TypeScript, and more. This flexibility allows you to leverage your existing coding skills and preferences.

Rich API and Commands

WebdriverIO provides a comprehensive set of APIs and commands that make it easy to interact with web elements, simulate user actions, and validate application behavior. Its intuitive syntax and expressive APIs enhance the readability and maintainability of your test scripts.

Extensive Documentation and Community Support

WebdriverIO has a vast and active community that offers extensive documentation, tutorials, and support. This rich knowledge base provides resources and guidance to help you get started quickly, troubleshoot issues, and stay up-to-date with the latest trends and best practices in test automation.

Integration with Testing Frameworks

WebdriverIO seamlessly integrates with popular testing frameworks like Mocha and Jasmine. This integration allows you to leverage the features and capabilities of these frameworks, such as test organization, reporting, and parallel test execution.

Support for Continuous Integration (CI)

WebdriverIO can be easily integrated into CI/CD pipelines. It supports various CI tools like Jenkins, Travis CI, and CircleCI, enabling you to automate your testing process and ensure consistent and reliable test execution.

Community Plugins and Integrations

The WebdriverIO community has developed a wide range of plugins and integrations, expanding the capabilities of the framework. These plugins provide additional functionalities, such as generating test reports, capturing screenshots, and integrating with popular tools like Selenium Grid and BrowserStack.

Level up your testing game with our comprehensive webdriver.io course. Join now to master WebDriver.io hands-on and enhance your automation skills!

WebdriverIO Architecture: How does it work?

WebdriverIO follows a client-server architecture, where the client acts as a test runner and the server represents the browser or browser driver instance. The architecture consists of several components working together to facilitate the automation of web applications.

Test Runner:

The Test Runner is responsible for executing the test scripts written in WebdriverIO. It provides an interface to configure and manage the test execution process. WebdriverIO supports various test runners like Mocha and Jasmine, enabling you to structure and organize your tests effectively.

WebdriverIO Client:

The WebdriverIO Client is a JavaScript library that acts as a bridge between the test scripts and the browser or browser driver instance. It provides a rich set of APIs and commands to interact with web elements, perform actions, and make assertions. The client handles the communication and translates the test commands into WebDriver protocol actions.

WebDriver Protocol:

WebdriverIO utilizes the WebDriver protocol, a standardized protocol for browser automation. The WebDriver protocol defines a set of commands and responses that enable the test scripts to interact with the browser. 

It allows you to perform actions like clicking elements, entering text, navigating through pages, and validating element properties.

Browser or Browser Driver:

The browser or browser driver represents the actual browser instance where the tests are executed. WebdriverIO supports multiple browsers like Chrome, Firefox, Safari, and more. It uses the browser driver, such as ChromeDriver or GeckoDriver, to establish a connection with the browser and control its behavior. 

The browser driver acts as a mediator between the test scripts and the browser, translating the WebDriver protocol commands into browser-specific actions.

How to Use WebdriverIO in Testing

To harness the full potential of WebdriverIO for testing, it’s essential to familiarize yourself with its core concepts and APIs. WebdriverIO offers a comprehensive collection of commands that empower you to interact with elements, perform actions, and validate expected outcomes. These commands act as building blocks for simulating user interactions, verifying application behavior, and ensuring the correctness of your tests.

With WebdriverIO, you have the flexibility to choose from popular testing frameworks such as Mocha or Jasmine. These frameworks seamlessly integrate with WebdriverIO, providing a structured and organized approach to test development and execution. You can leverage their powerful features, such as test suites, test runners, and assertion libraries, to enhance the readability and maintainability of your test code.

When using WebdriverIO, you can employ various commands to navigate through web pages, locate elements, interact with form fields, click buttons, and perform other essential actions. Additionally, WebdriverIO offers a wide range of assertions to validate the expected behavior of your web application. These assertions enable you to check for specific text, verify the visibility of elements, compare attributes, and perform other validations crucial for robust testing.

By utilizing WebdriverIO’s powerful command set, you can build expressive and reliable tests. The intuitive syntax and fluent APIs provided by WebdriverIO make it easier to write test code that is concise, readable, and maintainable. This promotes efficient collaboration among team members and facilitates the quick identification and resolution of issues during the testing process.

Setting Up WebdriverIO

Before delving into the process of writing WebdriverIO tests, it’s important to ensure that you have set up WebdriverIO correctly. This involves meeting the following prerequisites:

Install Node.js:

Before proceeding, verify that Node.js is installed on your computer. To confirm its installation, open the command-line interface (CLI) and execute the following commands:

node -v
npm -v

If Node.js is appropriately installed, these commands will display the respective versions of Node.js and npm.

Install WebdriverIO:

Afterward, you need to install WebdriverIO. Execute the provided commands in your command prompt to install WebdriverIO:

npm install webdriverio

This command will use npm (Node Package Manager) to fetch and install the latest stable version of WebdriverIO.

Install Selenium Server Utility:

WebdriverIO relies on Selenium Server for browser automation. To install Selenium Server Utility globally, use the following command:

npm install -g selenium-standalone

This command will install the Selenium Standalone Server, which is required for running browser tests with WebdriverIO.

Update Selenium Standalone Server and Browser Drivers:

To ensure you have the latest versions of the Selenium Standalone Server and browser drivers, run the following command:

selenium-standalone install

This command will update the Selenium Standalone Server and download the necessary browser drivers (such as ChromeDriver or GeckoDriver).

Start Selenium Standalone Server and Browser:

Before executing your test scripts, you need to start the Selenium Standalone Server and launch the desired browser. Use the following command:

selenium-standalone start

This command will initiate the Selenium Standalone Server and start the browser specified in your test scripts. Make sure to keep the Selenium Standalone Server running in the background while executing your tests.

Configuring WebdriverIO for the first test

To set up WebdriverIO for your first test, follow these steps:

Create the project workspace:

Open your command-line interface (CLI) and enter the following commands to create a project workspace directory and navigate into it:

mkdir WebdriverioTestProject
cd WebdriverioTestProject

Initialize package.json:

To initialize a package.json file for your project, run the following command:

npm init -y

This command will generate a package.json file with the default configuration.

Install WebdriverIO CLI:

Install the WebdriverIO Command Line Interface (CLI) globally by running the following command:

npm install -g @wdio/cli

The WebdriverIO CLI will install, which will give useful tools for organizing and executing your WebdriverIO tests.

Create a WebdriverIO config file:

Generate a WebdriverIO config file using the following command:

npx wdio config

This command will initiate a configuration setup process where you can choose various options based on your requirements. You can configure the test environment, specify the framework, set the location of test specs, choose a reporter, and define the test execution mode (synchronous or asynchronous).

Create the test specs folder:

Create a folder to store your test specs by executing the following command:

mkdir -p ./test/specs

This command will create a directory structure with a specs folder inside the test folder to hold your test files.

Create the test script file:

Create a test script file where you will write your automation test script by running the following command:

touch ./test/specs/webdriverioTestScript.js

This command will create a webdriverioTestScript.js file inside the specs folder, ready for you to write your test code.

Test Automation Using Selenium and WebdriverIO

WebdriverIO is built on top of Selenium, a widely used automation framework for web applications. By integrating with Selenium, WebdriverIO offers a robust solution for web test automation. You can leverage Selenium’s WebDriver protocol to execute tests across different browsers and platforms, ensuring comprehensive coverage and compatibility.

WebdriverIO Framework

WebdriverIO provides a flexible and modular framework that allows you to structure your tests effectively. It supports various features such as page objects, custom commands, and hooks, empowering you to build scalable and maintainable test suites. With the WebdriverIO framework, you can organize your tests logically, improve code reusability, and enhance the overall test development process.

There are various types of WebdriverIO frameworks that can be used for test automation. Some popular ones include:

  • Mocha: A flexible testing framework that provides features like test organization, assertion library, and test reporting.
  • Jasmine: A behavior-driven development framework that offers a clean syntax and rich set of built-in functionalities for test structuring and execution.
  • Cucumber: A tool that supports behavior-driven development (BDD) and allows you to write test scenarios in a natural language format.
  • Jest: A JavaScript testing framework that focuses on simplicity and provides features like test runners, assertions, and mock functions.

These frameworks help in organizing and structuring the test code, enhanscing test readability, and providing additional functionalities for test automation with WebdriverIO.

Webdriver Library

WebdriverIO utilizes the WebDriver protocol to establish communication between the test scripts and the web browser. This library acts as a bridge, enabling seamless interaction and control over the browser’s functionalities. WebdriverIO simplifies the usage of this library by providing an intuitive API, allowing you to perform actions like clicking buttons, entering text, or validating elements with ease.

WebdriverIO vs. Selenium

Both WebdriverIO and Selenium are popular choices for web test automation. While Selenium is a standalone automation framework, WebdriverIO is built on top of it, providing a more user-friendly and developer-centric approach. WebdriverIO simplifies the test development process by offering a more intuitive API, better documentation, and easier integration with modern tools and frameworks.

WebdriverIO vs. Cypress

Cypress is another popular test automation framework known for its simplicity and speed. While both WebdriverIO and Cypress serve the purpose of automating web applications, they have different approaches. WebdriverIO offers cross-browser compatibility, broader browser support, and seamless integration with other testing frameworks, making it a preferred choice for complex test scenarios and larger projects.

WebdriverIO vs. Playwright

Playwright is a relatively new test automation framework that provides powerful capabilities for web, mobile, and desktop application testing. Playwright offers excellent browser automation support and provides cross-browser compatibility. However, WebdriverIO has a broader user base, extensive community support, and seamless integration with popular testing frameworks, making it a more mature and widely adopted solution.

Comparison Table of WebdriverIO, Selenium, Cypress, and Playwright:

Here is a quick comparison table summarizing the key features and differences between WebdriverIO, Selenium, Cypress, and Playwright:

FrameworkLanguage SupportBrowser CompatibilityIntegrationCommunity Support
WebdriverIO communityMultiple languagesWide rangePopular frameworksLarge and active
Selenium communityMultiple languagesWide rangePopular frameworksLarge and active
CypressJavaScriptLimitedBuilt-in supportGrowing community
Playwright communityMultiple languagesWide rangeBuilt-in supportRapidly growing

WebdriverIO with Appium

WebdriverIO can also be integrated with Appium, an open-source tool for mobile app automation. By combining WebdriverIO’s cross-browser capabilities with Appium’s mobile automation features, you can extend your test coverage to mobile applications and ensure a consistent testing approach across multiple platforms.

Best Way to Learn WebdriverIO for Test Automation

To learn WebdriverIO effectively, it’s recommended to start with the official documentation and tutorials provided by the WebdriverIO community. Additionally, practicing with real-world scenarios and building small test projects will help you gain hands-on experience and reinforce your understanding of the framework. Joining online communities, participating in forums, and exploring open-source projects can also provide valuable insights and guidance.

JavaScript in the Context of WebdriverIO

WebdriverIO is primarily written in JavaScript and relies on Node.js for its execution. Therefore, having a good understanding of JavaScript fundamentals is beneficial when working with WebdriverIO. JavaScript knowledge will enable you to leverage the full potential of the framework, customize test scripts, and implement complex automation scenarios efficiently.

Selenium WebDriver Methods

Selenium WebDriver provides a rich set of methods and functionalities to automate browser actions and interact with web elements. Here are some commonly used methods:

get(String url): Navigates the browser to the specified URL.


findElement(By locator): Finds the first web element that matches the given locator strategy (e.g., by ID, name, class name, CSS selector, etc.).

WebElement element = driver.findElement(By.id("elementId"));

findElements(By locator): Finds all web elements that match the given locator strategy.

List<WebElement> elements = driver.findElements(By.className("elementClass"));

sendKeys(CharSequence… keysToSend): Simulates keyboard input by sending a sequence of characters to the focused element or the specified element.

element.sendKeys("Hello World");

click(): Clicks on the specified element.


getText(): Retrieves the visible text of the specified element.

String text = element.getText();

getAttribute(String attributeName): Retrieves the value of the specified attribute of the element.

String value = element.getAttribute("href");

isDisplayed(): Checks if the element is displayed on the web page.

boolean isDisplayed = element.isDisplayed();

isEnabled(): Checks if the element is enabled and can be interacted with.

boolean isEnabled = element.isEnabled();

isSelected(): Checks if the element is selected (e.g., for checkboxes or radio buttons).

boolean isSelected = element.isSelected();

submit(): Submits a form associated with the specified element.


clear(): Clears the text or value of an input element.


Selenium WebDriver Example

Here’s a simple example using Selenium WebDriver in Java to print the title of a web page:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class HelloWorldExample {

    public static void main(String[] args) {
        // Specify the location of GeckoDriver for Firefox browser automation
        System.setProperty("webdriver.gecko.driver", "geckodriver");

        // Create the new instance of FirefoxDriver
        WebDriver driver = new FirefoxDriver();

        // Print "Hello, World!" to the console
        System.out.println("Hello, World!");

        // Close the browser


Hello, World!

Take Away!

In conclusion, WebdriverIO is a powerful automation testing framework that provides a simplified approach for testing web applications. With its user-friendly interface, cross-browser compatibility, multi-language support, rich API, and extensive community resources, WebdriverIO proves to be an excellent choice, especially for beginners in test automation. 

By leveraging WebdriverIO’s capabilities, testers can efficiently automate browser actions, validate application behavior, and ensure the reliability of their tests. 

Whether you’re new to test automation or an experienced professional, WebdriverIO offers a comprehensive solution for effective and scalable web testing.


Written by

The Test Tribe

Leave a Reply

Your email address will not be published.

Related Posts

Testing Courses at Thrive EdSchool

Advertisement (Know More)

Get Top Community News

    Top Event and other The Test Tribe updates to your Inbox.