'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var LoginForm = function () {
  function LoginForm() {
    _classCallCheck(this, LoginForm);

    this.selector = '.cspace-ui-LoginForm--common';
  }

  _createClass(LoginForm, [{
    key: 'getUsernameInput',
    value: function getUsernameInput() {
      return browser.$(this.selector).$('input[name="username"]');
    }
  }, {
    key: 'getPasswordInput',
    value: function getPasswordInput() {
      return browser.$(this.selector).$('input[name="password"]');
    }
  }, {
    key: 'getSubmitButton',
    value: function getSubmitButton() {
      return browser.$(this.selector).$('button[type="submit"]');
    }
  }, {
    key: 'getPromptText',
    value: function getPromptText() {
      return browser.$(this.selector).$('p').getText();
    }
  }, {
    key: 'isVisible',
    value: function isVisible() {
      return browser.isVisible(this.selector);
    }
  }, {
    key: 'setUsername',
    value: function setUsername(username) {
      this.getUsernameInput().setValue(username);

      return this;
    }
  }, {
    key: 'setPassword',
    value: function setPassword(password) {
      this.getPasswordInput().setValue(password);

      return this;
    }
  }, {
    key: 'clickSubmitButton',
    value: function clickSubmitButton() {
      this.getSubmitButton().click();

      return this;
    }
  }, {
    key: 'enterUsernameInput',
    value: function enterUsernameInput() {
      browser.elementIdValue(this.getUsernameInput().value.ELEMENT, 'Enter');

      return this;
    }
  }, {
    key: 'enterPasswordInput',
    value: function enterPasswordInput() {
      browser.elementIdValue(this.getPasswordInput().value.ELEMENT, 'Enter');

      return this;
    }
  }, {
    key: 'login',
    value: function login(username, password) {
      this.setUsername(username).setPassword([password, 'Enter']);

      return this;
    }
  }]);

  return LoginForm;
}();

exports.default = LoginForm;