From 189de4b69919d4d4066e380d7f2deb61af7a34f9 Mon Sep 17 00:00:00 2001 From: Davert Date: Tue, 18 Oct 2016 19:25:44 +0300 Subject: [PATCH 1/2] added timeouts to config section and defineTimeout method --- lib/helper/WebDriverIO.js | 51 ++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/lib/helper/WebDriverIO.js b/lib/helper/WebDriverIO.js index be86ecec6..9758d9773 100644 --- a/lib/helper/WebDriverIO.js +++ b/lib/helper/WebDriverIO.js @@ -42,7 +42,27 @@ let withinStore = {}; * * `windowSize`: (optional) default window size. Set to `maximize` or a dimension in the format `640x480`. * * `waitForTimeout`: (optional) sets default wait time in *ms* for all `wait*` functions. 1000 by default; * * `desiredCapabilities`: Selenium capabilities + * * `timeouts`: [WebDriverIO timeouts](http://webdriver.io/guide/testrunner/timeouts.html) defined as hash. * + * Example: + * + * ```json + * { + * "helpers": { + * "WebDriverIO" : { + * "browser": "chrome", + * "restart": false, + * "windowSize": "maximize, + * "timeouts": { + * "script": 60000, + * "page load": 10000, + * "implicit" : 5000 + * } + * } + * } + * } + * + * ``` * * Additional configuration params can be used from http://webdriver.io/guide/getstarted/configuration.html * @@ -230,15 +250,7 @@ class WebDriverIO extends Helper { } if (this.options.timeouts) { - if (this.options.timeouts.implicit) { - this.browser.timeouts('implicit', this.options.timeouts.implicit); - } - if (this.options.timeouts['page load']) { - this.browser.timeouts('page load', this.options.timeouts['page load']); - } - if (this.options.timeouts.script) { - this.browser.timeouts('script', this.options.timeouts.script); - } + this.defineTimeout(this.options.timeouts); } if (this.options.windowSize === 'maximize') { @@ -346,6 +358,27 @@ class WebDriverIO extends Helper { }) } + /** + * Set [WebDriverIO timeouts](http://webdriver.io/guide/testrunner/timeouts.html) in realtime: + * Timeouts are expected to be passed as object: + * + * ```js + * I.defineTimeout({ script: 5000 }); + * I.defineTimeout({ implicit: 10000, "page load": 10000, script: 5000 }); + * ``` + */ + defineTimeout(timeouts) { + if (timeouts.implicit) { + this.browser.timeouts('implicit', timeouts.implicit); + } + if (timeouts['page load']) { + this.browser.timeouts('page load', timeouts['page load']); + } + if (timeouts.script) { + this.browser.timeouts('script', timeouts.script); + } + } + /** * {{> ../webapi/amOnPage }} */ From fb88c9906e294b31acab28b01d7caa28d92b6e66 Mon Sep 17 00:00:00 2001 From: Davert Date: Tue, 18 Oct 2016 19:29:01 +0300 Subject: [PATCH 2/2] tiny typo --- lib/helper/WebDriverIO.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helper/WebDriverIO.js b/lib/helper/WebDriverIO.js index 9758d9773..1b5e25eb2 100644 --- a/lib/helper/WebDriverIO.js +++ b/lib/helper/WebDriverIO.js @@ -359,7 +359,7 @@ class WebDriverIO extends Helper { } /** - * Set [WebDriverIO timeouts](http://webdriver.io/guide/testrunner/timeouts.html) in realtime: + * Set [WebDriverIO timeouts](http://webdriver.io/guide/testrunner/timeouts.html) in realtime. * Timeouts are expected to be passed as object: * * ```js