Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/pages/FO/FOBasePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export default class FOBasePage extends CommonPage implements FOBasePagePageInte

private readonly accountLink: string;

protected loginForm: string;

private readonly h2AccountLink: string;

private readonly logoutLink: string;
Expand Down Expand Up @@ -219,6 +221,7 @@ export default class FOBasePage extends CommonPage implements FOBasePagePageInte
this.userInfoLink = '#_desktop_user_info';
this.h2UserInfoLink = '.ps-customersignin a.header-block__action-btn';
this.accountLink = `${this.userInfoLink} .user-info a[href*="my-account"]`;
this.loginForm = '#login-form';
this.h2AccountLink = '.ps-customersignin a[href*="my-account"]';
this.logoutLink = `${this.userInfoLink} .user-info a[href*="?mylogout="]`;
this.h2LogoutLink = '.ps-customersignin a[href*="?mylogout="]';
Expand Down Expand Up @@ -424,6 +427,13 @@ export default class FOBasePage extends CommonPage implements FOBasePagePageInte
* @return {Promise<void>}
*/
async goToLoginPage(page: Page): Promise<void> {
// If we are already on the login page, the header sign-in link points to the current
// URL. clickAndWaitForURL waits for the URL to *change*, so it would hang until timeout.
// There is nothing to navigate to in that case.
if (await this.elementVisible(page, this.loginForm, 1000)) {
return;
}

if (this.theme === 'hummingbird') {
if (await page.locator(this.h2UserInfoLink).count() > 0) {
await this.clickAndWaitForURL(page, this.h2UserInfoLink);
Expand Down
Loading