/ Webdriverio

Common Selenium and Webdriverio Error Messages

Via my WebdriverIO course and YouTube videos, I get asked a lot of questions about "why isn't this working?".

Many revolve around issues that different people face over and over again, so I wanted to note them here for folks searching.

Here's are the messages:

Let's get to it.


This is by far the most common error I get asked about, and thankfully the easiest to fix.

This error is thrown when WebdriverIO tries to send an HTTP request to the default Selenium server location. The request to that location (, will throw an error if Selenium isn't running.

Quick Fix: Start your local Selenium server or use something like the wdio-selenium-standalone-service.

You can manually verify you have your local Selenium Server running by going to and validating that the page loads.

If you get a 'site cannot be reached' error, then something is wrong on the Selenium side. If you are able to reach the site, then something is wrong on the WebdriverIO side.

sh: wdio: command not found

This is another common and easy to fix error.

When using the WebdriverIO test runner, you start your tests by calling wdio (or sometimes ./node_modules/.bin/wdio). If you haven't installed WebdriverIO (or have since removed it), this error will be thrown.

Quick Fix: Run npm install webdriverio to install/reinstall the test tool.

You can always check if you have WebdriverIO installed by running ls ./node_modules/.bin/wdio.

If it's not installed, you'll get this response ls: ./node_modules/.bin/wdio: No such file or directory

If it is installed, you'll see the same path as a response.

You can also check your dependencies section of your package.json file for a line that reads "webdriverio": "^4.12.0". The 4.12 will probably be different, as new versions are released all the time.

pattern ./test/specs/\*\*/\*.js did not match any file

Here's an error that can have several root causes.

To understand what is causing your specific issue, you need to understand what's going on behind the scenese.

This error is thrown when the wdio command is run. wdio looks at your wdio.conf.js file, grabs the specs value, and searches your directory for those files.

When it can't find them, it throws this error.

But you've looked and the files are right there! What's going on!?!

One issue could be that you're not running the wdio command from the right directory. Check that you're running it from the main folder of your project, not from inside your node_modules/.bin folder.

You should be able to run ls ./test/specs (or whatever the folder is that your store your test files in) from the same folder that you run your wdio command from and get a list of all your test files.

It might also be that case that your slashes are backwards. In Windows, paths are marked with a backslash \ instead of a forward slash /. This means your path would need to be .\test\specs\**\*.js.

TypeError: Cannot read property 'trim' of undefined

You may also see this error:

(node:2155) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): channel closed
(node:2155) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This error is less common, as it requires a more in-depth usage of CucumberJS to run in to (and usage of the Allure reporter).

That said, I want to cover it though because it's really tricky to understand.

Here's the full error message output:

                        throw _iteratorError;

TypeError: Cannot read property 'trim' of undefined
    at getTestStatus (/node_modules/wdio-allure-reporter/build/reporter.js:68:41)

Despite Allure throwing the error, it has nothing to do with the reporter.

Instead, this is caused by defining a CucumberJS step but not including the right number of parameters in the callback function.

Take this step definition:

const { Given, Then } = require('cucumber');

Given(/window height is (\d+)px/, function() {
  // we'll keep the width the same
  const width = browser.getViewportSize('width');
  browser.setViewportSize({ height, width });

You may not notice is, but the function() line is missing something. In our step definition, we use a digit regex character class: e.g. (\d+).

This means we can pass in any number to our step definition and it will work.

But, we don't accept that number in our function callback. Because of this, and some processing that Cucumber does, it will cause all sorts of choas, eventually ending a bunch of error messages that don't really tell us much.

Thankfully, your search for this error ending on this page, and I can tell you what you need to do:

Quick Fix: Make sure the number of arguments in your callback function matches the number of capturing groups you have.

For us, the fixed line in our example would look like:

Given(/window height is (\d+)px/, function(height) {

unsplash-logoIan Froome