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

ancestor returning no nodes since 3.27 #2234

Closed
cyrilchampier opened this issue Jul 29, 2019 · 5 comments
Closed

ancestor returning no nodes since 3.27 #2234

cyrilchampier opened this issue Jul 29, 2019 · 5 comments

Comments

@cyrilchampier
Copy link
Contributor

Meta

Capybara Version:
3.27.0
Driver Information (and browser if relevant):
selenium-webdriver (3.142.3)

Expected Behavior

ancestor method keep the same behavior as in 3.26.0

Actual Behavior

Most of our call to ancestors now fails.
From what I understand, here, we compare ancestors nodes with all nodes matching the selector, and select only intersection.

Problem seems to be the type, match_results contains types Capybara::Node::Simple while elements in the other array are Capybara::Node::Element.

Steps to reproduce

I did not fully understood, but here is our "call".
find('.dc-multi-level-selector-item-label', text: 'something').ancestor('.dc-multi-level-selector-item')
Tell me if you need more investigations on my side

@twalpole
Copy link
Member

What driver are you using and what is the relevant HTML?

@cyrilchampier
Copy link
Contributor Author

Here are the versions of our drivers:

chrome-driver: 75.0.3770.140
chrome: 75.0.3770.142

The command:

(byebug) find('.dc-multi-level-selector-item-label', text: 'Urgence').ancestor('.dc-multi-level-selector-item')
*** Capybara::ElementNotFound Exception: Unable to find visible css ".dc-multi-level-selector-item" that is an ancestor of visible css ".dc-multi-level-selector-item-label" with text "Urgence"

And the full html corresponding:

<div class="dc-multi-level-selector-item cursor-pointer">
  <span class="dc-checkbox dc-multi-level-selector-item-checkbox"></span>
  <div class="dc-multi-level-selector-item-content">
    <span class="dc-multi-level-selector-item-label">Urgence</span>
  </div>
</div>

@twalpole
Copy link
Member

https://gist.github.com/twalpole/4084690d90cc4beac28fcebf887cb6c1 is a self-contained example with that HTML showing the ancestor call working. What is it doing differently than your code?

@cyrilchampier
Copy link
Contributor Author

Thanks for the nice sample, i will keep it :)
I finally found the culprit, it's this appium_capybara gem that override Capybara::Queries::SelectorQuery#resolve_for and is incompatible with the new version.
Sorry for bothering you :(

@twalpole
Copy link
Member

@cyrilchampier Ok - I'm willing to provide a guaranteed stable API for them if there's something specific they need - overriding resolve_for isn't a great idea.

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

No branches or pull requests

2 participants