After performing a search using POST /session/{session id}/element
, I get this from the Chrome webdriver:
{ sessionId: '3241e7da289f4feb19c1f55dfc87024b',
status: 0,
value: { ELEMENT: '0.12239552668870868-1' } }
Is this what the specs demand?
I am asking because I couldn't find anywhere a spot where it said clearly "ELEMENT" in capital letters. All I can find in the specs is that a key called value
is set (which it is: it's set as { ELEMENT: '0.12239552668870868-1' }
Can I always always expect this response, from other browsers' webdrivers? That is, are
status
andsessionId
always returned?Is that
{ ELEMENT: '0.12239552668870868-1' }
the way chromium makes up the object? Or is this true for any webdrivers? Of not, what do other webdrivers return?
I have just encountered this same issue, and found the change was made around 3.5 of the Selenium server and related images.
I found this comment the most specific to understand the change and identify which version it changed in: https://github.com/SeleniumHQ/selenium/issues/4773#issuecomment-333092149
I am using Docker images like selenium/node-firefox:3.4.0-actinium, and have found v3.4.0 returns the
ELEMENT
key from the older JSonWire spec, whereas v3.9 returns the formatelement-6066-11e4-a52e-4f735466cecf
from the new WebDriver spec. (I haven't checked any other versions in between).It's part of their gradual migration to WebDriver, but it is a bit confusing that they did this breaking change at 3.5 (or thereabouts) and not v3.0.0 which I think everyone would have been OK with.
Also there's a mix of implementations in the "native" drivers like Gecko which is produced by the Firefox team now, and Chrome, as they will have different development roadmaps.
Furthermore, I've found the client-side library I'm using hasn't even implemented the new response yet, so I'll have to hang back for a while (or patch and PR it myself). I've seen similar conversations in other clients (like the Java client 2 years ago).
You can see the differences between the two protocols' definitions of the Element response:
https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#webelement-json-object
https://www.w3.org/TR/webdriver/#elements
As you have referred the
WebDriver-W3C Candidate Recommendation
, let us see the relevant bits. The specs clearly mentions the following :[[GetOwnProperty]]
(name).[[GetOwnProperty]]
inECMAScript® Language Specification
is defined as :GetOwnProperty
are internal method used for other native ECMAScript objects and are resolved within the internal scope of theBrowser Drivers
andBrowser Clients
.Object.getOwnPropertyNames()
andgetOwnPropertyDescriptors()
.Browser Specific Implementation
I did a small test with all the info you have provided with
Search Box
ofGoogle Home Page
i.e.https://www.google.co.in
with all the major variants ofWebDrivers
and here is the result :ChromeDriver
-OSS
:FirefoxDriver
-W3C
:InternetExplorerDriver
-W3C
:So as you can observe from the field details of the concerned
value
field returned is in similar pattern and till theWebDriver
variant passes the correct reference to user it shouldn't be a obstacle.Finally, it is worth to mention at this point of time that like
FirefoxDriver
andInternetExplorerDriver
(both being W3C compliant),ChromeDriver
is still not W3C compliant and may vary in behavioral aspects.Update A
As per your question and update, you are pretty right about
ChromeDriver
andChrome
communication protocol. Getting more granular we can find some difference in thewebdriver
call as follows :Firefox :
So, Firefox Browser returns :
Chrome :
So, Chrome Browser returns :
What matters most to we user is the value of the element returned by the browser object which is always referred by an user and correctly identified by the
webdriver
instance. All these inner logic becomesabstract
to the end user.Update B
Adding some significant bytes from @FlorentB. 's comments :