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}")`;
|
||||
console.log(`🌍 Clicking link: ${linkText}`);
|
||||
|
||||
// Get current URL
|
||||
const currentUrl = world.page.url();
|
||||
|
||||
// Click the link
|
||||
await world.page.click(selector);
|
||||
|
||||
// Wait a bit for navigation to start
|
||||
await world.page.waitForTimeout(500);
|
||||
|
||||
// Check if URL changed
|
||||
const newUrl = world.page.url();
|
||||
if (newUrl === currentUrl) {
|
||||
console.log(`🌍 URL did not change immediately after link click`);
|
||||
// Wait for any navigation to complete
|
||||
// Wait for navigation to complete
|
||||
try {
|
||||
await world.page.waitForLoadState('domcontentloaded', { timeout: 5000 });
|
||||
await world.page.waitForLoadState('networkidle', { timeout: 10000 });
|
||||
} catch {
|
||||
console.log(`🌍 DOMContentLoaded not reached, continuing`);
|
||||
console.log(`🌍 Networkidle not reached, continuing`);
|
||||
}
|
||||
} else {
|
||||
|
||||
const newUrl = world.page.url();
|
||||
console.log(`🌍 Page navigated to: ${newUrl}`);
|
||||
}
|
||||
});
|
||||
|
||||
When('I click the {string} wordmark', async function (wordmarkText: string) {
|
||||
|
||||
Reference in New Issue
Block a user