Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(context/web): add prefs for chromedriver (#257) #258

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions context/webctx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
Height = "height"
Driver = "driver" // Possible values: chrome, phantomjs, gecko
Args = "args"
Prefs = "prefs"
Timeout = "timeout"
Debug = "debug"
)
Expand Down Expand Up @@ -55,15 +56,24 @@ func (tcc *WebTestCaseContext) Init() error {
}
}
}
prefs := map[string]interface{}{}
if _, ok := tcc.TestCase.Context[Prefs]; ok {
switch tcc.TestCase.Context[Prefs].(type) {
case map[interface{}]interface{}:
for k, v := range tcc.TestCase.Context[Prefs].(map[interface{}]interface{}) {
prefs[k.(string)] = v
}
default:
return fmt.Errorf("%s are not a map[string]interface{}: %v (%T)", Prefs, tcc.TestCase.Context[Prefs], tcc.TestCase.Context[Prefs])
}
}

switch driver {
case "chrome":
tcc.wd = agouti.ChromeDriver(agouti.Desired(
agouti.Capabilities{
"chromeOptions": map[string][]string{
"args": args,
},
}))
tcc.wd = agouti.ChromeDriver(
agouti.ChromeOptions("args", args),
agouti.ChromeOptions("prefs", prefs),
)
case "gecko":
tcc.wd = agouti.GeckoDriver()
default:
Expand Down
14 changes: 13 additions & 1 deletion executors/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ Venom allows you to navigate into it and execute actions.
* Action (https://github.com/ovh/venom/tree/master/executors/web/types.go)
* Format

Parameters `debug` (default: false) and `timeout` (default: 180 seconds) are optional.
Web context allows you to configure the browser used for navigation. All parameters are optional:
* width: Width of the browser page
* height: Height of the browser page
* driver: `chrome`, `gecko` or `phantomjs` (default: `phantomjs`)
* args: List of arguments for `chrome` driver (see [here](https://peter.sh/experiments/chromium-command-line-switches/))
* prefs: List of user preferences for `chrome` driver, using dot notation (see [here](http://www.chromium.org/administrators/configuring-other-preferences) and [here](https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup))
* timeout: Timeout in seconds (default: 180)
* debug: Boolean enabling the debug mode of the web driver (default: false)

```yaml
name: TestSuite Web
Expand All @@ -21,6 +28,11 @@ testcases:
width: 1920
height: 1080
driver: phantomjs
args:
- 'browser-test'
prefs:
profile.default_content_settings.popups: 0
profile.default_content_setting_values.notifications: 1
timeout: 60
debug: true
steps:
Expand Down