RUN apk update && apk add --no-cache chromium
COPY . /k6-load-testing
I’m running the docker container with the following command
docker run --name perf --network=host -i perftests run - <src/ui.js
If I change the url in the script to https://google.co.uk It works fine and I get a screenshot. when running against localhost, the test completes, the screenshot is taken but it’s a blank screen and I see the above warning.
I’m not very familiar with this so any ideas on what I may be doing wrong are welcome
There might be an issue with your docker configuration or the localhost server. You might try the following steps.
Check the Docker network configuration: Ensure that the Docker container is running on the same network as the localhost service you’re trying to access. Using the --network=host flag should allow the container to access services running on the host network, but double-check to ensure it’s set up correctly.
Verify the correct host and port: Ensure that the http://localhost:5173/ URL is correct and corresponds to the service you want to test. Make sure the service is running and accessible.
Check the server configuration: Make sure the server running on localhost:5173 is configured correctly to handle the request from the Docker container. It’s possible that the server may be blocking requests coming from Docker or is not responding properly.
Consider the network security settings: If the server on localhost uses HTTPS, it’s possible that the browser in the Docker container is not able to establish a secure connection. You may need to configure the browser to trust the necessary certificates or use a self-signed certificate if applicable.
Verify the waitUntil option: The waitUntil: 'domcontentloaded' option in page.goto() might be causing the issue. Try changing it to waitUntil: 'networkidle' or waitUntil: 'load' to wait for different conditions before taking the screenshot.