import { browser, element, by, protractor, ExpectedConditions as EC, WebElement, error, Key } from 'protractor'; export class LoginPage { //LOGIN PAGE- ELEMENTS cookies = element(by.className('cc-compliance')); loginTitle = element(by.css('h4.m-0')); userName = element(by.name("userNameOrEmailAddress")); password = element(by.name('password')); loginBtn = element(by.buttonText('Log in')); //LOGIN AS TENANT - ELEMENTS change = element(by.css('tenant-change a')); tenantChangeModal = element(by.tagName('tenantchangemodal')); switch = this.tenantChangeModal.element(by.className('kt-switch')); tenancyName = element(by.id('tenancyNameInput')); switchTenantButton = this.tenantChangeModal.element(by.buttonText('Switch to the tenant')); spinner = element(by.xpath('//ngx-spinner/div')); async navigateTo() { return await browser.get('https://sprinthub-sandbox-staging.azureedge.net/'); } async waitForItemToBeVisible(element) { await browser.wait(EC.visibilityOf(element)); } async waitForItemNotToBePresent(element) { await browser.wait(EC.presenceOf(element)); } async allowCookies() { await this.waitForItemToBeVisible(this.cookies); this.cookies.click(); } async loginToHost() { await this.waitForItemToBeVisible(this.userName); await this.userName.sendKeys(''); await this.password.sendKeys(''); await this.loginBtn.click(); } async switchByTenant() { await this.change.click(); await browser.sleep(2000); await this.switch.click(); await this.waitForItemToBeVisible(this.tenancyName); await this.tenancyName.sendKeys('antech'); await this.switchTenantButton.click(); await browser.sleep(3000); await this.waitForItemToBeVisible(this.userName); } async loginUsingUsername() { await this.userName.click(); await this.userName.sendKeys('kat.saquilayan'); await this.password.sendKeys('Anirtak@001'); await this.password.sendKeys(Key.ENTER); } }