fix: improve link click handling to wait for networkidle
This ensures proper navigation waits for links that trigger client-side routing
This commit is contained in:
@@ -180,28 +180,18 @@ When('I click the {string} link', async function (linkText: string) {
|
|||||||
const selector = `a:has-text("${linkText}")`;
|
const selector = `a:has-text("${linkText}")`;
|
||||||
console.log(`🌍 Clicking link: ${linkText}`);
|
console.log(`🌍 Clicking link: ${linkText}`);
|
||||||
|
|
||||||
// Get current URL
|
|
||||||
const currentUrl = world.page.url();
|
|
||||||
|
|
||||||
// Click the link
|
// Click the link
|
||||||
await world.page.click(selector);
|
await world.page.click(selector);
|
||||||
|
|
||||||
// Wait a bit for navigation to start
|
// Wait for navigation to complete
|
||||||
await world.page.waitForTimeout(500);
|
try {
|
||||||
|
await world.page.waitForLoadState('networkidle', { timeout: 10000 });
|
||||||
// Check if URL changed
|
} catch {
|
||||||
const newUrl = world.page.url();
|
console.log(`🌍 Networkidle not reached, continuing`);
|
||||||
if (newUrl === currentUrl) {
|
|
||||||
console.log(`🌍 URL did not change immediately after link click`);
|
|
||||||
// Wait for any navigation to complete
|
|
||||||
try {
|
|
||||||
await world.page.waitForLoadState('domcontentloaded', { timeout: 5000 });
|
|
||||||
} catch {
|
|
||||||
console.log(`🌍 DOMContentLoaded not reached, continuing`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log(`🌍 Page navigated to: ${newUrl}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const newUrl = world.page.url();
|
||||||
|
console.log(`🌍 Page navigated to: ${newUrl}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
When('I click the {string} wordmark', async function (wordmarkText: string) {
|
When('I click the {string} wordmark', async function (wordmarkText: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user