import { Component } from '../component' ; import { typeText } from '../../utilities/utils' ; export class LoginComponent extends Component { usernameInput = this . byCss ( 'input#username' ) ; passwordInput = this . byCss ( 'input#password' ) ; submitButton = this . byCss ( 'button#login-button' ) ; errorMessage = this . byCss ( '.adf-login-error-message' ) ; copyright = this . byCss ( '.adf-copyright' ) ; passwordVisibility = this . byCss ( '.adf-login-password-icon' ) ; constructor ( ancestor ? ) { super ( 'adf-login' , ancestor ) ; } async enterUsername ( username ) { await typeText ( this . usernameInput , username ) ; } async enterPassword ( password ) { await typeText ( this . passwordInput , password ) ; } async enterCredentials ( username , password ) { await this . enterUsername ( username ) ; await this . enterPassword ( password ) ; } private async getPasswordVisibility ( ) { const text = await this . passwordVisibility . getText ( ) ; return text . endsWith ( 'visibility' ) ; } async isPasswordDisplayed ( ) { const type = await this . passwordInput . getAttribute ( 'type' ) ; if ( type === 'text' ) { return true ; } else { if ( type === 'password' ) { return false ; } } return false ; } async isPasswordHidden ( ) { return ! ( await this . getPasswordVisibility ( ) ) ; } }