WebdriverIO Testing Library

Learn how to test using WebdriverIO Testing Library.

What is WebdriverIO Testing Library?

WebdriverIO Testing Library is a set of helper functions that extend WebdriverIO's capabilities to make it easier to select HTML elements similar to how end users would find them. For example, the library provides methods such as getByLabel, getByPlaceholder, and getByText that we can use to find elements using their label, placeholder values, and text content.

Selector example

Given the following HTML:

<button type="submit">Submit</button>

We can select the input element by using the following:

browser.getByRole('button', { name: /submit/i })

Let’s explain the code snippet above:

  • browser: This is an alias for the WebdriverIO API.
  • getByRole: This is a WebdriverIO Testing Library method that returns a button
...
Access this course and 1400+ top-rated courses and projects.