@@ -17,11 +17,14 @@ module.exports = class BasePage {
17
17
driver
18
18
timeout
19
19
polling
20
+ interactionDelay
20
21
21
22
constructor ( webdriver ) {
22
23
this . driver = webdriver
23
24
this . timeout = parseInt ( process . env . SELENIUM_TIMEOUT ) || 1000 // max time waiting to locate an element. Should be less that test timeout
24
25
this . polling = parseInt ( process . env . SELENIUM_POLLING ) || 500 // how frequent selenium searches for an element
26
+ this . interactionDelay = parseInt ( process . env . SELENIUM_INTERACTION_DELAY ) || 0 // slow down interactions (when rabbit is behind a http proxy)
27
+ console . log ( "Interaction Delay : " + this . interactionDelay )
25
28
}
26
29
27
30
@@ -54,10 +57,10 @@ module.exports = class BasePage {
54
57
return this . waitForDisplayed ( CONNECTIONS_TAB )
55
58
}
56
59
57
- async clickOnAdminTab ( ) {
60
+ async clickOnAdminTab ( ) {
58
61
return this . click ( ADMIN_TAB )
59
62
}
60
- async waitForAdminTab ( ) {
63
+ async waitForAdminTab ( ) {
61
64
return this . waitForDisplayed ( ADMIN_TAB )
62
65
}
63
66
@@ -71,18 +74,19 @@ module.exports = class BasePage {
71
74
async clickOnExchangesTab ( ) {
72
75
return this . click ( EXCHANGES_TAB )
73
76
}
74
- async waitForExchangesTab ( ) {
77
+ async waitForExchangesTab ( ) {
75
78
return this . waitForDisplayed ( EXCHANGES_TAB )
76
79
}
77
80
78
81
async clickOnQueuesTab ( ) {
79
82
return this . click ( QUEUES_AND_STREAMS_TAB )
80
83
}
81
84
async waitForQueuesTab ( ) {
85
+ await this . driver . sleep ( 250 )
82
86
return this . waitForDisplayed ( QUEUES_AND_STREAMS_TAB )
83
87
}
84
88
85
- async clickOnStreamTab ( ) {
89
+ async clickOnStreamTab ( ) {
86
90
return this . click ( STREAM_CONNECTIONS_TAB )
87
91
}
88
92
async waitForStreamConnectionsTab ( ) {
@@ -153,8 +157,8 @@ module.exports = class BasePage {
153
157
async isDisplayed ( locator ) {
154
158
try {
155
159
element = await driver . findElement ( locator )
156
- console . log ( "element:" + element )
157
- return this . driver . wait ( until . elementIsVisible ( element ) , this . timeout / 2 ,
160
+
161
+ return this . driver . wait ( until . elementIsVisible ( element ) , this . timeout ,
158
162
'Timed out after [timeout=' + this . timeout + ';polling=' + this . polling + '] awaiting till visible ' + element ,
159
163
this . polling / 2 )
160
164
} catch ( error ) {
@@ -186,7 +190,13 @@ module.exports = class BasePage {
186
190
187
191
188
192
async waitForDisplayed ( locator ) {
189
- return this . waitForVisible ( await this . waitForLocated ( locator ) )
193
+ if ( this . interactionDelay && this . interactionDelay > 0 ) await this . driver . sleep ( this . interactionDelay )
194
+ try {
195
+ return this . waitForVisible ( await this . waitForLocated ( locator ) )
196
+ } catch ( error ) {
197
+ console . error ( "Failed to waitForDisplayed for locator " + locator )
198
+ throw error
199
+ }
190
200
}
191
201
192
202
async getText ( locator ) {
@@ -200,6 +210,8 @@ module.exports = class BasePage {
200
210
}
201
211
202
212
async click ( locator ) {
213
+ if ( this . interactionDelay ) await this . driver . sleep ( this . interactionDelay )
214
+
203
215
const element = await this . waitForDisplayed ( locator )
204
216
try {
205
217
return element . click ( )
0 commit comments