@@ -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
@@ -180,42 +185,69 @@ module.exports = class BasePage {
180185 }
181186
182187 async waitForLocated ( locator ) {
183- try {
184- return this . driver . wait ( until . elementLocated ( locator ) , this . timeout ,
185- 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] seconds locating ' + locator ,
186- this . polling )
187- } catch ( error ) {
188- if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
189- console . error ( "Failed waitForLocated " + locator + " due to " + error )
190- }
191- throw error
192- }
188+ let attempts = 3
189+ let retry = false
190+ let rethrowError = null
191+ do {
192+ try {
193+ return this . driver . wait ( until . elementLocated ( locator ) , this . timeout ,
194+ 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] seconds locating ' + locator ,
195+ this . polling )
196+ } catch ( error ) {
197+ if ( error . name . includes ( "StaleElementReferenceError" ) ) {
198+ retry = true
199+ } else if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
200+ console . error ( "Failed waitForLocated " + locator + " due to " + error )
201+ retry = false
202+ }
203+ rethrowError = error
204+ }
205+ } while ( retry && -- attempts > 0 )
206+ throw rethrowError
193207 }
194208
195209 async waitForVisible ( element ) {
196- try {
197- return this . driver . wait ( until . elementIsVisible ( element ) , this . timeout ,
198- 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] awaiting till visible ' + element ,
199- this . polling )
200- } catch ( error ) {
201- if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
202- console . error ( "Failed to find visible element " + element + " due to " + error )
210+ let attempts = 3
211+ let retry = false
212+ let rethrowError = null
213+ do {
214+ try {
215+ return this . driver . wait ( until . elementIsVisible ( element ) , this . timeout ,
216+ 'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] awaiting till visible ' + element ,
217+ this . polling )
218+ } catch ( error ) {
219+ if ( error . name . includes ( "StaleElementReferenceError" ) ) {
220+ retry = true
221+ } else if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
222+ console . error ( "Failed to find visible element " + element + " due to " + error )
223+ retry = false
224+ }
225+ rethrowError = error
203226 }
204- throw error
205- }
227+ } while ( retry && -- attempts > 0 )
228+ throw rethrowError
206229 }
207230
208231
209232 async waitForDisplayed ( locator ) {
210- if ( this . interactionDelay && this . interactionDelay > 0 ) await this . driver . sleep ( this . interactionDelay )
211- try {
212- return this . waitForVisible ( await this . waitForLocated ( locator ) )
213- } catch ( error ) {
214- if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
215- console . error ( "Failed to waitForDisplayed " + locator + " due to " + error )
216- }
217- throw error
218- }
233+ let attempts = 3
234+ let retry = false
235+ let rethrowError = null
236+ do {
237+ if ( this . interactionDelay && this . interactionDelay > 0 ) await this . driver . sleep ( this . interactionDelay )
238+ try {
239+ return this . waitForVisible ( await this . waitForLocated ( locator ) )
240+ } catch ( error ) {
241+ if ( error . name . includes ( "StaleElementReferenceError" ) ) {
242+ retry = true
243+ } else if ( ! error . name . includes ( "NoSuchSessionError" ) ) {
244+ retry = false
245+ console . error ( "Failed to waitForDisplayed " + locator + " due to " + error )
246+ }
247+ rethrowError = error
248+ }
249+ } while ( retry && -- attempts > 0 )
250+ throw rethrowError
219251 }
220252
221253 async getText ( locator ) {
0 commit comments