I have the following html saved with the save_and_open_page command before running the capybara selectors (I also checked page.body, this is the same thing): https://gist.github.com/davidkovaccs/8991af5bed1805277f52
I get the following error message: "expected to find xpath" // div [@ class = 'box'] "9 times, found 6 matches:" box_2001 attrkulcs1: attrvalue 1 attrkulcs2: attrvalue 2 attrkulcs3: attrvalue 3 "," box_2002 attrkulcs1: attrvalue 1 attrkulcs2: attrvalue 3 attrkulcs3: attrvalue 3 attrkulcs3: attrvalue 3 attrkulcs1: attrvalue 1 attrkulcs2: attrvalue 1 attrkulcs2 . Also found "", "", "" that match the selector, but not all filters. (Capybara :: ExpectationNotMet)
Note that the 6 matches found are not equal to 6 for each test run. this number is from 4 to 9. I really do not understand what can be "consistent with the selector instruction, but not with all filters." As far as I know, I do not use any filters.
I tried the following selectors, but they all give the same error message:
have_xpath("//div[@class='box']", :count => 9)
have_selector(:css, '.box', :count => 9)
have_css('.box', :count => 9)
I also tried it with capybara 2.2.1 and 2.3.0. I am using Selenium webdriver 2.42.0
Running $ x ("// div [@ class = 'box']"). The length from the browser console works great.
source
share