Skip to content
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
14 changes: 9 additions & 5 deletions lib/helper/Protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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: {}
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}

Expand Down
7 changes: 5 additions & 2 deletions lib/helper/SeleniumWebdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down