Interacting with Chrome DevTools from WebDriverIO
WebdriverIO is build to test various types of applications, from web or mobile applications towards native desktop apps or even VS Code extensions. But what about Chrome DevTools plugins? In this blog post we explore how one could interact with an extension build for Chrome Devtools.
WebdriverIO is build to test various types of applications, from web or mobile applications towards native desktop apps or even VS Code extensions. But what about Chrome DevTools plugins? In this blog post we explore how one could interact with an extension build for Chrome Devtools.
One of WebDriverIO features is the ability to interact with Chrome DevTools, which can be extremely helpful for debugging and testing web applications and browser extensions. In this blog, we'll explore how to use WebDriverIO to interact with the Chrome DevTools, specifically focusing on interacting with the PixiJS extension. You can find a complete example in Github.
Devtools in WebdriverIO
Setting Up Extension
You need to download the extension you want to test in a .crx format,
in our case we have downloaded the PixiJS-Devtools-Chrome-Web-Store.crx extension file.
Setting Up WebDriverIO
First, ensure you have WebDriverIO set up in your project. If not, you can install it by following the official installation guide here
WebDriverIO Configuration for Chrome DevTools
Here is the configuration file (wdio.conf.js) tailored to our example:
import path from "path";
import fs from "fs";
export const config = {
specs: ["./test/specs/**/*.js"],
runner: "local",
maxInstances: 1,
capabilities: [
{
browserName: "chrome",
browserVersion: "stable",
"goog:chromeOptions": {
args: [
"ignore-certificate-errors-spki-list",
"--ignore-certificate-errors",
"window-size=1920,1080",
"--auto-open-devtools-for-tabs",
],
extensions: [
fs.readFileSync(
path.resolve("./PixiJS-Devtools-Chrome-Web-Store.crx"),
"base64"
),
],
},
},
],
logLevel: "debug",
framework: "mocha",
mochaOpts: {
ui: "bdd",
timeout: 1000 * 60 * 5, // 5 min
},
};
In this configuration, we specify the Chrome browser with options to auto-open DevTools for tabs and load the PixiJS DevTools extension. The extensions option reads the extension file in base64 format.
We need also the --auto-open-devtools-for-tabs flag to automatically open the DevTools (Developer Tools) panel.