GoogleChromeLabs / chromium-bidi

Implementation of WebDriver BiDi for Chromium
https://googlechromelabs.github.io/chromium-bidi/
Apache License 2.0
90 stars 31 forks source link

`browsingContext.locateNodes` causes `Cannot convert undefined or null to object` #2663

Open christian-bromann opened 1 week ago

christian-bromann commented 1 week ago

The following browsingContext.locateNodes command causes an unexpected error. The payload is:

{
  "locator": {
    "type": "css",
    "value": "p"
  },
  "context": "9D759775E2DD1A3A0DF3F19F190FBB2A",
  "startNodes": [
    {
      "sharedId": "f.9D759775E2DD1A3A0DF3F19F190FBB2A.d.68270CA8749D6C7CD4AA73E22040C295.e.9"
    },
    {
      "sharedId": "f.9D759775E2DD1A3A0DF3F19F190FBB2A.d.68270CA8749D6C7CD4AA73E22040C295.e.11"
    },
    {
      "sharedId": "f.9D759775E2DD1A3A0DF3F19F190FBB2A.d.68270CA8749D6C7CD4AA73E22040C295.e.11"
    }
  ]
}

The error:

TypeError: Cannot convert undefined or null to object
    at Function.hasOwn (\u003Canonymous>)
    at WindowRealm.serializeForBiDi (\u003Canonymous>:517:1368)
    at WindowRealm.serializeForBiDi (\u003Canonymous>:549:1915)
    at WindowRealm.serializeForBiDi (\u003Canonymous>:517:1750)
    at WindowRealm.serializeForBiDi (\u003Canonymous>:549:1915)
    at WindowRealm.cdpToBidiValue (\u003Canonymous>:517:527)
    at WindowRealm.callFunction (\u003Canonymous>:517:6978)
    at async WindowRealm.callFunction (\u003Canonymous>:549:3531)
    at async #locateNodesByLocator (\u003Canonymous>:565:25244)
    at async BrowsingContextImpl.locateNodes (\u003Canonymous>:565:19734)

It seems like Chromedriver struggles if there are duplicate shared Ids.

christian-bromann commented 1 week ago

I am getting another error for a simple lookup query:

2024-10-10T21:27:50.196Z INFO webdriver: BIDI COMMAND browsingContext.locateNodes {"locator":{"type":"css","value":"li"},"context":"BF44CEC775C51410E3C7088F35447BBB","startNodes":[{"sharedId":"f.BF44CEC775C51410E3C7088F35447BBB.d.61DA9EE30FB3CCA2EBEDC0274F4E18AE.e.8"},{"sharedId":"f.BF44CEC775C51410E3C7088F35447BBB.d.61DA9EE30FB3CCA2EBEDC0274F4E18AE.e.2"},{"sharedId":"f.BF44CEC775C51410E3C7088F35447BBB.d.61DA9EE30FB3CCA2EBEDC0274F4E18AE.e.6"}]}
2024-10-10T21:27:50.201Z DEBUG webdriver: BIDI RESULT {"error":"unknown error","id":20,"message":"Cannot convert undefined or null to object","stacktrace":"TypeError: Cannot convert undefined or null to object\n    at Function.hasOwn (\u003Canonymous>)\n    at WindowRealm.serializeForBiDi (\u003Canonymous>:517:1368)\n    at WindowRealm.serializeForBiDi (\u003Canonymous>:549:1915)\n    at WindowRealm.serializeForBiDi (\u003Canonymous>:517:1750)\n    at WindowRealm.serializeForBiDi (\u003Canonymous>:549:1915)\n    at WindowRealm.cdpToBidiValue (\u003Canonymous>:517:527)\n    at WindowRealm.callFunction (\u003Canonymous>:517:6978)\n    at async WindowRealm.callFunction (\u003Canonymous>:549:3531)\n    at async #locateNodesByLocator (\u003Canonymous>:565:25244)\n    at async BrowsingContextImpl.locateNodes (\u003Canonymous>:565:19734)","type":"error"}
OrKoN commented 1 week ago

@christian-bromann are you sure the args are from the same realm? do you have an executable example to reproduce?