Add sizzle support

Use the same `document` tracking fix/hack as in our CDP driver.
This commit is contained in:
Martin Pitt 2024-07-26 16:43:51 +02:00
parent 49317d7c19
commit 6c97825295
4 changed files with 17 additions and 8 deletions

View file

@ -127,9 +127,6 @@ class WebdriverBidi:
"log.entryAdded", "browsingContext.domContentLoaded",
])
test_functions = Path("test-functions.js").read_text()
await self.bidi("script.addPreloadScript", functionDeclaration=f"() => {{ {test_functions} }}")
# wait for browser to initialize default context
for _ in range(10):
realms = (await self.bidi("script.getRealms"))["realms"]
@ -193,7 +190,8 @@ class WebdriverBidi:
"""Send a Webdriver BiDi command and return the JSON response"""
payload = json.dumps({"id": self.last_id, "method": method, "params": params})
log_proto.debug("ws ← %r", payload)
# avoid log spam for preload scripts
log_proto.debug("ws ← %r", method if method == "script.addPreloadScript" else payload)
await self.ws.send_str(payload)
future = asyncio.get_event_loop().create_future()
self.pending_commands[self.last_id] = future