@@ -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