diff options
Diffstat (limited to 'e2e/lib/Page.ts')
-rw-r--r-- | e2e/lib/Page.ts | 18 |
1 files changed, 18 insertions, 0 deletions
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<Selection> { + const obj = await this.webdriver.executeScript(`return window.getSelection();`) as any; + return { from: obj.anchorOffset, to: obj.focusOffset }; + } + + async clearSelection(): Promise<void> { + await this.webdriver.executeScript(`window.getSelection().removeAllRanges()`); + } + + async switchToTop(): Promise<void> { + await this.webdriver.switchTo().defaultContent(); + } + async waitAndGetHints(): Promise<Hint[]> { await this.webdriver.wait(until.elementsLocated(By.css('.vimvixen-hint'))); |