webdriver icon indicating copy to clipboard operation
webdriver copied to clipboard

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

Open juliandescottes opened this issue 3 years ago • 1 comments

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.

juliandescottes avatar Sep 23 '22 06:09 juliandescottes

CC'ing @jgraham

whimboo avatar Sep 23 '22 06:09 whimboo