Both chromedriver and geckodriver have strange behavior:
When executing javascript via the driver, objects in the return value that have the property nodeType
with values 1
or 9
(Element or Document types) are converted to Element representations.
Another way to show this, is by starting the driver, then creating a session by POST'ing to http://localhost:9515/session
and then executing javascript by POST'ing to http://localhost:9515/session/<session_id>/execute/sync
. The response is something like:
{
"ELEMENT": "0.6880568807801719-1"
}
This behavior isn't documented in the spec: https://w3c.github.io/webdriver/
The tl;dr; is that in
kCallFunctionScript
which both executeScript and getNode by node ID there is incorrect code reuse. It's a bug in ChromeDriver you're welcome to fix it:executeScript does:
Which does:
Funnily,
GetNodeIdFromFunction
also does:This is funny, because kCallFunctionScript is: