rabbitmq-server/selenium/test/pageobjects/VhostsAdminTab.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-02-15 21:29:55 +08:00
const { By, Key, until, Builder } = require('selenium-webdriver')
const AdminTab = require('./AdminTab')
const MAIN_SECTION = By.css('div#main div#vhosts.section')
2023-02-15 21:29:55 +08:00
const SELECTED_VHOSTS_ON_RHM = By.css('div#rhs ul li a[href="#/vhosts"]')
const FILTER_VHOST = By.css('div#main div.filter input#filter')
const CHECKBOX_REGEX = By.css('div#main div.filter input#filter-regex-mode')
const VHOSTS_TABLE_ROWS = By.css('div#main table.list tbody tr')
const TABLE_SECTION = By.css('div#main div#vhosts.section table.list')
2023-02-15 21:29:55 +08:00
module.exports = class VhostsAdminTab extends AdminTab {
async isLoaded () {
return this.waitForDisplayed(MAIN_SECTION)
2023-02-15 21:29:55 +08:00
}
async searchForVhosts(vhost, regex = false) {
await this.sendKeys(FILTER_VHOST, vhost)
//await this.sendKeys(FILTER_VHOST, Key.RETURN)
2023-02-15 21:29:55 +08:00
if (regex) {
await this.click(CHECKBOX_REGEX)
}
await this.driver.sleep(250)
return this.waitForDisplayed(VHOSTS_TABLE_ROWS)
2023-02-15 21:29:55 +08:00
}
async hasVhosts(vhost, regex = false) {
return await this.searchForVhosts(vhost, regex) != undefined
}
async clickOnVhost(vhost_rows, vhost) {
2024-02-10 00:22:17 +08:00
const links = await vhost_rows.findElements(By.css("td a"))
2023-02-15 21:29:55 +08:00
for (let link of links) {
let text = await link.getText()
if ( text === vhost ) return link.click()
2023-02-15 21:29:55 +08:00
}
throw "Vhost " + vhost + " not found"
}
async getVhostsTable(firstNColumns) {
return this.getTable(TABLE_SECTION, firstNColumns)
}
2023-02-15 21:29:55 +08:00
}