Run Selenium Tests in GitHub Actions

Published
Length
3 min read

Luis Felipe Dias

All posts

To run selenium tests in github actions, set up a workflow with a headless browser. The runner starts your web app, opens the browser, and checks each page step. Teams often store broad database keys and cloud roles inside repo secrets for these runs. If a test script or package has a bug, those broad roles put data at risk. How to run selenium tests in github actions First, you pick a runner image that holds your language tools and web browsers. Most standard cloud runners come with Chrome,

GitHub Actions Security + Just-in-Time Access: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

To run selenium tests in github actions, set up a workflow with a headless browser. The runner starts your web app, opens the browser, and checks each page step. Teams often store broad database keys and cloud roles inside repo secrets for these runs. If a test script or package has a bug, those broad roles put data at risk.

How to run selenium tests in github actions

First, you pick a runner image that holds your language tools and web browsers. Most standard cloud runners come with Chrome, Firefox, and matching drivers ready to use. Your workflow file tells the runner to pull your code and install test packages. Next, the job starts your web app in the background on the same host.

If your app needs a database, you can add a service container to the job. The runner starts this database container before your test steps begin to run. Once the app responds on a local port, the test runner starts the browser. The browser runs in headless mode because the cloud server has no screen.

Your test scripts then click buttons, fill out forms, and check page text. When a step fails, the script saves a screenshot or log file to the runner. You can upload these files as build artifacts so your team can check them later. After all tests finish, the runner stops the app and deletes the virtual machine.

Managing secrets and test data in browser workflows

Most browser tests need to log in as a real user or seed test data. Teams often put database passwords or admin tokens into repo secrets for this step. The runner reads these secrets and passes them to the test script as variables. It is best to scope these secrets to a dedicated staging or test setup.

Never point automated browser jobs at a live production database or live user accounts. Even in a test setup, shared staging databases can hold sensitive records like emails or card numbers. If a pull request from an outside fork runs, GitHub blocks secret access by default. Keep this rule in place so untrusted code cannot read your private keys.

GitHub Actions Security + Just-in-Time Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native workflow roles solve and what keeps the session active

GitHub workflow permissions and secret rules control which jobs can start and read keys. They do a great job of keeping secrets out of public build logs. They also let you require human approval before a job uses a staging secret. This setup decides which runner gets to log in to your test database or cloud host.

Still, native runner settings do not watch what happens after the script logs in. Once a job holds a database key, it can run any query that role allows. A bad script could drop a staging table or pull raw emails into a test artifact. Native workflow controls decide who logs in, not what individual queries or commands do in flight.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Why do my browser tests pass locally but fail on the runner?

Cloud runners have less CPU and memory than a local laptop, which slows page loads. Use explicit wait checks in your scripts instead of fixed sleep timers to fix this.

Do I need to install browser drivers manually in my workflow?

No, standard GitHub hosted runners already include Chrome, Firefox, Edge, and their matching web drivers. You can also let modern Selenium versions fetch the right driver version during the test run.

How can I see what went wrong when a headless browser test fails?

Set up your test tool to take a screenshot and save page HTML on every failure. Then use a workflow upload step to save those files as downloadable build artifacts.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.