From 8e5e6bfcdd45f9e2cd572e02eb4fad527a0094df Mon Sep 17 00:00:00 2001 From: Shin'ya UEOKA Date: Wed, 25 Sep 2019 03:22:11 +0000 Subject: [PATCH] Fix form option page --- e2e/lib/FormOptionPage.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/e2e/lib/FormOptionPage.ts b/e2e/lib/FormOptionPage.ts index c8ff341..c49a44f 100644 --- a/e2e/lib/FormOptionPage.ts +++ b/e2e/lib/FormOptionPage.ts @@ -1,5 +1,5 @@ import { Lanthan } from 'lanthan'; -import { WebDriver, By } from 'selenium-webdriver'; +import { WebDriver, By, until } from 'selenium-webdriver'; export default class FormOptionPage { private webdriver: WebDriver; @@ -9,7 +9,7 @@ export default class FormOptionPage { } async setBlacklist(nth: number, value: string): Promise { - let selector = '.form-blacklist-form .column-url'; + let selector = '.form-blacklist-form-row > .column-url'; let inputs = await this.webdriver.findElements(By.css(selector)); if (inputs.length <= nth) { 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) { - 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)); if (inputs.length <= nth) { 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 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)); if (inputs.length <= nth) { throw new RangeError('Index out of range to set a search engine') @@ -37,12 +37,14 @@ export default class FormOptionPage { } async addBlacklist(): Promise { + 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')) 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 { - 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) { throw new RangeError('Index out of range to remove blacklist') } @@ -50,12 +52,14 @@ export default class FormOptionPage { } async addSearchEngine(): Promise { - 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 this.webdriver.wait(until.elementLocated(By.css(`.form-search-form-row:nth-child(${rows.length + 1})`))); } async setDefaultSearchEngine(nth: number): Promise { - 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) { throw new RangeError('Index out of range to set a default search engine'); }