From 02e26508f3f7eb5b67d007e3b5276d27e296e300 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Fri, 26 Jan 2024 15:36:29 -0800 Subject: [PATCH] Don't encourage the 'XPath trap' with examples --- README.md | 4 ++-- lib/capybara/selector.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index da1851371..cca656c9d 100644 --- a/README.md +++ b/README.md @@ -740,7 +740,7 @@ distinguish an element that matches the selector from an element that does not: page.html # => '
Hello world
' 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 @@ -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 diff --git a/lib/capybara/selector.rb b/lib/capybara/selector.rb index 3e6694135..8d5cf82c1 100644 --- a/lib/capybara/selector.rb +++ b/lib/capybara/selector.rb @@ -24,7 +24,7 @@ # ```ruby # page.html # => '' # -# page.find :xpath, '//input' +# page.find :xpath, './/input' # ``` # # * **:css** - Select elements by CSS selector