go-rod / rod

A Chrome DevTools Protocol driver for web automation and scraping.
https://go-rod.github.io
MIT License
5k stars 328 forks source link

Upload file on Managed Launcher? #1030

Open jackbit opened 3 months ago

jackbit commented 3 months ago

Rod Version: v0.114.7 Example script:

func UploadFile(launcherURLstring, localFilePath string) {
    browser := launcher.MustNewManaged(launcherURL).StartURL("about:blank").NoSandbox(true).MustConnect()
    page := browser.MustPage(`http://local.host/upload-form`)
    page.MustElementX(`//input[@type="file"]`).MustSetFiles(localFilePath )
}

The script above is working well, but the file is invalid. Because I think the remote browser can not select local file. Any idea how to handle it ?

github-actions[bot] commented 3 months ago

Please add a valid Rod Version: v0.0.0 to your issue. Current version is v0.114.8

generated by check-issue

ysmood commented 3 months ago

For now, you can create a file server on the managed docker container to accept remote files.

cdp doesn't have this kind of api yet.