NHtmlUnit is .NET friendly wrapper for HtmlUnit.
We really like the HtmlUnit project, which enables headless web testing without needing to have a complete browser running. By using IKVM it is possible to convert the HtmlUnit Java library for use on Microsoft's .NET platform.
However it doesn't feel very natural to use a java library in a .NET language, and therefore we created an HtmlUnit wrapper written in C#.
NHtmlUnit can be built using either MSBuild or Visual Studio 2010.
After building you can find NHtmlUnit.dll
plus its dependencies here:
- app\NHtmlUnit\bin\Debug
- app\NHtmlUnit\bin\Release
An prepackaged binary is planned for release in the near future.
A package is also available using the NuGet package manager:
For now there is no manual or API reference written for NHtmlUnit.
You can however use the HtmlUnit reference, as this wrapper almost completely reflects the original API.
The difference is that Java iterators, lists and collections are exposed as
their .NET-friendly counterparts (IEnumerable
, IList
and ICollection
).
In addition, properties are now "real" .NET properties. obj.getSomething()
and
obj.setSomething()
is exposed as obj.Something
;
This executable only needs to be run when the HtmlUnit jar file has changed!
When NHtmlUnitGenerator is run it will overwrite all files in app\NHtmlUnit\Generated.
Note that it doesn't do anything with the project files, so if classes are added or removed from the origin HtmlUnit jar file this will not be synchronized. You have to manually add new files to the project.
NHtmlUnit is licensed under the Apache License Version 2.0, which is the same license used for HtmlUnit.
NHtmlUnit has in large parts been autogenerated using the HtmlUnit jar file as input.
Although we consider NHtmlUnit itself to be of decent quality, the NHtmlUnitGenerator is basically a large hack.
A complete rewrite of the NHtmlUnitGenerator using Mono.Cecil would be nice, although we're unsure exactly how much this would do for the final product.
NHtmlUnit was written by Asbjørn Ulsberg and Karsten Strand at OKB AS.