Debian Codegraph @

lib/examples/compare-chromedp/eval/main.go

raw
1 // Package main ...
2 package main
3
4 import (
5 "log"
6
7 "github.com/go-rod/rod"
8 )
9
10 // This example shows how we can use Eval to run scripts in the page.
11 // Note: `this` in the eval function will refer to the element that Eval is
12 // called on. This can be useful for things such as blurring elements.
13 func main() {
14 res := rod.New().MustConnect().
15 MustPage("https://www.google.com/").
16 MustElement(`input`).
17 MustEval("() => Object.keys(window)")
18
19 log.Printf("window object keys: %v", res)
20 }