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?)

Any ideas?

Thanks in advance :)

Answers


!= 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.


Need Your Help

Android search dialog shows unwanted additional suggestion list

android android-widget

The Android search dialog below is displaying suggestions I supply using my own content provider (aardvark, another, apple). Below that list is a second list (about, all, ...) which I do not want. ...

Good way to set/refresh information with thread in java swing app

java swing thread-safety swingworker concurrency

I'm not a Java programmer and I'm not sure if what I'm doing is correct or not, or if exist a better way to do this.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.