aboutsummaryrefslogtreecommitdiff
path: root/e2e/lib/Console.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-09-23 16:16:51 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-09-23 16:16:51 +0900
commitd37896887e848818a8d6e426ad6216fa8b331d80 (patch)
treeb3f13487449d029db97f61e62ea353e0f5c5abd1 /e2e/lib/Console.ts
parentb5540dea9a08a258dc0dd19fccfcb2be47b0fc3c (diff)
Make pages as a page object
Diffstat (limited to 'e2e/lib/Console.ts')
-rw-r--r--e2e/lib/Console.ts25
1 files changed, 24 insertions, 1 deletions
diff --git a/e2e/lib/Console.ts b/e2e/lib/Console.ts
index 37b0597..233bf48 100644
--- a/e2e/lib/Console.ts
+++ b/e2e/lib/Console.ts
@@ -1,4 +1,4 @@
-import { WebDriver, By } from 'selenium-webdriver';
+import { WebDriver, By, Key } from 'selenium-webdriver';
export type CompletionItem = {
type: string;
@@ -25,6 +25,21 @@ export class Console {
});
}
+ async execCommand(command: string): Promise<void> {
+ let input = await this.webdriver.findElement(By.css('input.vimvixen-console-command-input'));
+ await input.sendKeys(command, Key.ENTER);
+ }
+
+ async getErrorMessage(): Promise<string> {
+ let p = await this.webdriver.findElement(By.css('.vimvixen-console-error'));
+ return p.getText();
+ }
+
+ async inputKeys(...keys: string[]) {
+ let input = await this.webdriver.findElement(By.css('input'));
+ await input.sendKeys(...keys);
+ }
+
getCompletions(): Promise<CompletionItem[]> {
return this.webdriver.executeScript(() => {
let items = document.querySelectorAll('.vimvixen-console-completion > li');
@@ -46,4 +61,12 @@ export class Console {
return objs;
});
}
+
+ async close(): Promise<void> {
+ let input = await this.webdriver.findElement(By.css('input'));
+ await input.sendKeys(Key.ESCAPE);
+ // TODO remove sleep
+ await new Promise(resolve => setTimeout(resolve, 100));
+ await (this.webdriver.switchTo() as any).parentFrame();
+ }
}