...

/

Understanding WebdriverIO Selectors

Understanding WebdriverIO Selectors

Learn about the basics of WebdriverIO selector methods.

Element selector strategies

Locating elements on a web page is essential to writing automated user interface tests. We have to find elements before we can interact with them. WebdriverIO provides several strategies to locate elements. Many strategies allow us to select elements similar to how end users interact with the application in the browser. Let's look at a few of these strategies.

Anchor elements

We can locate anchor elements by their text value. For example, given the following HTML anchor element:

<a href="https://www.educative.io/">Educative</a>

We can select the element in WebdriverIO as follows:

const link = await $('=Educative')

In the code snippet above, we use the link text strategy to locate an element whose text is equal to the given value after the =. In addition, we can also use *= to select an element whose text contains a given substring. Given the following ...

Access this course and 1400+ top-rated courses and projects.