Now I have the problem that I can identify the text in a table.
For this Site I choose from
Test with test::unit okay
assert(@browser.th(:text => "Buchrückenbreite").exists?)
assert(@browser.td(:text => "0.13 cm").exists?)
Test with rspec incorrect
@browser.th(:text => "Buchrückenbreite").should == true
@browser.td(:text => "0.13 cm").should == true
Error Message:
expected: true
got: #<Watir::TableHeaderCell:0x..fc61f5c1d071c696a located=false selector={:text=>"Buchrückenbreite", :tag_name=>"th"}> (using ==)
Diff:
@@ -1,2 +1,2 @@
-true
+#<Watir::TableHeaderCell:0x..fc61f5c1d071c696a located=false selector={:text=>"Buchrückenbreite", :tag_name=>"th"}>
Another test:
expect(@browser.th(:text => "Buchrückenbreite")).to be_true
Error Message:
expected #<Watir::TableHeaderCell:0x007fd9452034d0> to respond to
true?
If you want to check if an object exists, you can use RSpec's exist matcher
.
In the 'should' syntax:
@browser.th(:text => "Buchrückenbreite").should exist
@browser.td(:text => "0.13 cm").should exist
Or in the 'expect' syntax:
expect(@browser.th(:text => "Buchrückenbreite")).to exist
expect(@browser.td(:text => "0.13 cm")).to exist