switch201
switch201

Reputation: 597

Why am I getting an invalid select exception, when the same simple selector works in the chrome console?

I am using GEB with selenium.

This is one of the selectors I was getting invalid selector: An invalid or illegal selector was specified for

$("button:contains('Accept')")

If I run this selector through the chrome console it is able to find the element, but when I run the same selector through GEB/selenium is states it is an invalid selector

In the stack trace it also has this:

*** Element info: {Using=css selector, value=button:contains('Accept')} Again I do not see anything wrong with this selector.

if I change the code to use an xpath expression instead it works.

seleniumVersion = '3.13.0'

Upvotes: 0

Views: 455

Answers (1)

switch201
switch201

Reputation: 597

Apparently for GEB the syntax for defining the above selector would look like this:

$("button", text: contains('Accept'))

If you do it this way then it works

Upvotes: 3

Related Questions