Skip to content

feat: add geckodriver to factory process #1353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MikeMcC399
Copy link
Collaborator

@MikeMcC399 MikeMcC399 commented May 19, 2025

Situation

The mozilla/geckodriver is required to test Firefox. It is not part of the Firefox distribution, nor is it included in Cypress. If the driver is unavailable, then testing against Firefox fails. This is typically the case in an air-gapped environment.

If an attempt is made to run Cypress against a Firefox browser in a Cypress Docker container using cypress/browsers or cypress/included images, Cypress tries to download mozilla/geckodriver. In an air-gapped environment (no Internet access) the download fails and it is not possible to test against Firefox. The same applies to any Docker images built for Firefox with the current version of cypress/factory.

Secondly, in a regular environment with Internet connectivity, and no cached version of the mozilla/geckodriver stored in the Docker image, the driver version defaults to the latest, which means that the test configuration with Firefox is non-deterministic.

Assessment

Cypress uses the npm wrapper package geckodriver, bundled into the Cypress binary, in order to ensure the availability of the mozilla/geckodriver driver for Firefox testing.

By manually installing the mozilla/geckodriver in a Docker build process, and then setting the geckodriver environment variable GECKODRIVER_PATH, the wrapper package is instructed not to download and to use the locally stored driver instead.

If the mozilla/geckodriver can first be built into a Cypress Docker image in an environment with Internet connectivity, the Docker image can later be used in an environment without Internet to test against Firefox.

Change

Introduce a new Cypress build parameter GECKODRIVER_VERSION to direct the Cypress factory build process to install the corresponding version of mozilla/geckodriver into a Cypress Docker image being built. The driver is stored in the GECKODRIVER_PATH /opt/geckodriver/geckodriver.

The published images cypress/browsers and cypress/included are left unchanged, with no geckodriver pre-installed. An enhancement to these images is left for a follow-on PR.

This is a backwards-compatible feature addition.

Detailed changes

@cypress-app-bot
Copy link

@MikeMcC399
Copy link
Collaborator Author

@MikeMcC399 MikeMcC399 self-assigned this May 19, 2025
@MikeMcC399 MikeMcC399 marked this pull request as ready for review May 19, 2025 11:05
@MikeMcC399
Copy link
Collaborator Author

MikeMcC399 commented May 19, 2025

Tests

CircleCI tests

Include additional test-factory-cypress-included-firefox-geckodriver tests for amd64 and arm64

Local tests

Test with Docker Desktop Linux 4.41.2 under Ubuntu 24.04.2 LTS, amd64

cd factory
docker compose build factory
cd ..

Build tests

cd examples/basic
docker build -f Dockerfile.factory --build-arg GECKODRIVER_VERSION=0.36.0 -t firefox-test .
cd ../..
  • use --progress plain to see skipped messages
  • use --no-cache to repeat test
GECKODRIVER_VERSION Build message
0.36.0 Success
0.34.0 Success
0.99.0 Fail 404 Not Found
0.33.0 Skip

Run tests

Build custom images with network connected:

cd examples/basic
docker build -f Dockerfile.factory \
--build-arg FIREFOX_VERSION=138.0.3 --build-arg GECKODRIVER_VERSION=0.36.0 \
-t firefox-browsers-test .
npm ci

cd ../basic-mini
docker build -f Dockerfile.factory \
--build-arg CYPRESS_VERSION=14.3.3 --build-arg FIREFOX_VERSION=138.0.3 --build-arg GECKODRIVER_VERSION=0.36.0 \
-t firefox-included-test .

docker build -f Dockerfile.factory \
--build-arg CYPRESS_VERSION=13.15.0 --build-arg FIREFOX_VERSION=138.0.3 \
-t firefox-included-13.15.0-test .

cd ../firefox-esr
docker build -f Dockerfile.factory --build-arg GECKODRIVER_VERSION=0.36.0 \
-t firefox-esr-test .
npm ci

cd ../..

Disconnect network and run each image:

cd examples/basic
docker run -it --rm --entrypoint bash -v .:/app -w /app firefox-browsers-test -c "npx cypress run -b firefox"

cd ../basic-mini
docker run -it --rm --entrypoint cypress -v .:/app -w /app firefox-included-test run -b firefox
docker run -it --rm --entrypoint cypress -v .:/app -w /app -u node firefox-included-test run -b firefox # test non-root
docker run -it --rm --entrypoint cypress -v .:/app -w /app firefox-included-13.15.0-test run -b firefox

cd ../firefox-esr
docker run -it --rm --entrypoint bash -v .:/app -w /app firefox-esr-test -c "npx cypress run -b firefox"

cd ../..

@MikeMcC399 MikeMcC399 force-pushed the add/factory-geckodriver branch from e806a42 to dd3d948 Compare May 20, 2025 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add geckodriver to factory process
2 participants