Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
hupe1980 committed Feb 26, 2023
1 parent 45e9a25 commit 4d3bac6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,22 @@ if err := os.WriteFile("./screenshot.png", data, 0600); err != nil {
}
```

## BiDi Session
```go
biDiSession := session.BiDiSession()

bc, err := biDiSession.NewBrowsingContext(bidi.BrowsingContextTypeWindow, nil)
if err != nil {
panic(err)
}

defer bc.Close()

navigation, err := bc.Navigate("https://golang.org", bidi.BrowsingContextReadinessStateComplete)
if err != nil {
panic(err)
}
```

## License
[MIT](LICENCE)
26 changes: 13 additions & 13 deletions capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ func (c Capabilities) Set(key string, value string) Capabilities {

type ChromeOptions map[string]interface{}

func (c Capabilities) SetChromeOptions(co ChromeOptions) Capabilities {
c["goog:chromeOptions"] = co
return c
}

func (c Capabilities) ChromeOptions() ChromeOptions {
if opts, ok := c["goog:chromeOptions"]; ok {
return opts.(map[string]interface{})
}

return nil
}

func (co ChromeOptions) AddArg(arg string) ChromeOptions {
if _, ok := co["args"]; ok {
co["args"] = append(co["args"].([]string), arg)
Expand Down Expand Up @@ -102,16 +115,3 @@ func (co ChromeOptions) DebuggerAddress() string {

return ""
}

func (c Capabilities) SetChromeOptions(co ChromeOptions) Capabilities {
c["goog:chromeOptions"] = co
return c
}

func (c Capabilities) ChromeOptions() ChromeOptions {
if opts, ok := c["goog:chromeOptions"]; ok {
return opts.(map[string]interface{})
}

return nil
}

0 comments on commit 4d3bac6

Please sign in to comment.