From d3d972623cc6ce0a77cfe1d599e6ca98bb39ed54 Mon Sep 17 00:00:00 2001 From: Andrea Bisello Date: Mon, 2 Oct 2017 17:56:29 +0200 Subject: [PATCH 1/2] Improved xpath locator documentation --- src/SeleniumLibrary/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/SeleniumLibrary/__init__.py b/src/SeleniumLibrary/__init__.py index 29cd21df4..675a75bfa 100644 --- a/src/SeleniumLibrary/__init__.py +++ b/src/SeleniumLibrary/__init__.py @@ -121,6 +121,15 @@ class SeleniumLibrary(DynamicCore): Notice that using the ``sizzle`` strategy or its alias ``jquery`` requires that the system under test contains the jQuery library. + xpath can also be used to click element contains text + + Example: + + | `Click Element` | xpath=//*[contains(text(),'ABC')] | + + This will Click Element containing ABC text. Notice that this approach can be error prone + and you should use other locators when possible. + === Implicit XPath strategy === If the locator starts with ``//`` or ``(//``, the locator is considered From ed9797b1072d5e2fafcd5ec32031df9c571dc658 Mon Sep 17 00:00:00 2001 From: Andrea Bisello Date: Mon, 9 Oct 2017 08:37:43 +0200 Subject: [PATCH 2/2] Improved Xpath Documentation and Examples --- src/SeleniumLibrary/__init__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/SeleniumLibrary/__init__.py b/src/SeleniumLibrary/__init__.py index 675a75bfa..b0eed1392 100644 --- a/src/SeleniumLibrary/__init__.py +++ b/src/SeleniumLibrary/__init__.py @@ -121,11 +121,6 @@ class SeleniumLibrary(DynamicCore): Notice that using the ``sizzle`` strategy or its alias ``jquery`` requires that the system under test contains the jQuery library. - xpath can also be used to click element contains text - - Example: - - | `Click Element` | xpath=//*[contains(text(),'ABC')] | This will Click Element containing ABC text. Notice that this approach can be error prone and you should use other locators when possible. @@ -138,8 +133,10 @@ class SeleniumLibrary(DynamicCore): Examples: - | `Click Element` | //div[@id="container"] | - | `Click Element` | (//div)[2] | + | `Click Element` | //div[@id="container"] | Click Div With id : container | + | `Click Element` | (//div)[2] | Click the second div in the document | + | `Click Element` | xpath=//*[contains(text(),'ABC')] | Click element containint text ABC | + The support for the ``(//`` prefix is new in SeleniumLibrary 3.0.