Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange selectors behaviour #1326

Closed
davidkovaccs opened this issue Jun 10, 2014 · 3 comments
Closed

Strange selectors behaviour #1326

davidkovaccs opened this issue Jun 10, 2014 · 3 comments

Comments

@davidkovaccs
Copy link

I have the following html saved with the save_and_open_page command right before the capybara selectors are run (I've also checked page.body, it's the same): 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 2 attrkulcs3: attrvalue 3 attrkulcs4: attrvalue 4", "box_2003", "box_1001", "box_1002 attrkulcs1: attrvalue 1 attrkulcs2: attrvalue 2 attrkulcs3: attrvalue 3", "box_1003 attrkulcs1: attrvalue 1". Also found "", "", "", which matched the selector but not all filters. (Capybara::ExpectationNotMet)'

Note that the found 6 matches is not 6 for every test run. it a number between 4 and 9. I don't really understand what can be the 'matched the selector but not all filters' statement. As I know I'm not using any filters.

I've tried the following selectors, but all of them gives the same error message:

have_xpath("//div[@Class='box']", :count => 9)
have_selector(:css, '.box', :count => 9)
have_css('.box', :count => 9)
I've tried it with capybara 2.2.1 and 2.3.0 also. I'm using Selenium webdriver 2.42.0

Running $x("//div[@Class='box']").length from browser console works perfectly.

@twalpole
Copy link
Member

You are actually using filters count and visible (defaults to true) without the relevant css it's impossible to say for sure, however the three empty sets of quotes would tend to indicate that 3 of the .box elements weren't actually visible on the page

@davidkovaccs
Copy link
Author

Thanks for your help, this was the problem indeed! With a :visible => false flag it works perfectly.
This existance of this visible parameter was not clear for me and I couldn't found anything related to this on the web.
Thanks anyway!

@twalpole
Copy link
Member

@davidkovaccs just FYI - but visible defaults to true since in most cases when doing user interaction tests one wants tto make sure the content is actually visible to the user

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants