My goal is to run browser tests, written using k6, in a docker container. I have my script for the k6 browser tests, and a docker image with nodejs, k6, and chromium installed (chromium is for k6 browser testing). My 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/can’t access company network websites? However, if I run a curl command to the login page inside the docker container, that works fine.
Note that I can run the k6 sample browser test script (which performs browser testing functions on a website that does not require being on my company network to access) within my docker container and everything goes as expected, which I think indicates the chrome was installed correctly. Here is the Dockerfile chrome installation code, if it is relevant:
RUN apt-get install -y wget
RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb
How can I adjust my dockerfile or anything else to be able to access the company login page on Chrome from inside my docker container?