Skip to content

Commit 31673d1

Browse files
dsharapkouDzmitry Sharapkou
and
Dzmitry Sharapkou
authored
waitForEnabled fix for webdriver 6 (#2336)
Co-authored-by: Dzmitry Sharapkou <dzmitry.sharapkou@inturn.co>
1 parent 05b0672 commit 31673d1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/helper/WebDriver.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,19 @@ class WebDriver extends Helper {
18641864
*/
18651865
async waitForEnabled(locator, sec = null) {
18661866
const aSec = sec || this.options.waitForTimeout;
1867+
if (isWebDriver5()) {
1868+
return this.browser.waitUntil(async () => {
1869+
const res = await this.$$(withStrictLocator(locator));
1870+
if (!res || res.length === 0) {
1871+
return false;
1872+
}
1873+
const selected = await forEachAsync(res, async el => this.browser.isElementEnabled(getElementId(el)));
1874+
if (Array.isArray(selected)) {
1875+
return selected.filter(val => val === true).length > 0;
1876+
}
1877+
return selected;
1878+
}, aSec * 1000, `element (${new Locator(locator)}) still not enabled after ${aSec} sec`);
1879+
}
18671880
return this.browser.waitUntil(async () => {
18681881
const res = await this.$$(withStrictLocator(locator));
18691882
if (!res || res.length === 0) {
@@ -1874,7 +1887,10 @@ class WebDriver extends Helper {
18741887
return selected.filter(val => val === true).length > 0;
18751888
}
18761889
return selected;
1877-
}, aSec * 1000, `element (${new Locator(locator)}) still not enabled after ${aSec} sec`);
1890+
}, {
1891+
timeout: aSec * 1000,
1892+
timeoutMsg: `element (${new Locator(locator)}) still not enabled after ${aSec} sec`,
1893+
});
18781894
}
18791895

18801896
/**

0 commit comments

Comments
 (0)