File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export default class WaitCommandPlugin extends BasePlugin {
4141 }
4242 }
4343
44- if ( json . sessionId ) {
44+ if ( json . sessionId && json . value . ELEMENT ) {
4545 this . element = json . value . ELEMENT ;
4646 this . logger . info (
4747 `Element with ${ strategy } strategy for ${ selector } selector found.`
@@ -51,13 +51,27 @@ export default class WaitCommandPlugin extends BasePlugin {
5151
5252 async _elementDisplayed ( driver ) {
5353 this . logger . info ( 'Checking if element is displayed' ) ;
54- await fetch (
54+ const baseUrl = this . _constructSessionUrl ( driver ) ;
55+ const response = await fetch (
5556 `${ baseUrl } wd/hub/session/${ driver . sessionId } /element/${ this . element } /attribute/displayed` ,
5657 {
5758 method : 'GET' ,
5859 headers : { 'Content-Type' : 'application/json' } ,
5960 }
6061 ) ;
62+ const json = await response . json ( ) ;
63+ if ( json . value . error ) {
64+ if ( retryCount !== 25 ) {
65+ this . logger . info (
66+ `Retrying to check whether ${ this . element } element is displayed or not`
67+ ) ;
68+ retryCount ++ ;
69+ await this . _elementDisplayed ( driver ) ;
70+ }
71+ }
72+ if ( json . sessionId && json . value === 'true' ) {
73+ this . logger . info ( `Element with ${ this . element } id is displayed.` ) ;
74+ }
6175 }
6276
6377 _getAutomationName ( driver ) {
You can’t perform that action at this time.
0 commit comments