|
|
@ -1,5 +1,5 @@ |
|
|
|
import { Lanthan } from 'lanthan'; |
|
|
|
import { Lanthan } from 'lanthan'; |
|
|
|
import { WebDriver, By } from 'selenium-webdriver'; |
|
|
|
import { WebDriver, By, until } from 'selenium-webdriver'; |
|
|
|
|
|
|
|
|
|
|
|
export default class FormOptionPage { |
|
|
|
export default class FormOptionPage { |
|
|
|
private webdriver: WebDriver; |
|
|
|
private webdriver: WebDriver; |
|
|
@ -9,7 +9,7 @@ export default class FormOptionPage { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async setBlacklist(nth: number, value: string): Promise<void> { |
|
|
|
async setBlacklist(nth: number, value: string): Promise<void> { |
|
|
|
let selector = '.form-blacklist-form .column-url'; |
|
|
|
let selector = '.form-blacklist-form-row > .column-url'; |
|
|
|
let inputs = await this.webdriver.findElements(By.css(selector)); |
|
|
|
let inputs = await this.webdriver.findElements(By.css(selector)); |
|
|
|
if (inputs.length <= nth) { |
|
|
|
if (inputs.length <= nth) { |
|
|
|
throw new RangeError('Index out of range to set a blacklist') |
|
|
|
throw new RangeError('Index out of range to set a blacklist') |
|
|
@ -19,7 +19,7 @@ export default class FormOptionPage { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async setSearchEngine(nth: number, name: string, url: string) { |
|
|
|
async setSearchEngine(nth: number, name: string, url: string) { |
|
|
|
let selector = '.form-search-form input.column-name'; |
|
|
|
let selector = '.form-search-form-row > .column-name'; |
|
|
|
let inputs = await this.webdriver.findElements(By.css(selector)); |
|
|
|
let inputs = await this.webdriver.findElements(By.css(selector)); |
|
|
|
if (inputs.length <= nth) { |
|
|
|
if (inputs.length <= nth) { |
|
|
|
throw new RangeError('Index out of range to set a search engine') |
|
|
|
throw new RangeError('Index out of range to set a search engine') |
|
|
@ -27,7 +27,7 @@ export default class FormOptionPage { |
|
|
|
await inputs[nth].sendKeys(name); |
|
|
|
await inputs[nth].sendKeys(name); |
|
|
|
await this.webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`); |
|
|
|
await this.webdriver.executeScript(`document.querySelectorAll('${selector}')[${nth}].blur()`); |
|
|
|
|
|
|
|
|
|
|
|
selector = '.form-search-form input.column-url'; |
|
|
|
selector = '.form-search-form-row > .column-url'; |
|
|
|
inputs = await this.webdriver.findElements(By.css(selector)); |
|
|
|
inputs = await this.webdriver.findElements(By.css(selector)); |
|
|
|
if (inputs.length <= nth) { |
|
|
|
if (inputs.length <= nth) { |
|
|
|
throw new RangeError('Index out of range to set a search engine') |
|
|
|
throw new RangeError('Index out of range to set a search engine') |
|
|
@ -37,12 +37,14 @@ export default class FormOptionPage { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async addBlacklist(): Promise<void> { |
|
|
|
async addBlacklist(): Promise<void> { |
|
|
|
|
|
|
|
let rows = await this.webdriver.findElements(By.css(`.form-blacklist-form-row`)); |
|
|
|
let button = await this.webdriver.findElement(By.css('.form-blacklist-form .ui-add-button')) |
|
|
|
let button = await this.webdriver.findElement(By.css('.form-blacklist-form .ui-add-button')) |
|
|
|
await button.click(); |
|
|
|
await button.click(); |
|
|
|
|
|
|
|
await this.webdriver.wait(until.elementLocated(By.css(`.form-blacklist-form-row:nth-child(${rows.length + 1})`))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async removeBlackList(nth: number): Promise<void> { |
|
|
|
async removeBlackList(nth: number): Promise<void> { |
|
|
|
let buttons = await this.webdriver.findElements(By.css('.form-blacklist-form .ui-delete-button')); |
|
|
|
let buttons = await this.webdriver.findElements(By.css('.form-blacklist-form-row .ui-delete-button')); |
|
|
|
if (buttons.length <= nth) { |
|
|
|
if (buttons.length <= nth) { |
|
|
|
throw new RangeError('Index out of range to remove blacklist') |
|
|
|
throw new RangeError('Index out of range to remove blacklist') |
|
|
|
} |
|
|
|
} |
|
|
@ -50,12 +52,14 @@ export default class FormOptionPage { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async addSearchEngine(): Promise<void> { |
|
|
|
async addSearchEngine(): Promise<void> { |
|
|
|
let button = await this.webdriver.findElement(By.css('.form-search-form .ui-add-button')) |
|
|
|
let rows = await this.webdriver.findElements(By.css(`.form-search-form-row > .column-name`)); |
|
|
|
|
|
|
|
let button = await this.webdriver.findElement(By.css('.form-search-form > .ui-add-button')) |
|
|
|
await button.click(); |
|
|
|
await button.click(); |
|
|
|
|
|
|
|
await this.webdriver.wait(until.elementLocated(By.css(`.form-search-form-row:nth-child(${rows.length + 1})`))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async setDefaultSearchEngine(nth: number): Promise<void> { |
|
|
|
async setDefaultSearchEngine(nth: number): Promise<void> { |
|
|
|
let radios = await this.webdriver.findElements(By.css('.form-search-form input[type=radio]')); |
|
|
|
let radios = await this.webdriver.findElements(By.css('.form-search-form-row input[type=radio]')); |
|
|
|
if (radios.length <= nth) { |
|
|
|
if (radios.length <= nth) { |
|
|
|
throw new RangeError('Index out of range to set a default search engine'); |
|
|
|
throw new RangeError('Index out of range to set a default search engine'); |
|
|
|
} |
|
|
|
} |
|
|
|