Skip to content

Commit 7ed0a73

Browse files
committed
allow default driver to return element state
1 parent dd998d4 commit 7ed0a73

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/plugin.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ export default class WaitCommandPlugin extends BasePlugin {
66
async findElement(next, driver, ...args) {
77
const locatorArgs = JSON.parse(JSON.stringify(args));
88
let originalRes;
9-
await this._find(driver, locatorArgs);
9+
await this._find(driver, locatorArgs, next);
1010
originalRes = await next();
1111
retryCount = 0;
1212
return originalRes;
1313
}
1414

15-
async _find(driver, locatorArgs) {
15+
async _find(driver, locatorArgs, next) {
1616
const response = await fetch(
1717
`http://${driver.uiautomator2.host}:${driver.uiautomator2.systemPort}/wd/hub/session/${driver.sessionId}/element`,
1818
{
@@ -27,13 +27,12 @@ export default class WaitCommandPlugin extends BasePlugin {
2727
}
2828
);
2929
const json = await response.json();
30-
if (retryCount === 25) {
31-
throw new Error('Element not found...');
32-
}
3330
if (json.value.error) {
34-
console.log(json.value.error, 'Retying...', retryCount);
35-
retryCount++;
36-
await this._find(driver, locatorArgs);
31+
if (retryCount !== 25) {
32+
console.log(json.value.error, 'Retying...', retryCount);
33+
retryCount++;
34+
await this._find(driver, locatorArgs);
35+
}
3736
}
3837
}
3938
}

0 commit comments

Comments
 (0)