Open bcpeinhardt opened 1 year ago
This is a known issue with xpath and is a selenium / Webdriver thing. To search below the parent element with xpath you have to start with . /
.
I wasn't aware of By::Id behaving this way. That seems surprising. There are a few selectors (name and classname for example) that are just convenient wrappers around the css selector. The rest are passed directly to webdriver.
It would be good to compare the behaviour with either the Java or python selenium client. If there is any difference then we should fix our side.
And it probably needs some clarifying docs in any case. The xpath one in particular is a huge gotcha.
It seems like when querying from a base element, some locators will query first from the element (By::Name and By::ClassName seem to do this as expected), whereas others will query from the top of the document like calling query from driver (By::Id and By::XPath seem to do this).
If this doesn't make any sense I can put together an example later to demonstrate what I'm talking about.