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

export class LoginPo {
  async navigateTo(): Promise<unknown> {
    return browser.get(browser.baseUrl);
  }

  async getTitleText(): Promise<string> {
    return element(by.className('login-heading')).getText();
  }

  async processForm(): Promise<unknown> {
    element(by.id('username')).sendKeys('testins');
    element(by.id('password')).sendKeys('insert');
    return element(by.id('loginButton')).click();
  }

  async dashboardPresent(): Promise<unknown> {
    return element(by.className('dashboard')).isPresent();
  }

  async loggedUser(): Promise<string> {
    return element(by.id('loggedUser')).getText();
  }

  async logout(): Promise<unknown> {
    return element(by.id('logOut')).click();
  }
}
