I’ve created a dockerfile to run my k6 browser test script in. The script should perform simple browser testing functions, like going to a login page, entering credentials, and hitting “login”, and it works as expected if I run it outside the docker container. However, when I run it inside the docker container, it errors when it tries to go to the login page:
ERRO[0002] error on evaluating window.k6SpanId: evaluating JS in global context: context canceled category="FrameSession:onFrameNavigated" elapsed="0 ms" source=browser
ERRO[0002] Uncaught (in promise) TypeError: Cannot read property 'headers' of undefined or null
running at file:///home/username/browserTest.js:25:16(16) executor=shared-iterations scenario=ui
I believe this might be because the login page it is trying to access is only available on the company network. My computer uses a VPN to connect to the company network, but perhaps specifically the chromium browser in the docker container is somehow not using the VPN? However, if I run a curl command to the login page inside the docker container, that works fine.
Notes:
- I am not using the official k6 browser docker image, since I wanted to use a company image as my base image.
- I can run the sample browser test script within my docker container and everything goes as expected.