Skip to content

Commit 33a0671

Browse files
Slow down interactions
When RabbitMQ is deployed behind a http proxy dyanically generated pages get to the selenium driver slower
1 parent 3b33905 commit 33a0671

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

deps/rabbitmq_management/selenium/test/basic-auth/ac-management.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('management user with vhosts permissions', function () {
4949
await overview.waitForQueuesTab()
5050
assert.ok(!await overview.isPopupWarningDisplayed())
5151
})
52-
it('can access limited options in admin tab', async function () {
52+
it('can access limited options in admin tab', async function () {
5353
await overview.clickOnAdminTab()
5454
await overview.waitForAdminTab()
5555
assert.ok(!await overview.isPopupWarningDisplayed())
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export PUBLIC_RABBITMQ_HOST=proxy:9090
22
export RABBITMQ_HOST_FOR_PROXY=rabbitmq:15672
3+
export SELENIUM_INTERACTION_DELAY=250
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export PUBLIC_RABBITMQ_HOST=localhost:9090
22
export RABBITMQ_HOST_FOR_PROXY=host.docker.internal:15672
3+
export SELENIUM_INTERACTION_DELAY=250

deps/rabbitmq_management/selenium/test/pageobjects/BasePage.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ module.exports = class BasePage {
1717
driver
1818
timeout
1919
polling
20+
interactionDelay
2021

2122
constructor (webdriver) {
2223
this.driver = webdriver
2324
this.timeout = parseInt(process.env.SELENIUM_TIMEOUT) || 1000 // max time waiting to locate an element. Should be less that test timeout
2425
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)
2528
}
2629

2730

@@ -54,10 +57,10 @@ module.exports = class BasePage {
5457
return this.waitForDisplayed(CONNECTIONS_TAB)
5558
}
5659

57-
async clickOnAdminTab () {
60+
async clickOnAdminTab () {
5861
return this.click(ADMIN_TAB)
5962
}
60-
async waitForAdminTab() {
63+
async waitForAdminTab() {
6164
return this.waitForDisplayed(ADMIN_TAB)
6265
}
6366

@@ -71,18 +74,19 @@ module.exports = class BasePage {
7174
async clickOnExchangesTab () {
7275
return this.click(EXCHANGES_TAB)
7376
}
74-
async waitForExchangesTab() {
77+
async waitForExchangesTab() {
7578
return this.waitForDisplayed(EXCHANGES_TAB)
7679
}
7780

7881
async clickOnQueuesTab () {
7982
return this.click(QUEUES_AND_STREAMS_TAB)
8083
}
8184
async waitForQueuesTab() {
85+
await this.driver.sleep(250)
8286
return this.waitForDisplayed(QUEUES_AND_STREAMS_TAB)
8387
}
8488

85-
async clickOnStreamTab () {
89+
async clickOnStreamTab () {
8690
return this.click(STREAM_CONNECTIONS_TAB)
8791
}
8892
async waitForStreamConnectionsTab() {
@@ -153,8 +157,8 @@ module.exports = class BasePage {
153157
async isDisplayed(locator) {
154158
try {
155159
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,
158162
'Timed out after [timeout=' + this.timeout + ';polling=' + this.polling + '] awaiting till visible ' + element,
159163
this.polling / 2)
160164
}catch(error) {
@@ -186,7 +190,13 @@ module.exports = class BasePage {
186190

187191

188192
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+
}
190200
}
191201

192202
async getText (locator) {
@@ -200,6 +210,8 @@ module.exports = class BasePage {
200210
}
201211

202212
async click (locator) {
213+
if (this.interactionDelay) await this.driver.sleep(this.interactionDelay)
214+
203215
const element = await this.waitForDisplayed(locator)
204216
try {
205217
return element.click()

0 commit comments

Comments
 (0)