diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-02-22 22:03:58 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-22 22:03:58 +0900 |
commit | 4c3be5b014fe61a608b4f4aa69e40e3575d63b68 (patch) | |
tree | e061c016ffc8efabccd647b4ab9ef07fe77c6434 /e2e/lib/Page.ts | |
parent | 78c87e895e6ac50b6c6d83d4cc77bfd8017e5384 (diff) | |
parent | 2f0cea1debd2b37b51e31adb8bf16d914655171a (diff) |
Merge pull request #714 from ueokande/qa-0.27
QA 0.27
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'))); |