Reputation: 3705
In Rspec Capybara test I want to check that no H4, H5, ..., H9 selector exists.
I would expect the following solution:
visit "/"
expect(page).not_to have_css(/(h|H)\[4-9]d/)
But it fails due to Nokogiri parsing
I also noticed that:
has_css?("h1")
# is not equal to
has_css?("H1")
Upvotes: 1
Views: 1411
Reputation: 101891
Some alternatives:
visit "/"
expect(page).not_to have_css("h1,H1,h2,H2,h3,H3,h4,H4,h5,H5,h6,H6,h7,H7,h8,H8,h9,H9")
I used the following snippet to generate that ugly selector:
(1..9).map { |n| "h#{n.to_s},H#{n.to_s}" }.join(',')
How can I create a nokogiri case insensitive Xpath selector?
Nokogumbo is a HTML5 parser which creates lowercase element names.
Upvotes: 1