import {browser, by, element} from 'protractor';

export class UnitPo {
  async clickByXpath(xPath: string): Promise<unknown> {
    return element(by.xpath(xPath)).click();
  }

  async clickById(id: string): Promise<unknown> {
    return element(by.id(id)).click();
  }

  async setDateInXpath(xPath: string): Promise<unknown> {
    element(by.xpath(xPath)).click();
    await browser.sleep(500);
    element(by.className('p-datepicker-prev-icon')).click();
    await browser.sleep(500);
    return element(by.xpath('//td[contains(@class, \'ng-star-inserted\') and not(contains(@class, \'p-datepicker-other-month\'))]'))
      .click();
  }

  async selectSensor(selectSensorId: string): Promise<unknown> {
    return element(by.id(selectSensorId)).click();
  }
}
