Skip to content

Commit dd998d4

Browse files
committed
Consider active driver port and host
1 parent 29c9ae4 commit dd998d4

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/plugin.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ export default class WaitCommandPlugin extends BasePlugin {
66
async findElement(next, driver, ...args) {
77
const locatorArgs = JSON.parse(JSON.stringify(args));
88
let originalRes;
9-
try {
10-
await this._find(driver, locatorArgs);
11-
} catch (e) {
12-
originalRes = await next();
13-
}
9+
await this._find(driver, locatorArgs);
10+
originalRes = await next();
11+
retryCount = 0;
1412
return originalRes;
1513
}
1614

1715
async _find(driver, locatorArgs) {
1816
const response = await fetch(
19-
`http://localhost:8200/wd/hub/session/${driver.sessionId}/element`,
17+
`http://${driver.uiautomator2.host}:${driver.uiautomator2.systemPort}/wd/hub/session/${driver.sessionId}/element`,
2018
{
2119
body: JSON.stringify({
2220
strategy: locatorArgs[0],
@@ -29,12 +27,11 @@ export default class WaitCommandPlugin extends BasePlugin {
2927
}
3028
);
3129
const json = await response.json();
32-
console.log(json);
33-
if (retryCount === 5) {
30+
if (retryCount === 25) {
3431
throw new Error('Element not found...');
3532
}
3633
if (json.value.error) {
37-
console.log(json.value.error, 'Retying...');
34+
console.log(json.value.error, 'Retying...', retryCount);
3835
retryCount++;
3936
await this._find(driver, locatorArgs);
4037
}

0 commit comments

Comments
 (0)