From 674ca5988e32780f02c3c48ce9d677a29dc470f1 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sat, 22 Feb 2020 17:25:13 +0900 Subject: Add find test cases --- e2e/lib/Page.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'e2e/lib/Page.ts') diff --git a/e2e/lib/Page.ts b/e2e/lib/Page.ts index ad3f454..31605cb 100644 --- a/e2e/lib/Page.ts +++ b/e2e/lib/Page.ts @@ -6,6 +6,11 @@ type Hint = { text: string, }; +type Selection = { + from: number, + to: number, +}; + export default class Page { private constructor(private webdriver: WebDriver) { } @@ -66,6 +71,19 @@ export default class Page { return this.webdriver.executeScript(() => window.document.documentElement.clientHeight); } + async getSelection(): Promise { + const obj = await this.webdriver.executeScript(`return window.getSelection();`) as any; + return { from: obj.anchorOffset, to: obj.focusOffset }; + } + + async clearSelection(): Promise { + await this.webdriver.executeScript(`window.getSelection().removeAllRanges()`); + } + + async switchToTop(): Promise { + await this.webdriver.switchTo().defaultContent(); + } + async waitAndGetHints(): Promise { await this.webdriver.wait(until.elementsLocated(By.css('.vimvixen-hint'))); -- cgit v1.2.3