@@ -10,7 +10,6 @@ export default class WaitCommandPlugin extends BasePlugin {
1010 this . strategy = locatorArgs [ 0 ] ;
1111 this . selector = locatorArgs [ 1 ] ;
1212 await this . _find ( ) ;
13- await this . _elementDisplayed ( ) ;
1413 originalRes = await next ( ) ;
1514 retryCount = 0 ;
1615 return originalRes ;
@@ -35,6 +34,7 @@ export default class WaitCommandPlugin extends BasePlugin {
3534 `Element with ${ this . strategy } strategy for ${ this . selector } selector found.`
3635 ) ;
3736 retryCount = 0 ;
37+ await this . _elementDisplayed ( baseUrl ) ;
3838 }
3939 }
4040
@@ -55,17 +55,16 @@ export default class WaitCommandPlugin extends BasePlugin {
5555 return await response . json ( ) ;
5656 }
5757
58- async _elementDisplayed ( ) {
58+ async _elementDisplayed ( baseUrl ) {
5959 this . logger . info ( `Checking if ${ this . selector } element is displayed` ) ;
60- const baseUrl = this . _constructSessionUrl ( ) ;
61- const response = await this . elementDisplayed ( baseUrl ) ;
60+ const response = await this . elementDisplayStatus ( baseUrl ) ;
6261 if ( response . value . error ) {
6362 if ( retryCount !== this . _getTimeout ( ) ) {
6463 this . logger . info (
6564 `Retrying to check whether ${ this . selector } element is displayed or not`
6665 ) ;
6766 retryCount ++ ;
68- await this . _elementDisplayed ( ) ;
67+ await this . _elementDisplayed ( baseUrl ) ;
6968 }
7069 }
7170 if ( response . sessionId && response . value === 'true' ) {
@@ -74,7 +73,7 @@ export default class WaitCommandPlugin extends BasePlugin {
7473 }
7574 }
7675
77- async elementDisplayed ( baseUrl ) {
76+ async elementDisplayStatus ( baseUrl ) {
7877 const response = await fetch (
7978 `${ baseUrl } wd/hub/session/${ this . driver . sessionId } /element/${ this . element } /attribute/displayed` ,
8079 {
0 commit comments