Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
- `Node#trigger` silently dispatched nothing for events other than mouse, focus and `submit`, such as `input`,
`change` or custom events [#197]
- `Node#set` with an empty string cleared a text field without firing the `input` event [#164]
- Finders with `exact_text: true` raised `InvalidSelector` because Capybara appended an empty `[]` predicate to the
XPath [#256]

### Removed

Expand Down
4 changes: 4 additions & 0 deletions lib/capybara/cuprite/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ def all_text(node)
private

def find_all(method, selector, within = nil)
# Capybara appends its text-match hint as `(expr)[...]`, but with `exact_text: true` the hint
# is empty and the result `(expr)[]` is invalid XPath. An empty predicate is never valid, so
# dropping it can't change a valid selector. Remove once teamcapybara/capybara#2860 is released.
selector = selector.delete_suffix("[]") if method == :xpath
nodes = if within
evaluate("_cuprite.find(arguments[0], arguments[1], arguments[2])", method, selector, within)
else
Expand Down
5 changes: 5 additions & 0 deletions spec/features/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,11 @@
expect(@session.evaluate_script("window.last_hashchange")).to eq("#foo")
end

it "finds a link with exact_text: true" do
@session.visit "/with_html"
expect(@session.find_link("A link", exact_text: true)[:href]).to end_with("/with_simple_html")
end

context "current_url" do
let(:request_uri) { URI.parse(@session.current_url).request_uri }

Expand Down
Loading