I’m looking for a headless browser that supports .NET to help me with automated UI testing for web applications.
Having previously worked with HtmlUnit in Java, I want to find a similar solution in the .NET world now.
My aim is to create these automated UI tests without using browser-remoting tools like Watin or Selenium, as I prefer not to deal with the complexities of managing actual browser instances.
I would like to stick with .NET tools and avoid using Java or Ruby for this task.
Can anyone share their experiences with headless browser frameworks for .NET? What have you found that works well, particularly regarding handling modern web applications and JavaScript functionalities?
I’m keen on options that provide a straightforward API for programmatic control over web pages, including navigating, submitting forms, and extracting content efficiently.
AngleSharp could be perfect if you want to ditch browser instances completely. It’s a pure .NET HTML parser with CSS selectors that handles DOM manipulation and forms without any external dependencies. I’ve been using it for 18 months across multiple projects for lightweight scraping and testing. The catch? JavaScript support is pretty basic - nowhere near a real browser engine. Works great for static content and simple interactions, but modern SPAs will break it. The API is clean and follows web standards. If your apps are JavaScript-heavy, you’ll need to pair it with something else or stick with the browser approach despite the headaches.
I’ve used PuppeteerSharp for two years and it’s solid for headless browser automation in .NET. It’s basically the C# version of Node.js Puppeteer - controls Chrome/Chromium through DevTools Protocol. The API’s clean and handles JS-heavy apps perfectly since it runs on actual Chrome. Easy NuGet install, downloads Chromium automatically if you don’t have it. Performance is good for most testing, though new browser instances take a bit to start up. Docs aren’t great but there’s enough examples online. Yeah, it uses a browser instance under the hood, but it’s all handled programmatically - no messy external drivers to deal with.
playwright for .net is solid - i’ve been using it for 8 months. it runs chrome, firefox, and safari headlessly, and the .net bindings stay current. handles modern js apps way better than other tools i’ve tried. setup’s easy through nuget and it manages browser binaries automatically. debugging’s helpful when tests fail too.