aboutsummaryrefslogtreecommitdiff
path: root/e2e/lib/JSONOptionPage.ts
blob: 0f2b0a7b2edb896132ffc13be49901c956612bb0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Lanthan } from "lanthan";
import { WebDriver, By } from "selenium-webdriver";

export default class JSONOptionPage {
  private webdriver: WebDriver;

  constructor(lanthan: Lanthan) {
    this.webdriver = lanthan.getWebDriver();
  }

  async updateSettings(value: string): Promise<void> {
    const textarea = await this.webdriver.findElement(By.css("textarea"));
    await this.webdriver.executeScript(
      `document.querySelector('textarea').value = '${value}'`
    );
    await textarea.sendKeys(" ");
    await this.webdriver.executeScript(() =>
      document.querySelector("textarea")!.blur()
    );
  }

  async getErrorMessage(): Promise<string> {
    const error = await this.webdriver.findElement(
      By.css(".settings-ui-input-error")
    );
    return error.getText();
  }
}