diff --git a/lib/helper/Protractor.js b/lib/helper/Protractor.js index 2dbecb901..b29bb4e99 100644 --- a/lib/helper/Protractor.js +++ b/lib/helper/Protractor.js @@ -42,6 +42,8 @@ let withinStore = {}; * * `restart` (optional, default: true) - restart browser between tests. * * `seleniumAddress` - Selenium address to connect (default: http://localhost:4444/wd/hub) * * `rootElement` - Root element of AngularJS application (default: body) + * * `waitForTimeout`: (optional) sets default wait time in _ms_ for all `wait*` functions. 1000 by default. + * * `scriptsTimeout`: (optional) timeout in milliseconds for each script run on the browser, 10000 by default. * * `windowSize`: (optional) default window size. Set to `maximize` or a dimension in the format `640x480`. * * `manualStart` (optional, default: false) - do not start browser before a test, start it manually inside a helper with `this.helpers["WebDriverIO"]._startBrowser()` * * `capabilities`: {} - list of [Desired Capabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities) @@ -67,6 +69,7 @@ class Protractor extends SeleniumWebdriver { seleniumAddress: 'http://localhost:4444/wd/hub', rootElement: 'body', scriptsTimeout: 10000, + waitForTimeout: 1000, // ms windowSize: null, driver: 'hosted', capabilities: {} @@ -75,6 +78,7 @@ class Protractor extends SeleniumWebdriver { this.options = Object.assign(this.options, config); if (this.options.proxy) this.options.capabilities.proxy = this.options.proxy; if (this.options.browser) this.options.capabilities.browserName = this.options.browser; + this.options.waitForTimeout /= 1000; // convert to seconds } _init() { @@ -211,7 +215,7 @@ class Protractor extends SeleniumWebdriver { * {{> ../webapi/waitForElement }} */ waitForElement(locator, sec) { - sec = sec || 1; + sec = sec || this.options.waitForTimeout; let el = this.browser.element(guessLocator(locator) || by.css(locator)); return this.browser.wait(EC.presenceOf(el), sec * 1000); } @@ -220,7 +224,7 @@ class Protractor extends SeleniumWebdriver { * Waits for element to become clickable for number of seconds. */ waitForClickable(locator, sec) { - sec = sec || 1; + sec = sec || this.options.waitForTimeout; let el = this.browser.element(guessLocator(locator) || by.css(locator)); return this.browser.wait(EC.elementToBeClickable(el), sec * 1000); } @@ -229,7 +233,7 @@ class Protractor extends SeleniumWebdriver { * {{> ../webapi/waitForVisible }} */ waitForVisible(locator, sec) { - sec = sec || 1; + sec = sec || this.options.waitForTimeout; let el = this.browser.element(guessLocator(locator) || by.css(locator)); return this.browser.wait(EC.visibilityOf(el), sec * 1000); } @@ -238,7 +242,7 @@ class Protractor extends SeleniumWebdriver { * {{> ../webapi/waitForInvisible }} */ waitForInvisible(locator, sec) { - sec = sec || 1; + sec = sec || this.options.waitForTimeout; let el = this.browser.element(guessLocator(locator) || by.css(locator)); return this.browser.wait(EC.invisibilityOf(el), sec * 1000); } @@ -258,7 +262,7 @@ class Protractor extends SeleniumWebdriver { context = this.context; } let el = this.browser.element(guessLocator(context) || by.css(context)); - sec = sec || 1; + sec = sec || this.options.waitForTimeout; return this.browser.wait(EC.textToBePresentInElement(el, text), sec * 1000); } diff --git a/lib/helper/SeleniumWebdriver.js b/lib/helper/SeleniumWebdriver.js index 3965ec8ec..7b7612fd4 100644 --- a/lib/helper/SeleniumWebdriver.js +++ b/lib/helper/SeleniumWebdriver.js @@ -71,13 +71,16 @@ class SeleniumWebdriver extends Helper { restart: true, keepCookies: false, windowSize: null, - waitforTimeout: 1000, // ms + waitForTimeout: 1000, // ms scriptTimeout: 1000, // ms manualStart: false, capabilities: {} }; + if (this.options.waitforTimeout) { + console.log(`waitforTimeout is deprecated in favor of waitForTimeout, please update config`); + this.options.waitForTimeout = this.options.waitforTimeout; + } this.options = Object.assign(this.options, config); - this.options.waitForTimeout ||= this.options.waitforTimeout; // deprecate waitforTimeout this.options.waitForTimeout /= 1000; // convert to seconds }