0

I my tests I am using WebDriverIO. I want to get all elements with class form_error that are visible.

I try something like this:

$$('.form_error:visible')

but the :visible filter is not a valid webdriverio selector construct. How to achieve that?

Dawid Ohia
  • 16,129
  • 24
  • 81
  • 95

1 Answers1

2

WebdriverIO uses CSS selectors to find elements, and :visible is not a valid CSS selector.

Instead, you could go two ways:

  1. Get all elements with a class of .form_error, then run isVisible() on them and filter the hidden ones out
  2. Use a custom execute function to run JavaScript on the page to check for visibility of elements. Something similar to this answer.
Kevin Lamping
  • 2,292
  • 16
  • 20