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

Merged
merged 5 commits into from
May 23, 2025

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:

Edit: updated builds to latest versions

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

cd ../basic-mini
docker build -f Dockerfile.factory \
--build-arg CYPRESS_VERSION=14.4.0 --build-arg FIREFOX_VERSION=138.0.4 --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.4 \
-t firefox-included-13.15.0-test .

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

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
@MikeMcC399 MikeMcC399 marked this pull request as draft May 21, 2025 17:28
@MikeMcC399

This comment was marked as resolved.

@AtofStryker
Copy link
Contributor

@MikeMcC399 I'm hoping to take a look at this either today or tomorrow

@MikeMcC399 MikeMcC399 force-pushed the add/factory-geckodriver branch from beaea37 to c276419 Compare May 21, 2025 18:15
@MikeMcC399 MikeMcC399 marked this pull request as ready for review May 21, 2025 18:31
@MikeMcC399

This comment was marked as outdated.

@MikeMcC399 MikeMcC399 force-pushed the add/factory-geckodriver branch from 1542caa to 615fb0f Compare May 22, 2025 11:25
@MikeMcC399 MikeMcC399 marked this pull request as draft May 22, 2025 11:26
@MikeMcC399 MikeMcC399 marked this pull request as ready for review May 22, 2025 11:42
@MikeMcC399

This comment was marked as resolved.

@MikeMcC399
Copy link
Collaborator Author

Re-tested locally with latest commit and running containers successfully without network connection.

Copy link
Contributor

@AtofStryker AtofStryker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave everything a test locally. This looks great @MikeMcC399. Thank you!

@AtofStryker AtofStryker merged commit d7665e4 into cypress-io:master May 23, 2025
50 checks passed
@MikeMcC399 MikeMcC399 deleted the add/factory-geckodriver branch May 23, 2025 15:24
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
3 participants