I’m working on a C# project where I need to automate web interactions like JavaScript execution, finding elements using XPath selectors, and simulating user actions such as clicks and keyboard input. The main challenge is that I want to distribute my application without requiring end users to install any additional software or browsers.
I’ve explored Selenium which works great for automation tasks, but it needs Chrome or Firefox to be installed on the target machine for headless operations. I also looked into CefSharp which embeds Chromium directly into the app, but it lacks advanced features like XPath support and doesn’t offer the same level of functionality as Selenium.
What I’m looking for:
Are there any C# libraries or frameworks that provide comprehensive headless browser capabilities (similar to Selenium’s feature set) while being completely self-contained? I want to ship a single executable that doesn’t depend on external browser installations.
Hit this same issue two years back while building automation tools for client deployments. Tried a bunch of options and settled on AngleSharp + a custom JavaScript wrapper. AngleSharp doesn’t run JavaScript by itself, but throw in Jint and you’ve got a lightweight setup that handles most DOM stuff and basic scripting without external dependencies. You’ll have to code some browser behaviors yourself, but it works for most automation jobs. Also played around with Chromely - it’s basically a slim CEF wrapper that’s way more flexible than CefSharp. You can add XPath by injecting custom JavaScript. File size stays reasonable compared to full Chromium, and deployment’s easy since everything bundles with your app.
hey, puppeteer-sharp could be a good fit! it packages chromium with your app, so no extra installs r needed. just keep in mind your exe size will grow a lot. but for standlone use, it seems to fit ur needs perfectly!
Check out Microsoft’s WebView2 Runtime - it might work for what you need. Yeah, you’ll need to install the runtime, but you can bundle it with your app using the evergreen bootstrapper or fixed version model. You get full browser automation with JavaScript and XPath support through DOM APIs. I’ve used WebView2 in production for similar stuff. The runtime’s pretty small compared to embedding a whole browser, and Microsoft’s deployment options make it seamless for users. Automation works great since it’s running real Chromium under the hood. Also worth looking at Playwright for .NET - it bundles browser binaries automatically when you build. Downloads the browser files during setup, so deployment’s way more predictable than depending on whatever browsers users have installed.