@@ -45,6 +45,7 @@ module.exports = class BasePage {
4545 return this . selectOption ( SELECT_REFRESH , option )
4646 }
4747 async waitForOverviewTab ( ) {
48+ await this . driver . sleep ( 250 )
4849 return this . waitForDisplayed ( OVERVIEW_TAB )
4950 }
5051
@@ -56,27 +57,31 @@ module.exports = class BasePage {
5657 return this . click ( CONNECTIONS_TAB )
5758 }
5859 async waitForConnectionsTab ( ) {
60+ await this . driver . sleep ( 250 )
5961 return this . waitForDisplayed ( CONNECTIONS_TAB )
6062 }
6163
6264 async clickOnAdminTab ( ) {
6365 return this . click ( ADMIN_TAB )
6466 }
6567 async waitForAdminTab ( ) {
68+ await this . driver . sleep ( 250 )
6669 return this . waitForDisplayed ( ADMIN_TAB )
6770 }
6871
6972 async clickOnChannelsTab ( ) {
7073 return this . click ( CHANNELS_TAB )
7174 }
7275 async waitForChannelsTab ( ) {
76+ await this . driver . sleep ( 250 )
7377 return this . waitForDisplayed ( CHANNELS_TAB )
7478 }
7579
7680 async clickOnExchangesTab ( ) {
7781 return this . click ( EXCHANGES_TAB )
7882 }
7983 async waitForExchangesTab ( ) {
84+ await this . driver . sleep ( 250 )
8085 return this . waitForDisplayed ( EXCHANGES_TAB )
8186 }
8287
@@ -179,42 +184,69 @@ module.exports = class BasePage {
179184 }
180185
181186 async waitForLocated ( locator ) {
182- try {
183- return this . driver . wait ( until . elementLocated ( locator ) , this . timeout ,
184- 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] seconds locating ' + locator ,
185- this . polling )
186- } catch ( error ) {
187- if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
188- console . error ( "Failed waitForLocated " + locator + " due to " + error )
189- }
190- throw error
191- }
187+ let attempts = 3
188+ let retry = false
189+ let rethrowError = null
190+ do {
191+ try {
192+ return this . driver . wait ( until . elementLocated ( locator ) , this . timeout ,
193+ 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] seconds locating ' + locator ,
194+ this . polling )
195+ } catch ( error ) {
196+ if ( error . name . includes ( "StaleElementReferenceError" ) ) {
197+ retry = true
198+ } else if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
199+ console . error ( "Failed waitForLocated " + locator + " due to " + error )
200+ retry = false
201+ }
202+ rethrowError = error
203+ }
204+ } while ( retry && -- attempts > 0 )
205+ throw rethrowError
192206 }
193207
194208 async waitForVisible ( element ) {
195- try {
196- return this . driver . wait ( until . elementIsVisible ( element ) , this . timeout ,
197- 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] awaiting till visible ' + element ,
198- this . polling )
199- } catch ( error ) {
200- if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
201- console . error ( "Failed to find visible element " + element + " due to " + error )
209+ let attempts = 3
210+ let retry = false
211+ let rethrowError = null
212+ do {
213+ try {
214+ return this . driver . wait ( until . elementIsVisible ( element ) , this . timeout ,
215+ 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] awaiting till visible ' + element ,
216+ this . polling )
217+ } catch ( error ) {
218+ if ( error . name . includes ( "StaleElementReferenceError" ) ) {
219+ retry = true
220+ } else if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
221+ console . error ( "Failed to find visible element " + element + " due to " + error )
222+ retry = false
223+ }
224+ rethrowError = error
202225 }
203- throw error
204- }
226+ } while ( retry && -- attempts > 0 )
227+ throw rethrowError
205228 }
206229
207230
208231 async waitForDisplayed ( locator ) {
209- if ( this . interactionDelay && this . interactionDelay > 0 ) await this . driver . sleep ( this . interactionDelay )
210- try {
211- return this . waitForVisible ( await this . waitForLocated ( locator ) )
212- } catch ( error ) {
213- if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
214- console . error ( "Failed to waitForDisplayed " + locator + " due to " + error )
215- }
216- throw error
217- }
232+ let attempts = 3
233+ let retry = false
234+ let rethrowError = null
235+ do {
236+ if ( this . interactionDelay && this . interactionDelay > 0 ) await this . driver . sleep ( this . interactionDelay )
237+ try {
238+ return this . waitForVisible ( await this . waitForLocated ( locator ) )
239+ } catch ( error ) {
240+ if ( error . name . includes ( "StaleElementReferenceError" ) ) {
241+ retry = true
242+ } else if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
243+ retry = false
244+ console . error ( "Failed to waitForDisplayed " + locator + " due to " + error )
245+ }
246+ rethrowError = error
247+ }
248+ } while ( retry && -- attempts > 0 )
249+ throw rethrowError
218250 }
219251
220252 async getText ( locator ) {
0 commit comments