Using WebDriverIO vs. Selenium WebDriver: How, When, and Why
Given its status as one of the most popular and widely used automation frameworks in the software industry today, teams around the world are using WebDriverIO to speed up the execution of large test suites that help with Quality Assurance in their systems.
This is the first in a series of articles about the powerful automation tool that is WebDriver IO. In this post, we’ll show you definitions, capabilities, functionalities, and when you should use WebdriverIO, as well as compare it against another notable automation tool, Selenium WebDriver.
What is WebDriverIO?
WebDriverIO is an automation test framework rooted in NodeJS. The official website defines WebDriverIO as “a progressive automation framework built to automate modern web and mobile applications. It simplifies the interaction with your app and provides a set of plugins that help you create a scalable, robust, and stable test suite.”
Let’s look at the phrase “progressive automation framework” specifically; progressive automation is a method of automation wherein test modules are tested one after the other. Scripts are essentially written to test new software, along with the development code. The main purpose of progressive automation is faster testing and identification of problems, as well as their respective quick fixes.
WebDriverIO allows you to implement your tests in a flexible and powerful framework that is provided with a bunch of functionalities and plugins, making the test implementation process easier. All of this can be attributed to the huge WebDriverIO community that is continually maintaining and improving it.
How does WebDriverIO work?
Now that we know what WebDriverIO is, it is time to get a better understanding of how it works. WebDriverIO is a framework that follows the web standard protocol WebDriver, as well as Chrome DevTools protocol. This means that you can use the WebDriverIO framework to automate web applications efficiently for both Selenium WebDriver-based cross-browser testing or Chromium-based automation. Indeed, this is an automation framework independent from Selenium WebDriver, allowing testers to automate both web applications— regardless of the communication protocol they want to use—and Native/Hybrid mobile applications.
The WebDriver protocol was designed to automate a browser from the user perspective, encompassing everything a user is able to do with the browser. It provides a set of commands that abstract away common interactions with an application. To use this automation protocol, you need a proxy server that translates all commands and executes them in the target environment (i.e. the browser or the mobile app). For browser automation,
the proxy server is usually the browser driver. There are several drivers available for browsers: Chrome, Firefox, Edge, Internet Explorer, and Safari.
- Official W3C Web standard, supported by all major browsers
- Simplified protocol that covers common user interactions
- Support for mobile automation (and even Native desktop apps)
- Can be used locally, as well as in the cloud, through services like Sauce Labs
- Not designed for in-depth browser analysis (e.g. tracing or intercepting network events)
- Limited set of automation capabilities (e.g. no support to throttle CPU or network)
- Additional effort to set up browser driver with selenium-standalone/ChromeDriver/etc
Chrome DevTools protocol
The DevTools interface is a Native browser interface that is usually used to debug the browser from a remote application (e.g. Chrome DevTools). In addition to its capabilities to inspect the browser in nearly all possible forms, it can also be used to control it. While every browser used to have its own internal DevTools interface that was not really exposed to the user, more and more browsers are now adopting the Chrome DevTools protocol to either debug a web application using Chrome DevTools or control Chrome using tools like Puppeteer.
The communication happens without any proxy, directly to the browser using WebSockets. WebDriverIO allows you to use the DevTools capabilities as an alternative automation technology for WebDriver if you have special requirements to automate the browser.
- Access to more automation capabilities (e.g. network interception, tracing, etc.)
- No need to manage browser drivers
- Only supports Chromium-based browsers (e.g. Chrome, Chromium Edge) and (partially) Firefox
- Does not support execution on cloud vendors such as Sauce Labs, BrowserStack, etc.
Why should I use WebDriverIO?
WebDriverIO is a flexible and powerful automation framework that can be used to automate web applications (WebDriver/Chrome DevTools), mobile (Hybrid/Native) applications using Appium, and even Native desktop applications (Windows and macOS), using a custom configuration of Appium (mobile automation).
NodeJS has a vast community around the world that has helped the framework grow with new, powerful, and useful features and plugins to make suite tests much more robust, complete, and stable. Compared to many automation tools, WebDriverIO is a truly open-source project that is run with open governance and owned by a non-profit entity called OpenJS Foundation. This legally binds the project to grow and be directed in the interest of all participants. The framework is independent in the way it is being developed and where it is supposed to go. It allows the WebDriverIO community to provide free support in its channels, as they have a sustainable community that supports users continuously. In an upcoming article in this series, we will discuss the plugins and extensions that make WebDriverIO so unique.
WebDriverIO vs Selenium WebDriver
In this section, we are going to compare these two powerful automation tools. We will mention the advantages and disadvantages of each with respect to the other, and which features may be better in one than in the other.
It should be noted that one common and important thing that these two frameworks have in common is that both WebDriverIO and Selenium WebDriver are open-source, can be used for browser testing, are rich in documentation, and have a huge community that is maintaining the project actively. Knowing this, let’s start with their respective advantages:
Advantages of Selenium WebDriver
- The most-used automation tool in the world. By Dec. 2021, Selenium WebDriver on GitHub received 224k stars, 6,7K forks, and was used by 124k users.
- Time-proven. It’s been around for more than a decade and has proved its reliability. Selenium’s history starts in the 2000s.
- Wide range of supported browsers: Chrome, Firefox, Edge, Internet Explorer, Safari, and Opera.
- Its API allows the creation of robust tests and is pretty well documented.
Advantages of WebdriverIO
- WebDriverIO can be run on the WebDriver protocol for true cross-browser testing, as well as on Chrome DevTools protocol for Chromium-based automation using Puppeteer. WebDriverIO can do the same things that Selenium can, but also comes with lots of integrations with popular test automation tools and plugins.
- It is built for testing modern web applications written in React, Vue, Angular, Svelte, or other front-end frameworks built in NodeJS.
- It is possible to automate Native desktop applications (e.g. written with Electron.js)
- DevTools protocol, supported by WebDriverIO, is much faster than WebDriver protocol, although it does not support many browsers at the moment (2021).
- WebDriverIO has a command-line interface (CLI) and a very flexible configuration.
- Easy project setup, flexible configuration in only one configuration file (wdio.conf), and integration with other test automation tools out of a box.
- It is pretty easy to implement and maintain the automated test cases since WebDriverIO’s API is somewhat similar to Selenium WebDriver, with the difference that its syntax in various commands is simpler and easier to read and implement.
- Test reports can be easily integrated with WebDriverIO thanks to the existing tools in the market using its test runner, wherein there are a lot of good open-source options.
Now that we know the main advantages of WebDriverIO and Selenium WebDriver, it is time to analyze each a bit further in order to determine which one is “better” (or at least, which one is the most “feasible” when getting started with the test automation development on a new project). Asking “which framework is better than the other one” is a very complex thing. In order to be objective, we will use a direct comparison approach using the information from the previous section.
|Allows you to automate web, mobile, and desktop applications.||Mainly used for automating browsers.|
|According to GitHub (Dec. 2021), WebDriverIO has received 7,2K stars, 2K forks, and is used by 37,1K users.||According to GitHub (Dec. 2021), the Selenium repo has received 22,4k stars, 6,7K forks, and is used by 124K users.|
|More actively maintained, with 184 releases since 2013 (first release).||Less actively maintained, with 73 releases since 2006 (first release).|
|Uses WebDriver protocol and Chrome DevTools protocol for Chromium.||Only uses WebDriver protocol to interact with browsers.|
|Has a command-line interface (CLI) and a very flexible configuration thanks to its test runner, which generates a config file (wdio.conf). Allows us to control web and mobile apps through just a few lines of code and you choose how to interact with browsers – using one protocol or another.||Only used to manipulate actions in a browser. Configuration requires more work.|
|Can be used to run parallel execution and to run executions in synchronous mode.||Can be used to run parallel execution and to run executions in synchronous mode.|
|Supports Chrome, Firefox, Edge, Internet Explorer, and Safari. Opera is outside of its scope.||Supports Chrome, Firefox, Edge, Internet Explorer, Safari, and Opera.|
|Has a pretty simple syntaxis in its API’s commands, making them easier to read than Selenium. This helps programmers write their test cases in a simpler and faster way.||Allows you to create test cases in a much more robust way and has much richer documentation and community.|
|Manages the browser instances on its own.||Requires that browser instances be managed by code.|
WebDriverIO is a powerful automation tool rich in documentation, functionalities, and plugins. Using WebDiverIO allows us to automate our test suites in a fast and reliable way. This framework has two integrated communication protocols that facilitate the choice of one or the other, depending on your technical needs and preferences.
WebDriverIO and Selenium WebDriver are both good options to automate our E2E tests in web applications; both are open source and boast a huge dev community that is continuously maintaining and improving each of them. However, based on the above analysis and articles referenced, one might say that WebDriverIO is the best option to automate web, mobile, and even desktop applications; its open-source repository is more actively maintained and forked by many more developers.