aboutsummaryrefslogtreecommitdiff
path: root/e2e/lib/JSONOptionPage.ts
blob: d6ed7eecbf187bb26907a46df255c4a01831774a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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();
  }
}