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

Extensions.loadUnpacked wasn't found #148

Open MarioSimou opened 2 months ago

MarioSimou commented 2 months ago

The error message appears straightforward, but I'm uncertain about what I might be doing wrong. According to the documentation, I should use the absolute path of the extension. Therefore, I’m providing the absolute path to the extension's directory. However, I’m encountering the following error: cdp.Extensions: LoadUnpacked: rpc error: 'Extensions.loadUnpacked' wasn't found (code = -32601). Any idea why? Is there anything that I need to enable?

    var loadUnpackedArgs = extensions.NewLoadUnpackedArgs(
        "/home/projects/app/extension",
    )

    var loadUnpackedReply *extensions.LoadUnpackedReply
    var e error

    if loadUnpackedReply, e = c.Extensions.LoadUnpacked(bs.ctx, loadUnpackedArgs); e != nil {
        fmt.Printf("Error: %s", e.Error())
        return e
    }
mafredri commented 2 months ago

@MarioSimou your usage looks correct. I suspect your browser doesn't support it. What browser and version are you using, and are you running it in headless mode as well?

mafredri commented 2 months ago

@MarioSimou another option is that this is being blocked by security settings, see: https://knowledge.workspace.google.com/kb/load-unpacked-extensions-000005962

MarioSimou commented 1 month ago

I'm using Chrome v127.0.6533.88. Indeed, I'm running on headless mode, but using the --headless=new flag. Also, I don't think I use google workspace.

mafredri commented 1 month ago

Alright, please update to v128 (this was added in protocol version r1289136) and make sure to enable the --enable-unsafe-extension-debugging flag as per docs: https://pkg.go.dev/github.com/mafredri/cdp#Extensions

Although, considering --remote-debugging-pipe is mentioned, I'm not sure if that's sufficient.