Unable to click on a dropdown link: ERRO[0057] Uncaught (in promise) waiting for navigation

I have a scenario where I need to click on a menu item ‘Account’ and in the drop-down click on the button ‘Settings’. Using the below code option but getting the error: ERRO[0057] Uncaught (in promise) waiting for navigation: timed out after 30s executor=shared-iterations scenario=ui

Version: k6 v0.46.0 (2023-08-14T13:23:26+0000/v0.46.0-0-gcbd9e9ad, go1.20.7, windows/amd64)

The same code works for me in Playwright without even using wait.

Code:

//Click on the Account Menu bar item -  THIS WORKS
const myAccountButton = page.locator('[id="myAccount"]');
await Promise.all([page.waitForNavigation(), myAccountButton.click(),]);

//Click on the Settings drop down link - TRIED VARIOUS //LOCATORS
// const accountSettingsButton = page.locator('[id="accountSettings"]');
// const accountSettingsButton = page.locator('a[href="/account"]');
// const accountSettingsButton = page.locator('#myAccount_1077722406 > a.jut__DropdownMenu__link.jut__NavBarItem__active');
// const accountSettingsButton = page.locator('//div[@id="myAccount"]/div/a[1]');
const accountSettingsButton = page.locator('//div[@id=\'myAccount\']/div/a[1]');
await page.waitForSelector(accountSettingsButton, { state: 'visible',});
await Promise.all([page.waitForNavigation({
            timeout: 30000,
            waitUntil: 'domcontentloaded',
            }),
            accountSettingsButton.click(),
        ]);

Hi @anilkothacheruvu,

Could you remove the options from the second waitForNavigation and try again? Like this:

await Promise.all([page.waitForNavigation(), accountSettingsButton.click()]);

Please send us a simple HTML and a test script if what I suggest doesn’t work.

Thanks!

Hey mate, Thanks for the quick response. Your response gave me an idea that as my action is related to clicking an item in a menu probably I don’t need a waitForNaviagtion(). So I removed it when I click the menu item and just used

await Promise.all([myAccountButton.click(),]);

It worked for me, so probably the uncaught promise is from the waitForNavigation where all along I was thinking it was my locator. Posting it here just in case if it helps someone.

Thanks a lot.

1 Like

Nice to see that you solved the issue :+1: