The Simplest Way to Make Azure Active Directory and Selenium Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Using azure active directory and selenium together lets teams test web apps behind single sign-on. This setup runs automated browser checks while keeping your user login rules in place. Many engineering teams build internal web apps that require a directory login before any page loads. When you run browser tests against these pages, the test script hits a login screen first. You need a safe way for the test runner to log in, check the app, and log out. Done right, your team catches broken pages

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Using azure active directory and selenium together lets teams test web apps behind single sign-on. This setup runs automated browser checks while keeping your user login rules in place.

Many engineering teams build internal web apps that require a directory login before any page loads. When you run browser tests against these pages, the test script hits a login screen first. You need a safe way for the test runner to log in, check the app, and log out. Done right, your team catches broken pages before users do without leaving open doors for attackers.

How logins and data flow in azure active directory and selenium

In a standard setup, the test runner starts a fresh browser session on a build server. The script opens your target web app, which redirects the browser to the directory login page. From there, the directory checks who is asking to log in and what role they hold.

Instead of typing a human user password into the form, teams can use token flows. The build server asks the directory for a scoped access token before the browser even opens. The script then places that token into the browser storage or headers before loading the app. This skips the slow login screen and keeps plain text passwords out of your test scripts.

When a test must check the actual login screen, teams create a dedicated test user account. The directory assigns this user a narrow role that only works inside the test app. Once the login finishes, the directory sends a signed token back to the browser session. The web app reads this token, checks the assigned role, and loads the right view for the test.

Common failure modes and how to scope access

The biggest mistake teams make is sharing one admin account across all browser test suites. If a test log leaks that password, anyone can log into your real systems with full power. Another common trap is turning off multi-factor checks for an entire user group just to make tests pass.

Long-lived tokens also create high risk when stored in plain text inside code repos. If an engineer copies a test config file to a laptop, that token travels with it. Also, shared test accounts leave terrible audit logs because every action looks like the same generic user. When a test alters database records by mistake, you cannot tell which build job ran the action.

Active Directory + Azure RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix these issues, scope every test account to the smallest possible role in your directory. Give each test pipeline its own service identity so your logs show which job ran which browser session. Set conditional rules in your directory so test accounts can only log in from known build server networks. Never allow a test identity to read production customer data or change system settings.

Keeping sensitive data safe during automated browser runs

Browser tests often read pages that display user profiles, billing forms, or support tickets. Even in staging setups, real data sometimes slips into test databases during a bad sync. If a test fails, the runner might save screenshots or page text that hold private details.

Teams should scrub test data and mask fields like emails, phone numbers, card numbers, and national IDs. Masking rewrites matched fields in results so test logs do not store raw sensitive values. You should also clear browser state and revoke active tokens as soon as each test run ends. Short token lifetimes make sure a stolen test session cannot be reused hours later.

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

Should we disable multi-factor checks for browser test accounts?

Only bypass multi-factor prompts for dedicated test accounts that are locked to your build server IP addresses. Never remove multi-factor rules for human users or accounts that can reach production data.

Why do our browser login tests break so often?

Login pages change their page layout and element names without warning, which breaks scripts that click buttons. Fetching a token from the directory API and loading it into the browser session is much more stable.

How do we audit what a browser test did in our app?

Give each build pipeline a unique directory identity and log every token request alongside the build job ID. This links every page load and data change back to the exact code commit that triggered the test.

The query runs. The emails stay hidden.