Skip to content

Commit

Permalink
Don't encourage the 'XPath trap' with examples
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jan 26, 2024
1 parent b37c5b4 commit 02e2650
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ distinguish an element that matches the selector from an element that does not:
page.html # => '<div id="greeting">Hello world</div>'

page.find(:css, 'div').text # => 'Hello world'
page.find(:xpath, '//div').text # => 'Hello world'
page.find(:xpath, './/div').text # => 'Hello world'
```

General purpose finder methods like [`find`][] and [`all`][] can accept the
Expand All @@ -756,7 +756,7 @@ page.find('div').text # => 'Hello world'

Capybara.default_selector = :xpath

page.find('//div').text # => 'Hello world'
page.find('.//div').text # => 'Hello world'
```

The locator argument's semantics are context-specific, and depend on the
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# ```ruby
# page.html # => '<input>'
#
# page.find :xpath, '//input'
# page.find :xpath, './/input'
# ```
#
# * **:css** - Select elements by CSS selector
Expand Down

0 comments on commit 02e2650

Please sign in to comment.