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
Obsolete nodes are not refreshed when using Capybara's #within and/or #synchronize #242
Comments
I did some monkey-patching to fix similar issue
module NodePatch
def command(name, *args)
browser.send(name, node, *args)
rescue Ferrum::NodeNotFoundError => e
# Throw ElementNotFound because it's not inside #invalid_element_errors
# so it would not be suppresed inside Capybara::Queries::SelectorQuery#matches_filters?
# and then error would force element to reload Capybara::Node::Element#reload
# instead of just ignore it
#
# Original code:
# raise ObsoleteNode.new(self, e.response)
raise Capybara::ElementNotFound, e.response
rescue Ferrum::BrowserError => e
case e.message
when 'Cuprite.MouseEventFailed'
raise MouseEventFailed.new(self, e.response)
else
raise
end
end
end
Capybara::Cuprite::Node.prepend NodePatch I still think that there should be better way to do that |
I spent a lot of time debugging Capybara/Cuprite/Ferrum source code trying to get to the root of this issue just to realize it's not actually a bug. There is a good reason outlined by @jnicklas in this comment. Basically, when you use |
Reproduction
This code uses Capybara's
synchronize
inside ofwithin
. The code insidesynchronize
always fails, but that's a simplification from the real application. The page has JavaScript that fully replaces the#parent
element that contains the#child
element, which is what Capybara is looking for.Gemfile
repro.rb
index.html
Steps
python3 -m http.server --bind '::1' 8888
bundle exec ruby repro.rb
Output
Observations
If I add
puts page.has_selector?('#child', text: 'Child 2')
before thesynchronize
block, it will print outtrue
and the program will (correctly) exit withDummyError
.If I replace
cuprite
withapparition
, the program will (correctly) exit withDummyError
.The text was updated successfully, but these errors were encountered: