0

这是我通过 WebSocket 收到的消息。当我发送此消息时:

{ id: 3, method: 'Network.enable' }

...它回复:

{ id: 3, error: { code: -32601, message: "'Network.enable' wasn't found" } }

它也这么说'Page.navigate'

{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"1541d58d-c591-4a88-9e53-852b43ad9151","type":"browser","title":"","url":"","attached":true,"canAccessOpener":false}}}
{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"53D6E4E3FF62F8365364C9C252B99EA1","type":"background_page","title":"Chrome Media Router","url":"chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/_generated_background_page.html","attached":false,"canAccessOpener":false,"browserContextId":"FA3F0A2AA7B4498D28B9CD859D95FBB4"}}}
{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"885AA252B844C7B4FEC9F5AA2174CC76","type":"page","title":"","url":"https://www.websocket.org/echo.html","attached":false,"canAccessOpener":false,"browserContextId":"FA3F0A2AA7B4498D28B9CD859D95FBB4"}}}
{"id":1,"result":{}}
{"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"53D6E4E3FF62F8365364C9C252B99EA1","type":"background_page","title":"Chrome Media Router","url":"chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/_generated_background_page.html","attached":false,"canAccessOpener":false,"browserContextId":"FA3F0A2AA7B4498D28B9CD859D95FBB4"}}}
{"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"885AA252B844C7B4FEC9F5AA2174CC76","type":"page","title":"","url":"https://www.websocket.org/echo.html","attached":true,"canAccessOpener":false,"browserContextId":"FA3F0A2AA7B4498D28B9CD859D95FBB4"}}}
{"method":"Target.attachedToTarget","params":{"sessionId":"F9B5F64C1027EDFD4C1C20B827D40CF0","targetInfo":{"targetId":"885AA252B844C7B4FEC9F5AA2174CC76","type":"page","title":"","url":"https://www.websocket.org/echo.html","attached":true,"canAccessOpener":false,"browserContextId":"FA3F0A2AA7B4498D28B9CD859D95FBB4"},"waitingForDebugger":false}}
{"id":2,"result":{"sessionId":"F9B5F64C1027EDFD4C1C20B827D40CF0"}}
{"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"885AA252B844C7B4FEC9F5AA2174CC76","type":"page","title":"https://www.websocket.org/echo.html","url":"https://www.websocket.org/echo.html","attached":true,"canAccessOpener":false,"browserContextId":"FA3F0A2AA7B4498D28B9CD859D95FBB4"}}}
{"id":3,"error":{"code":-32601,"message":"'Network.enable' wasn't found"}}
4

2 回答 2

0

在激活之前,您需要在 devTools 中创建会话,您可以通过这种方式激活

    DevTools chromeDevTools = chromeDriver.getDevTools();
    chromeDevTools.createSession();

之后你可以做任何你想做的事

谢谢

于 2022-02-18T14:09:29.157 回答
0

您需要先创建会话,如果您使用的是 java / selenium,则代码为:devTools.createSession();

于 2021-07-21T11:56:03.367 回答