Xk6 Browser v0.5.0 How to ignore http error on the page

I have an unimportant http 404 error on the page. This is just an icon fails to load. Test fails. I want to ignore it and continue test. How can I do that?

I was using 0.1.3 and everything was working. I can download xk6 browser 0.1.3 but I need to bundle this with xk6-file. It doesn’t give me the option for older version when bundling. How can I do it?

Hi @MCengiz,

Thanks for reaching out.

Could you share some details to help us diagnose the issue?

  1. What OS version are you running?
  2. Can you send us a test script that exhibits this behaviour (preferably pointing to a public facing site)?

Have you tried working with the latest version of xk6-browser v0.5.0?

I’ve created a test script that navigates to a website where I’ve purposefully pointed to resources that don’t exist (the favicon and an image in the main body), and the test doesn’t stop when a 404 response is returned when the browser fails to retrieve them.

Cheers,
Ankur

import { chromium } from 'k6/x/browser';
 const browser1 = chromium.launch({ headless: false });
  const context1 = browser1.newContext({ });
let studentPage = context1.newPage();
  studentPage.goto("https://id.edurooms.com", { waitUntil: 'networkidle' });


ERRO[0002] Failed to load resource: the server responded with a status of 404 () browser_source=network line_number=0 source=browser stacktrace=“” url=“https://id.edurooms.com/favicon.ico”
ERRO[0030] communicating with browser: websocket: close 1006 (abnormal closure): unexpected EOF category=cdp elapsed=“0 ms” goroutine=82
ERRO[0032] navigating to “https://id.edurooms.com”: timed out after 30s
running at reflect.methodValueCall (native)

This is the bundle I use
xk6 build v0.40.0 --with github.com/grafana/xk6-browser --with github.com/avitalique/xk6-file

Hi,

Thanks for getting back with the details. I can see that the key part of the error message is the following:

ERRO[0032] navigating to “https://id.edurooms.com”: timed out after 30s
running at reflect.methodValueCall (native)

The 404 error:

ERRO[0002] Failed to load resource: the server responded with a status of 404 () browser_source=network line_number=0 source=browser stacktrace=“” url=“https://id.edurooms.com/favicon.ico”

Is misleading. This is the error coming back from the browser when it was trying to retrieve the favicon icon. xk6-browser and the running test isn’t concerned with that error, and the test will pass.

The reason why it’s not passing and timing out after 30 seconds, is due to a bug in how xk6-browser is handling networkIdle lifecycle events when navigating to a page. This issue is currently being worked on and will hopefully be in the next release in the coming weeks. You can track this issue’s PR #578.

The work around (until the next release) is to wait on a different lifecycle event, load. This doesn’t wait for all network traffic to end before unblocking the wait, but it does wait for all “dependent resources such as stylesheets and images” to load first before firing.

Cheers,
Ankur

1 Like