views:

27

answers:

1

Hello,

I'm looking for a good browser emulator API for .NET. I've been looking at WatiN, but I really don't need (want!) the GUI, I just want the HTML/DOM-parsing, JavaScript runtime and emulation of state, cache, and everything else.

What I'm looking for would work something like this

using (var browser = Browser.Create(BrowserType.Firefox))
{
  // Download all page resources and executes JS
  var page = browser.Open("http://localhost:8080");

  // Lookup <a id="nextButton" href="#" /> and trigger click event
  page.Find("nextButton").Click();
}

Have you ever come across anything like it? Thanks!

+3  A: 

Why not use the real browser? Use the WebBrowser control.

John Saunders
I've had some success with this - you can certainly run the WebBrowser control in an API kind of way. I ran it in a Windows Forms message loop and marshaling browser commands to it from a non UI thread was not that hard. You have full access to everything and the C# 4.0 dynamic keyword just made it a heck of a lot easier to program against, so I say go for it.
ZeroBugBounce
Yes, part of the problem is that I want to do it in a windows service, a non UI thread. I will look into what richdiet suggested.
Mikael Lundin
You may need to make enable desktop access for the service for that, but otherwise, seems possible.
ZeroBugBounce