go-rod / rod

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

Add a JS script to browser #1017

Closed dunaevv closed 4 months ago

dunaevv commented 4 months ago

Rod Version: v0.114.7

How can I add a JS script which would be evaluated in Chrome? Can I do it like it in Playwright:

context.add_init_script(path_to_file)  

Thanks!

github-actions[bot] commented 4 months ago

Please fix the format of your markdown:

5 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
5 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
7 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]

generated by check-issue

ysmood commented 4 months ago

https://github.com/go-rod/rod/blob/c35d2abd99a193ef49e21e02591cb6572269291f/page_eval_test.go#L14-L30

dunaevv commented 4 months ago

https://github.com/go-rod/rod/blob/c35d2abd99a193ef49e21e02591cb6572269291f/page_eval_test.go#L14-L30

Thanks! I will try