skip to content

Element Location

How a Selenium client names the element it wants: the By strategies, what a find call hands back, the CSS and XPath expression languages, and reaching into a shadow root.

on this pageshow

explore

questions

page 2 of 2

In Selenium XPath locators, why is ends-with() unavailable when starts-with() works fine?

level: middleimportance: nice to knowfreq 28%

basics

~10 s

Browsers evaluate locators with document.evaluate, which implements XPath 1.0 only, and ends-with() arrived in XPath 2.0. Selenium 4 offers no way to raise that version, so you emulate it with substring and string-length.

open as a page

In Selenium, why does re-finding a parent WebElement not refresh the child elements found through it?

level: seniorimportance: nice to knowfreq 36%

basics

~20 s

A nested find resolves once and returns a handle on one node, with no link back to the parent. Re-finding the parent only re-runs the parent's locator, so the child references still point at the nodes a re-render discarded.

open as a page

showing 31–32 of 32