diff options
Diffstat (limited to 'e2e/lib')
-rw-r--r-- | e2e/lib/Console.ts | 5 | ||||
-rw-r--r-- | e2e/lib/Page.ts | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/e2e/lib/Console.ts b/e2e/lib/Console.ts index 6a82387..e3bd2d6 100644 --- a/e2e/lib/Console.ts +++ b/e2e/lib/Console.ts @@ -35,6 +35,11 @@ export class Console { return p.getText(); } + async getInformationMessage(): Promise<string> { + const p = await this.webdriver.findElement(By.css('.vimvixen-console-info')); + return p.getText(); + } + async inputKeys(...keys: string[]) { const input = await this.webdriver.findElement(By.css('input')); await input.sendKeys(...keys); 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'))); |