25

Does anybody know if there is a .net equivalent of htmlunit or similar library?

I've heard that people have used IKVM to convert the htmlunit library. But I have also heard that the converted code is slow.

Requirements:

  • Headless browser
  • Support javascript
  • Handle cookies
  • .Net
mike
  • 251
  • 1
  • 3
  • 4
  • 2
    Possible duplicate of http://stackoverflow.com/questions/1512632/c-library-similar-to-htmlunit – Aaron D Sep 24 '11 at 16:27

3 Answers3

15

You can try out the just-released NHtmlUnit (available on NuGet), which is a .NET-wrapper for HtmlUnit. It's not .NET as in "written in a .NET language and compiled to MSIL", but it's converted to .NET with IKVM and we've written a layer of "purified" C# code on top of it so everything looks and behaves like .NET.

Asbjørn Ulsberg
  • 8,721
  • 3
  • 45
  • 61
  • asbjornu, how's the performance of NHtmlUnit? Have you tested it perchance, or could you share any anecdotal evidence or gut feelings? – agentnega Jan 31 '12 at 00:07
  • I'm one of the developers of NHtmlUnit and it performs very comparably to HtmlUnit since the Java code is translated into MSIL at the bytecode level and the whole Java class library is provided through IKVM as MSIL bytecode as well. – Asbjørn Ulsberg Feb 01 '12 at 07:13
  • Is it possible to use NHtmlUnit with WebDriver (e.g., Selenium)? – D.R. Jan 14 '16 at 13:13
  • @D.R. I would rather say it goes the other way around. You use [HtmlUnit in WebDriver](https://code.google.com/p/selenium/wiki/HtmlUnitDriver), so you can program against one interface (WebDriver) and have the same code execute in several different "browsers" such as HtmlUnit. – Asbjørn Ulsberg Jan 14 '16 at 19:41
5

You can use Htmlunit from .net with ikvm. I followed the instructions at http://blog.stevensanderson.com/2010/03/30/using-htmlunit-on-net-for-headless-browser-automation/ and it worked for me.

edit: it is slow though. recently I've been using Selenium Server with the .net client

mcintyre321
  • 12,996
  • 8
  • 66
  • 103
1

Nothing yet that fulfils all of your requirements.

XBrowser is a headless browser that handles cookies, but does not support javascript. It is however in active development so this may change.

Talljoe
  • 14,593
  • 4
  • 43
  • 39
Oded
  • 489,969
  • 99
  • 883
  • 1,009