aboutsummaryrefslogtreecommitdiff
path: root/e2e/lib/JSONOptionPage.ts
blob: ac1ae3dc37190fecead84ce645b96b0075601103 (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> {
    let 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> {
    let error = await this.webdriver.findElement(By.css('.settings-ui-input-error'));
    return error.getText();
  }
}