mafredri / cdp

Package cdp provides type-safe bindings for the Chrome DevTools Protocol (CDP), written in the Go programming language.
MIT License
725 stars 45 forks source link

Default example doesn't work - Page.Enable wasn't found #145

Closed let4be closed 1 year ago

let4be commented 1 year ago

getting cdp.Page: Enable: rpc error: 'Page.enable' wasn't found (code = -32601) using the default example Chrome 114.0.5735.90 and latest mafredri/cdp Ideas?

mafredri commented 1 year ago

Is it possible another client than Chrome 114 (other browser, Node.js, etc) is listening on the port you're connecting to?

I tried Chromium 116.0.5835.0 and all the examples/tests are working fine (and those do call Page.enable).

What does the version endpoint say? (Example)

v, err := devtool.New("http://127.0.0.1:9222").Version(ctx)
if err != nil {
    panic(err)
}
fmt.Printf("CDP Version: %#v\n", v)
let4be commented 1 year ago
CDP Version: &devtool.Version{Browser:"Chrome/114.0.5735.90", Protocol:"1.3", UserAgent:"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36", V8:"11.4.183.17", WebKit:"537.36 (@386bc09e8f4f2e025eddae123f36f6263096ae49)", AndroidPackage:"", WebSocketDebuggerURL:"ws://127.0.0.1:9222/devtools/browser/fef552f7-4b30-4be5-aa03-4ca0560b1412"}

Do I need to start chrome with some special flags? I'm currently using those flags: --disable-gpu --no-sandbox --disable-setuid-sandbox also tried adding --enable-automation --allow-running-insecure-content --no-first-run to no avail.

let4be commented 1 year ago

Mmm, I need to be more careful. Somehow wrong URI was specified in the devtool.New call I used http://127.0.0.1:9222/json/version here for some reason... It works.