Skip to content

Commit ad43714

Browse files
committed
Add retry logic to navigateToPIM for improved mobile Chrome reliability
1 parent e59b7f9 commit ad43714

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

automated-testing/pages/DashboardPage.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,30 @@ export class DashboardPage {
5555
async navigateToPIM() {
5656
await this.dashboardTitle.waitFor({ state: 'visible', timeout: 60000 });
5757
await this.ensureMenuVisible();
58-
59-
// Wait for PIM menu to be stable and ready
60-
await this.pimMenu.waitFor({ state: 'attached', timeout: 15000 });
58+
59+
// Ensure the PIM menu is attached and visible with longer timeouts for mobile
60+
await this.pimMenu.waitFor({ state: 'attached', timeout: 20000 });
6161
await this.pimMenu.scrollIntoViewIfNeeded();
62-
await this.pimMenu.waitFor({ state: 'visible', timeout: 60000 });
63-
64-
// Wait for navigation to complete after clicking
65-
await Promise.all([
66-
this.page.waitForURL(/.*pim/, { timeout: 60000 }),
67-
this.pimMenu.click({ force: true })
68-
]);
69-
70-
// Wait for PIM page to load
71-
await this.page.getByRole('heading', { name: 'PIM' }).waitFor({ state: 'visible', timeout: 60000 });
62+
63+
// Try up to 3 times in case of menu animation delays (especially in mobile)
64+
for (let attempt = 0; attempt < 3; attempt++) {
65+
try {
66+
await this.pimMenu.waitFor({ state: 'visible', timeout: 20000 });
67+
await Promise.all([
68+
this.page.waitForURL(/.*pim/, { timeout: 60000 }),
69+
this.pimMenu.click({ force: true }),
70+
]);
71+
// Confirm heading appears
72+
await this.page.getByRole('heading', { name: 'PIM' }).waitFor({ state: 'visible', timeout: 60000 });
73+
return;
74+
} catch (e) {
75+
// If click fails, try to open hamburger menu again and retry
76+
await this.ensureMenuVisible();
77+
// Small wait before retrying
78+
await this.page.waitForTimeout(1000);
79+
}
80+
}
81+
throw new Error('Could not navigate to PIM menu in mobile view after several attempts');
7282
}
7383

7484
async navigateToLeave() {

0 commit comments

Comments
 (0)