Read more

About "unexpected '#' after 'DESCENDANT_SELECTOR' (Nokogiri::CSS::SyntaxError)"

Dominik Schöler
May 19, 2014Software engineer at makandra GmbH

The error unexpected 'x' after 'DESCENDANT_SELECTOR' (Nokogiri::CSS::SyntaxError) (where x may be basically any character) occurs when the Nokogiri parser receives an invalid selector like .field_with_errors # or td <strong>.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

In Cucumber, the culprit will be an invalid step definition that builds an invalid selector:

# inside some step definition:
field = find_field(label)
page.send(expectation, have_css(".field_with_errors ##{field[:id]}"))

The above raises the mentioned error if field[:id] is nil, i.e. the found field has no id.

Fix

Ensure your step definition cannot generate invalid selectors and instead prints better error messages. Adding field.should be_present might help,

Note

This error may be caused when your selenium browser window is too narrow, so that your driver can't see the field. May sound funny but true.

Posted by Dominik Schöler to makandra dev (2014-05-19 11:03)