2023-02-15 21:29:55 +08:00
|
|
|
const { By, Key, until, Builder } = require('selenium-webdriver')
|
|
|
|
|
|
|
|
const AdminTab = require('./AdminTab')
|
|
|
|
|
2025-05-01 00:08:58 +08:00
|
|
|
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')
|
2025-05-01 00:08:58 +08:00
|
|
|
const TABLE_SECTION = By.css('div#main table.list')
|
2023-02-15 21:29:55 +08:00
|
|
|
|
|
|
|
module.exports = class VhostsAdminTab extends AdminTab {
|
|
|
|
async isLoaded () {
|
2025-05-01 00:08:58 +08:00
|
|
|
await 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)
|
|
|
|
if (regex) {
|
|
|
|
await this.click(CHECKBOX_REGEX)
|
|
|
|
}
|
|
|
|
await this.driver.sleep(250)
|
2023-02-21 20:07:37 +08:00
|
|
|
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 === "/" ) return link.click()
|
|
|
|
}
|
|
|
|
throw "Vhost " + vhost + " not found"
|
|
|
|
}
|
2025-05-01 00:08:58 +08:00
|
|
|
async getVhostsTable(firstNColumns) {
|
|
|
|
return this.getTable(TABLE_SECTION, firstNColumns)
|
|
|
|
}
|
2025-05-02 19:05:25 +08:00
|
|
|
|
2023-02-15 21:29:55 +08:00
|
|
|
}
|