aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2021-03-20 11:42:08 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2021-03-21 12:24:36 +0900
commitb9cb7fe46f1aede8e0c52a8371b331bcdc90335a (patch)
tree7d1907eeac21fb4190cec7fa19a2884c5ad5eab2
parent8828d175d9754e7afedf1dbb0b7bda2824608b0a (diff)
Fix and stabilize e2e test
-rw-r--r--e2e/lib/Page.ts26
1 files changed, 17 insertions, 9 deletions
diff --git a/e2e/lib/Page.ts b/e2e/lib/Page.ts
index 6531f19..5db97da 100644
--- a/e2e/lib/Page.ts
+++ b/e2e/lib/Page.ts
@@ -15,13 +15,13 @@ export default class Page {
private constructor(private webdriver: WebDriver) {}
static async currentContext(webdriver: WebDriver): Promise<Page> {
- await Page.waitForConsoleLoaded(webdriver);
+ await Page.waitForPageCompleted(webdriver);
return new Page(webdriver);
}
static async navigateTo(webdriver: WebDriver, url: string): Promise<Page> {
await webdriver.navigate().to(url);
- await Page.waitForConsoleLoaded(webdriver);
+ await Page.waitForPageCompleted(webdriver);
return new Page(webdriver);
}
@@ -34,17 +34,20 @@ export default class Page {
async navigateTo(url: string): Promise<Page> {
await this.webdriver.navigate().to(url);
- await Page.waitForConsoleLoaded(this.webdriver);
+ await Page.waitForPageCompleted(this.webdriver);
return new Page(this.webdriver);
}
async showConsole(): Promise<Console> {
- const iframe = this.webdriver.findElement(
- By.css("#vimvixen-console-frame")
- );
+ 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.wait(until.elementLocated(By.css("input")));
return new Console(this.webdriver);
@@ -113,14 +116,19 @@ export default class Page {
return hints;
}
- private static async waitForConsoleLoaded(webdriver: WebDriver) {
+ private static async waitForPageCompleted(webdriver: WebDriver) {
const topFrame = await webdriver.executeScript(() => window.top === window);
if (!topFrame) {
return;
}
+ return this.waitForDocumentCompleted(webdriver);
+ }
+
+ private static async waitForDocumentCompleted(webdriver: WebDriver) {
await webdriver.wait(
- until.elementLocated(By.css("iframe.vimvixen-console-frame"))
+ async () =>
+ (await webdriver.executeScript("return document.readyState")) ===
+ "complete"
);
- await new Promise((resolve) => setTimeout(resolve, 100));
}
}