Browser tests in Azure

Automating Browser Tests 
in Azure

  When automating browser tests for applications integrated with MS Entra ID (OAuth2/OIDC) in Azure or Windows environments, Playwright, Selenium, and Cypress behave very differently.


1. Playwright (The Modern Microsoft Native)
Built by Microsoft, Playwright has native, deep integration with Windows architecture and Azure DevOps. It is currently the industry-recommended tool for testing Azure-backed applications. Playwright's native auto-waiting mechanisms are perfectly engineered to handle the asynchronous nature of Blazor Server (SignalR web sockets) and Blazor WebAssembly (WASM code execution) without requiring unstable sleep timers.
  • Azure Pipelines Integration: Out-of-the-box support in Azure DevOps. You can run Playwright tests across multiple browsers (Chromium, Firefox, WebKit) in parallel using headless Azure-hosted agents (Windows or Linux) without installing extra dependencies.  
  • The Entra ID Advantage (Storage State): Playwright allows you to log in once at the beginning of a test suite, capture the browser's authentication state (cookies, local storage, and session tokens), and save it to a JSON file. Every subsequent test reuse this file to bypass the Microsoft login screen completely, saving massive amounts of execution time. 
  • Windows Features: Native support for testing Windows-specific features like Integrated Windows Authentication (Kerberos/NTLM). 
  • API testing: Playwright while famous for frontend browser rendering, its underlying APIRequestContext lets you run integration test logic (asynchronously) directly within TypeScript, Python, or C# code projects to test APIs.
  • Verdict: Best choice for Azure environments. It is fast, handles async Microsoft login redirects natively, and isolates test contexts perfectly. 
2. Cypress
Cypress executes tests directly inside the browser. While highly developer-friendly, this architecture introduces unique hurdles when dealing with cloud identity providers like Azure Entra ID.
  • The Microsoft Login Hurdle: Older versions of Cypress strictly enforced a "Same-Origin" rule, meaning a test could not navigate from your application (myapp.azurewebsites.net) to the Microsoft login page (://microsoftonline.com). While Cypress now supports multi-domain testing via cy.origin(), handling Microsoft's complex login redirects can still be flaky.
  • Azure Deployment: Cypress tests run smoothly on Azure App Services or Container Instances. However, configuring parallel execution requires using Cypress Cloud or a self-hosted alternative in your Azure CI/CD pipelines.
  • The Solution for Entra ID: Instead of using the UI to type username and password, Cypress tests typically use cy.request() to make a programmatic back-channel OAuth2 request to Entra ID, fetch the access token, and inject it straight into the browser storage before the test begins.
  • Verdict: Great for testing your application's internal UI logic, but less optimal if you need to test the actual end-to-end Microsoft login redirect flow.
3. Selenium (The Enterprise Legacy)
Selenium is the veteran framework. It interacts with browsers via external browser drivers (like WebDriver for Edge or Chrome) running on the host OS.
  • Windows Integration: Selenium has deep roots in the Windows ecosystem. If you are testing legacy desktop-web hybrid setups or need absolute control over the Windows operating system registry, certificates, or Edge IE Mode (Internet Explorer compatibility), Selenium remains highly relevant.
  • Azure Devops Setup: Running Selenium in Azure Pipelines requires more infrastructure management. You often have to manage self-hosted Windows build agents, install matching browser versions, and ensure the correct chromedriver.exe or edgedriver.exe is configured on the machine.
  • Handling Entra ID: Because Selenium has no built-in concept of "state saving" like Playwright, your automated scripts usually have to physically type the email, click next, type the password, and handle the redirect loops on every single test, which slows down CI/CD pipelines significantly.
  • Verdict: Best if you are maintaining legacy test suites, require heavy Edge/IE compatibility testing, or need tight integration with Windows OS-level configurations. 


Summary Matrix for Azure & Windows
FeaturePlaywrightCypressSelenium
Microsoft OriginYes (Built by Microsoft)NoNo
Handling Entra ID UIExcellent (via storageState)Moderate (via cy.origin)Slow (Must log in every test)
Azure Pipelines SetupNative & immediateRequires extra setupHigh configuration overhead
Parallel ExecutionBuilt-in & freeRequires cloud license/toolRequires Selenium Grid/Infrastructure
Windows Edge SupportChromium-based EdgeChromium-based EdgeChromium & Legacy Edge/IE Mode

Comments

Popular posts from this blog

GHL Email Campaigns

Free AI Tools

Await