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

waitForEnabled fix for webdriver 6 #2336

Merged
merged 1 commit into from
Apr 17, 2020
Merged
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
18 changes: 17 additions & 1 deletion lib/helper/WebDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,19 @@ class WebDriver extends Helper {
*/
async waitForEnabled(locator, sec = null) {
const aSec = sec || this.options.waitForTimeout;
if (isWebDriver5()) {
return this.browser.waitUntil(async () => {
const res = await this.$$(withStrictLocator(locator));
if (!res || res.length === 0) {
return false;
}
const selected = await forEachAsync(res, async el => this.browser.isElementEnabled(getElementId(el)));
if (Array.isArray(selected)) {
return selected.filter(val => val === true).length > 0;
}
return selected;
}, aSec * 1000, `element (${new Locator(locator)}) still not enabled after ${aSec} sec`);
}
return this.browser.waitUntil(async () => {
const res = await this.$$(withStrictLocator(locator));
if (!res || res.length === 0) {
Expand All @@ -1869,7 +1882,10 @@ class WebDriver extends Helper {
return selected.filter(val => val === true).length > 0;
}
return selected;
}, aSec * 1000, `element (${new Locator(locator)}) still not enabled after ${aSec} sec`);
}, {
timeout: aSec * 1000,
timeoutMsg: `element (${new Locator(locator)}) still not enabled after ${aSec} sec`,
});
}

/**
Expand Down