w3c / webdriver

Remote control interface that enables introspection and control of user agents.
https://w3c.github.io/webdriver/
Other
676 stars 190 forks source link

Only accept valid tag names in Find element with "tag name" strategy? #1685

Open juliandescottes opened 1 year ago

juliandescottes commented 1 year ago

This question comes from the following geckodriver issue: https://github.com/mozilla/geckodriver/issues/2007

Chrome/chromedriver currently throws if Find Element by "tag name" is used with an empty string as the tag name, whereas Firefox/geckodriver will not throw and return an empty list.

At the moment, nothing in the specification mentions that the tag name should be validated before being used for get elements by tag name (https://www.w3.org/TR/webdriver/#tag-name). And getElementsByTagName does not throw when used with an empty string.

But selenium atoms prevent from using Find Element with an empty string as tag name. Chromedriver relies directly on selenium atoms to implement Find Element, so right now it throws with : invalid selector: Unable to locate an element with the tagName "".

The question is whether we should update the spec to align to the current behavior of selenium atoms & chromedriver and start validating the tag names, or rather update atoms to fit the current spec (assuming we are understanding it correctly).

I think there are other "invalid" tag names which can be used with getElementsByTagName. Eg ^ is invalid for HTML elements but can still be used with Find Element. Only empty string is validated by atoms/chromedriver.

whimboo commented 1 year ago

CC'ing @jgraham