diff --git a/context/webctx/context.go b/context/webctx/context.go index 8b83dfca..b07394bb 100644 --- a/context/webctx/context.go +++ b/context/webctx/context.go @@ -18,6 +18,7 @@ const ( Height = "height" Driver = "driver" // Possible values: chrome, phantomjs, gecko Args = "args" + Prefs = "prefs" Timeout = "timeout" Debug = "debug" ) @@ -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: diff --git a/executors/web/README.md b/executors/web/README.md index a4e315e3..18ab483a 100644 --- a/executors/web/README.md +++ b/executors/web/README.md @@ -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 @@ -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: