aboutsummaryrefslogtreecommitdiff
path: root/e2e/lib/JSONOptionPage.ts
blob: 1c2db5bd19d672eec49714c0ef8bfdb28af7b9b5 (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();
  }
}