Reputation: 47
I get it not the Watir in conjunction with rspec find my text. The following code leads to this error.
browser.text.include?("Coverberechnung").should == true
expected: true got: false (using ==)
Using should from rspec-expectations' old :should syntax
without explicitly enabling the syntax is deprecated. Use the new
:expect syntax or explicitly enable :should instead. Called from
Maybe I can have a help
URL for the Site: enter link description here
Upvotes: 3
Views: 10134
Reputation: 5283
You're looking for an initially-capitalized string (i.e. Coverberechnung), but that string is all-capitalized on the test site (i.e. COVERBERECHNUNG).
Try:
browser.text.include?("COVERBERECHNUNG").should == true
or (using expect syntax)
expect(browser.text.include?("COVERBERECHNUNG")).to be true
Upvotes: 5
Reputation: 11
I prefer to use
expect(browser.text).to include('coverberechnung')
Upvotes: 1
Reputation: 26
Or you can just do the following:
fail unless @browser.text.include? 'COVERBERECHNUNG'
Or if you want to target that exact string, you could do the following instead:
@browser.h1(text: 'COVERBERECHNUNG').wait_until_present
This code will raise an exception after 30 seconds (thus, failing your test in the process) if it can't find a header element with the text: 'COVERBERECHNUNG'. You can also override the waiting or polling process by doing the following:
@browser.h1(text: 'COVERBERECHNUNG').wait_until_present(10)
That code will check that h1 element within 10 seconds.
Upvotes: 0
Reputation: 374
If I wanted to be indifferent about case I would do something like this:
browser.text.upcase.include?("COVERBERECHNUNG").should == true
or
browser.text.downcase.include?("coverberechnung").should == true
this way you can avoid text comparison that may have varying cases.
also for you last problem #3: use
expect(browser.text.downcase.include?("coverberechnung")).to be true
they deprecated that version some time ago. so you can give this one a try with no issue.
NOTE: only one caveat is that this will ignore case. As described above.
Upvotes: 0