Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Poltergeist case insensitive

I'm using Poltergeist / Capybara for my tests:

Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app, {
      timeout: 60,
      phantomjs_options: ['--load-images=no'],
      case_insensitive: true # <-- doesn't work
    })
  end
end

but I noticed that I have to rewrite a lot of tests, as Poltergeists driver seems to be case-sensitive. Is there anything I can pass to change this?

like image 704
supersize Avatar asked Jan 18 '26 20:01

supersize


2 Answers

As @eugen mentions all searches in capybara are case sensitive by default. The problem you mention of having to rewrite tests usually occurs when moving from a driver that does/does-not support css text-transform to one that does-not/does - so the text being matched is or is not having the css text-transform (uppercase/lowercase/capitalize/...) applied. If you want to be able to swap back and forth between drivers and really need case insensitivity you can pass regexes to the different matchers

expect(page).to have_text(/case insensitive text/i)
expect(page).to have_selector(:css, '#div1', text: /case insensitive text/i)
like image 126
Thomas Walpole Avatar answered Jan 20 '26 10:01

Thomas Walpole


All searches in capybara are case sensitive, there is no global option to change that. If you need to do case insensitive matching, you'll have to do it on a search by search basis.

like image 29
eugen Avatar answered Jan 20 '26 09:01

eugen