Repository navigation
fix(browser): drop the empty xpath predicate Capybara adds for exact_text: true - #337
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #256.
find_link("Buchen", exact_text: true)raisedCapybara::Cuprite::InvalidSelectorbecause the XPath ended in an empty predicate:(.//a[...])[].On the first attempt Capybara appends its text-match hint as
(expr)[...]. Withexact_text: true(and no:text),matching_textreturnstrue,xpath_text_conditionsreturnsniland the predicate ends up empty. Selenium hides it becauseInvalidSelectorErroris in itsinvalid_element_errors, sosynchronizeretries without the hint. AddingInvalidSelectorto ours would do the same, but every genuinely invalid selector would then retry for the whole wait time before failing.Instead
Browser#find_alldrops a trailing[]from XPath selectors. An empty predicate is never valid XPath, so this can't change a valid selector, and nothing is lost since the hint was empty anyway.The real fix is upstream in teamcapybara/capybara#2860; this workaround can be removed once a release with it is required.