import { Button } from '@contour/fet/lib/elements'; import { NodeProfile } from '../../@types/nodeProfile'; import { ContourBasePage } from '../../base/basePage'; import { NavigationBarPage } from './navigationBar.page'; import locator from './userMenu.locator'; export class UserMenuPage extends ContourBasePage { constructor(url?: string) { super(locator, url); } async selectOption(option: string): Promise { await new NavigationBarPage().openUserMenu(); const optionLoc = { logout: this.locators.logout, account: this.locators.account }; await new Button(optionLoc[option]).clickElement(); } async switchIdentity(identity: string, currentProfile?: NodeProfile): Promise { await new NavigationBarPage().openUserMenu(); const targetIdentity = identity ? currentProfile.childIdentities[identity] : currentProfile.displayName; logger.debug(`Switch to identity ${targetIdentity}`); const currentIdentity = await new Button(this.locators.currentIdentity).getText(); if (currentIdentity != targetIdentity) { await new Button(this.locators.identity.replace('##identityName##', identity)).clickElement(); } else { await browser.keys('\uE00C'); } } }