From b89a87220f93844a95266638b9eb01ec74732fb0 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 21 Mar 2021 16:52:38 +0900 Subject: stabilize e2e --- e2e/lib/Page.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/e2e/lib/Page.ts b/e2e/lib/Page.ts index 5db97da..46d67b0 100644 --- a/e2e/lib/Page.ts +++ b/e2e/lib/Page.ts @@ -35,20 +35,18 @@ export default class Page { async navigateTo(url: string): Promise { await this.webdriver.navigate().to(url); await Page.waitForPageCompleted(this.webdriver); + + await new Promise((resolve) => setTimeout(resolve, 200)); + return new Page(this.webdriver); } async showConsole(): Promise { - await this.webdriver.switchTo().frame(0); - await Page.waitForDocumentCompleted(this.webdriver); - await this.webdriver.switchTo().parentFrame(); - await new Promise((resolve) => setTimeout(resolve, 100)); - await this.sendKeys(":"); const iframe = this.webdriver.findElement(By.id("vimvixen-console-frame")); await this.webdriver.wait(until.elementIsVisible(iframe)); - await this.webdriver.switchTo().frame(0); + await this.webdriver.switchTo().frame(iframe); await this.webdriver.wait(until.elementLocated(By.css("input"))); return new Console(this.webdriver); } @@ -57,9 +55,8 @@ export default class Page { const iframe = this.webdriver.findElement( By.css("#vimvixen-console-frame") ); - await this.webdriver.wait(until.elementIsVisible(iframe)); - await this.webdriver.switchTo().frame(0); + await this.webdriver.switchTo().frame(iframe); return new Console(this.webdriver); } @@ -116,12 +113,19 @@ export default class Page { return hints; } - private static async waitForPageCompleted(webdriver: WebDriver) { + private static async waitForPageCompleted( + webdriver: WebDriver + ): Promise { + this.waitForDocumentCompleted(webdriver); + const topFrame = await webdriver.executeScript(() => window.top === window); if (!topFrame) { return; } - return this.waitForDocumentCompleted(webdriver); + await webdriver.wait(until.elementLocated(By.id("vimvixen-console-frame"))); + await webdriver.switchTo().frame(0); + await Page.waitForDocumentCompleted(webdriver); + await webdriver.switchTo().parentFrame(); } private static async waitForDocumentCompleted(webdriver: WebDriver) { -- cgit v1.2.3