Linux x-k6-browser ERRO[0032]

Hi, Guys

I was trying to run k6 in linux ubuntu virtual machine and I encounter an error while executing the browser instance script in a headless mode.

aut@LMAUT1:~$ ./k6 K6_BROWSER_ENABLED=true run script.js
ERRO[0000] unknown command "K6_BROWSER_ENABLED=true" for "k6"
aut@LMAUT1:~$ K6_BROWSER_ENABLED=true ./k6 run script.js

          /\      |‾‾| /‾‾/   /‾‾/
     /\  /  \     |  |/  /   /  /
    /  \/    \    |     (   /   ‾‾\
   /          \   |  |\  \ |  (‾)  |
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: script.js
     output: -

  scenarios: (100.00%) 1 scenario, 1 max VUs, 1m0s max duration (incl. graceful stop):
           * browser: 1 looping VUs for 30s (exec: browser, gracefulStop: 30s)

ERRO[0004] Failed to load resource: the server responded with a status of 403 ()  browser_source=network line_number=0 source=browser stacktrace="<nil>" url="https://alb.reddit.com/rp.gif?ts=1690188543714&id=t2_aa7ovq9w&event=PageVisit&m.itemCount=undefined&m.value=&m.valueDecimal=undefined&m.currency=undefined&m.transactionId=&m.customEventName=&m.products=&m.conversionId=&uuid=054f7779-5ea1-4814-a63f-4bc1bf230665&aaid=&em=&external_id=&idfa=&integration=gtm&opt_out=0&sh=1280&sw=720&v=rdt_f5bd31b2"
ERRO[0032] Uncaught (in promise) navigating frame to "https://qa9.legalmatch.com/": navigating to "https://qa9.legalmatch.com/": timed out after 30s  executor=constant-vus scenario=browser

     browser_dom_content_loaded.......: avg=103.65ms min=79µs     med=605µs    max=690.93ms p(90)=428.25ms p(95)=529.13ms
     browser_first_contentful_paint...: avg=742.54ms min=742.54ms med=742.54ms max=742.54ms p(90)=742.54ms p(95)=742.54ms
     browser_first_meaningful_paint...: avg=742.54ms min=742.54ms med=742.54ms max=742.54ms p(90)=742.54ms p(95)=742.54ms
     browser_first_paint..............: avg=742.54ms min=742.54ms med=742.54ms max=742.54ms p(90)=742.54ms p(95)=742.54ms
     browser_loaded...................: avg=125.32ms min=259µs    med=14.09ms  max=514.95ms p(90)=421.14ms p(95)=468.04ms
     data_received....................: 5.7 MB 180 kB/s
     data_sent........................: 83 kB  2.6 kB/s
     http_req_connecting..............: avg=29.49ms  min=0s       med=0s       max=197ms    p(90)=128.8ms  p(95)=132.39ms
     http_req_duration................: avg=376.69ms min=22.31ms  med=255.3ms  max=1.3s     p(90)=968.99ms p(95)=1.06s
     http_req_receiving...............: avg=215.22ms min=1ms      med=79ms     max=1.03s    p(90)=674.6ms  p(95)=848ms
     http_req_sending.................: avg=182.79µs min=0s       med=0s       max=7ms      p(90)=1ms      p(95)=1ms
     http_req_tls_handshaking.........: avg=18.75ms  min=0s       med=0s       max=129ms    p(90)=70.39ms  p(95)=80.99ms
     http_reqs........................: 93     2.935365/s
     iteration_duration...............: avg=31.55s   min=31.55s   med=31.55s   max=31.55s   p(90)=31.55s   p(95)=31.55s
     iterations.......................: 1      0.031563/s
     vus..............................: 1      min=1      max=1
     vus_max..........................: 1      min=1      max=1


running (0m31.7s), 0/1 VUs, 1 complete and 0 interrupted iterations
browser ✓ [======================================] 1 VUs  30s
aut@LMAUT1:~$

Script

import { chromium } from 'k6/experimental/browser';
import { check } from 'k6';

export const options = {
    scenarios: {
        browser: {
            executor: 'constant-vus',
            exec: 'browser',
            vus: 1,
            duration: '30s'
        }
    }
};

export async function browser() {
    const browser = chromium.launch({ headless: true, timeout: '60s' });
    const page = browser.newPage();

    try {
        await page.goto('https://qa9.legalmatch.com/');

        check(page, {
            'Find the Right Lawyer for Your Legal Issue!': (page) =>
                page.locator("(//a[@class='case-intake-form__header--link'])[1]").isVisible() ===
                true
        });
        check(page, {
            'Hero Banner': (page) => page.locator("(//div[@class='hero '])[1]").isVisible() === true
        });
        check(page, {
            'Top Rated': (page) =>
                page
                    .locator("(//div[@class='w-top-rated w-top-rated--no-location '])[1]")
                    .isVisible() === true
        });
    } finally {
        page.close();
        browser.close();
    }
}

Thanks for your help.

  • Increase the timeout value in the chromium.launch() function to a higher value, for example, 120s, to allow more time for the page to load.
  • Check the URL https://qa9.legalmatch.com/ is accessible and responding correctly. Check if the page is functional and not blocked by any firewalls or security settings.
  • If possible consider reducing the number of VUs to see if the issue persists.
1 Like

Hi @nehakakar

Still the error exist increasing the timeout to 120s and having the VU of 1.


          /\      |‾‾| /‾‾/   /‾‾/
     /\  /  \     |  |/  /   /  /
    /  \/    \    |     (   /   ‾‾\
   /          \   |  |\  \ |  (‾)  |
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: testBrowser.js
     output: -

  scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
           * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)

ERRO[0002] Failed to load resource: the server responded with a status of 403 ()  browser_source=network line_number=0 source=browser stacktrace="<nil>" url="https://alb.reddit.com/rp.gif?ts=1690436798043&id=t2_aa7ovq9w&event=PageVisit&m.itemCount=undefined&m.value=&m.valueDecimal=undefined&m.currency=undefined&m.transactionId=&m.customEventName=&m.products=&m.conversionId=&uuid=380d6bf6-9804-4f06-8123-10b74e7976a1&aaid=&em=&external_id=&idfa=&integration=gtm&opt_out=0&sh=1280&sw=720&v=rdt_f5bd31b2"
ERRO[0031] Uncaught (in promise) navigating frame to "https://qa9.legalmatch.com/": navigating to "https://qa9.legalmatch.com/": timed out after 30s  executor=per-vu-iterations scenario=default

     data_received..........................: 5.5 MB 181 kB/s
     data_sent..............................: 93 kB  3.1 kB/s
     http_req_connecting....................: avg=24.16ms  min=0s      med=0s       max=182ms   p(90)=113.99ms p(95)=145.39ms
     http_req_duration......................: avg=352.66ms min=23.46ms med=254.28ms max=1.07s   p(90)=805.12ms p(95)=955.48ms
     http_req_receiving.....................: avg=190.63ms min=1ms     med=74ms     max=716ms   p(90)=574.4ms  p(95)=607.79ms
     http_req_sending.......................: avg=161.29µs min=0s      med=0s       max=4ms     p(90)=0s       p(95)=1ms
     http_req_tls_handshaking...............: avg=13.46ms  min=0s      med=0s       max=93ms    p(90)=72.99ms  p(95)=76.39ms
     http_reqs..............................: 93     3.058902/s
     iteration_duration.....................: avg=30.4s    min=30.4s   med=30.4s    max=30.4s   p(90)=30.4s    p(95)=30.4s
     iterations.............................: 1      0.032891/s
     vus....................................: 1      min=1      max=1
     vus_max................................: 1      min=1      max=1
     webvital_first_contentful_paint........: avg=805.3ms  min=805.3ms med=805.3ms  max=805.3ms p(90)=805.3ms  p(95)=805.3ms
     webvital_first_contentful_paint_good...: 1      0.032891/s
     webvital_time_to_first_byte............: avg=64.56ms  min=57.5ms  med=62.5ms   max=73.69ms p(90)=71.45ms  p(95)=72.57ms
     webvital_time_to_first_byte_good.......: 3      0.098674/s


running (00m30.4s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs  00m30.4s/10m0s  1/1 iters, 1 per VU

Hi, @nehakakar

This issue was fixed, I workaround with other test servers and it’s working fine. Thank you for your suggestions.