Capybara/Poltergeist: CSS Attribute Selector raising syntax error
I'm using Capybara 2.3 with Poltergeist (on Rails), and I've encountered a problem when calling 'has_selector' with a CSS selector which includes attribute value. For Example:
page.has_selector? "select#select_id option[value!='1']"
results in the following error:
Capybara::Poltergeist::InvalidSelector: The browser raised a syntax error while trying to evaluate css selector "select#select_id option[value!='1']"
Since I'm using the '!=' operator, I can't use the 'args' parameter of 'has_selector?' (or can I?)
Thanks in advance :)
!= is not a valid CSS attribute comparator (at least in chrome). You might want to try
page.has_selector? "select#select_id option:not([value='1'])"
You can achieve the same with the :not pseudo-class.