How can I find where this error originates in my script

When I ramp up I get lots of the following:

time="2024-11-18T01:41:35+01:00" level=warning msg="failed to hide page: evaluating JS: Cannot find context with specified id" category="Page:Close" elapsed="0 ms" source=browser
time="2024-11-18T01:41:35+01:00" level=warning msg="failed to hide page: evaluating JS: Cannot find context with specified id" category="Page:Close" elapsed="0 ms" source=browser
time="2024-11-18T01:41:35+01:00" level=warning msg="failed to hide page: evaluating JS: Cannot find context with specified id" category="Page:Close" elapsed="0 ms" source=browser
time="2024-11-18T01:41:35+01:00" level=warning msg="failed to hide page: evaluating JS: Cannot find context with specified id" category="Page:Close" elapsed="0 ms" source=browser
time="2024-11-18T01:41:35+01:00" level=warning msg="failed to hide page: evaluating JS: Cannot find context with specified id" category="Page:Close" elapsed="0 ms" source=browser

My actions are build like this:

        try {
          if (debug != 'False') {
            console.log("clicking username-authenticator");
          }
          sleep(0.1);
          const button = await page.locator('#username-authenticator');
          await button.waitFor( { state: 'visible' });
          if(screenshots != 'False') {
            await page.screenshot({ path: 'screenshots/' + Date.now() + '-clickusernam-' + ssns[x] + '.png'});
          }
          await button.click();
        } catch (error) {
          console.log("not finding usernameauthenticator " + ssns[x]);
        }

But I have tons of them, I can run with vus=1 and do screenshots and all are correct. But this happens when I ramp up.

Hard to debug.

Hi @mortenb123,

Does your script run correctly even after you see these errors?

The errors might be caused by fast navigation. You might want to remove sleep and use a Promise.all, as shown here.

Thanks.

1 Like