login.page.js 904 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const Page = require('./page');
  2. /**
  3. * sub page containing specific selectors and methods for a specific page
  4. */
  5. class LoginPage extends Page {
  6. /**
  7. * define selectors using getter methods
  8. */
  9. get inputUsername() {
  10. return $('#username');
  11. }
  12. get inputPassword() {
  13. return $('#password');
  14. }
  15. get btnSubmit() {
  16. return $('button[type="submit"]');
  17. }
  18. /**
  19. * a method to encapsule automation code to interact with the page
  20. * e.g. to login using username and password
  21. */
  22. async login (username, password) {
  23. await this.inputUsername.setValue(username);
  24. await this.inputPassword.setValue(password);
  25. await this.btnSubmit.click();
  26. }
  27. /**
  28. * overwrite specific options to adapt it to page object
  29. */
  30. open() {
  31. return super.open('login');
  32. }
  33. }
  34. module.exports = new LoginPage();