w3c / webdriver

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

Rational for this key? #1774

Closed ioquatix closed 10 months ago

ioquatix commented 10 months ago

The web element identifier is the string constant "element-6066-11e4-a52e-4f735466cecf".

Apologies for this question, but at first when Copilot auto-completed this in my custom webdriver implementation, I thought it was a bug.

After I checked the spec, I found out the code really should use this key, e.g.

module Async
  module WebDriver
    module Scope
      # The web element identifier is the string constant "element-6066-11e4-a52e-4f735466cecf".
      ELEMENT_KEY = "element-6066-11e4-a52e-4f735466cecf"

      def find_element(using, value)
        reply = post("element", {using: using, value: value})

        return Element.new(self.session, reply[ELEMENT_KEY])
      end

What is the rational for using what seems to be a particularly high-entropy key for what is expected to be a fairly common and unambiguous operation? Can we add this to the documentation/specification?

whimboo commented 10 months ago

The element identifier similar to ShadowRoot, window, and frame are relicts from the early implementations of Selenium we we kept it along to prevent backward incompatibilities. As such this also wont change anymore.

Note that for WebDriver BiDi a different serialization logic is used so that those arbitrary ids are not needed anymore, but are still internally shared by the browser to allow protocol interoperability.

ioquatix commented 10 months ago

My point was not to change them, but to add clarifications as to why they exist in the spec.