i'm trying to write my own custom webdriver interface to control firefox through chrome devtools protocol (cdp). i launch firefox using firefox-esr --remote-debugging-port 0 and then it creates a websocket that i connect to using python:
async def main_client():
async with websockets.connect("ws://localhost:34805/devtools/browser/f67014fd-9397-478d-a11e-66c189704ab0") as client_connection:
while True:
message = input("type in a command: ")
await client_connection.send(message)
asyncio.run(main_client())
then i send a message in json format
{
"command":"Runtime.evaluate",
"parameters":{"expression": "console.log(\"this is a message\")"}
}
the problem is that when i send the message nothing happens on the receiving end. does anyone know how to send messages over websocket to firefox?
thanks