I am new to selenium coding, and I am seeing several xpaths that contain (.,'followed by something') what does the ., refer to?
Asked
Active
Viewed 154 times
1

undetected Selenium
- 183,867
- 41
- 278
- 352

ALISON HARTLEY
- 15
- 4
-
Welcome to Stack Overflow. Please [edit] the question to include one or more sample xpath examples that show this. By seeing the full context it will be possible to verify that the `.` refers to the current element. – Jason Aller Sep 19 '19 at 14:55
1 Answers
1
The .
character within the xpath is the short form of text()
As an example if an WebElement is represented within the DOM Tree as:
<span>Use this payment method</span>
Effective Locator Strategies will be:
xpath 1:
//span[text()='Use this payment method']
xpath 2:
//span[contains(., 'Use this payment method')]
Reference
You can find a couple of relevant discussions in:

undetected Selenium
- 183,867
- 41
- 278
- 352