HtmlUnitDriver for .NET

117 views
Skip to first unread message

ShaderOp

unread,
Aug 12, 2010, 3:17:36 PM8/12/10
to Selenium Developers
Hi everyone,

I have been working on implementing a .NET driver for HtmlUnit based
on the latest Alpha 5 release. I'm testing my work against the unit
tests provided in WebDriver source code, and so far I have managed to
get 312 out of the 340+ tests passing.

I would have liked to offer a patch that includes all the source code
and dependencies, but I'm afraid I'm having some trouble understanding
the layout of the Selenium code and how the build process actually
works. There's also another issue: I'm using IKVM to compile HtmlUnit
into a .NET assembly, and although it's working fine for me, there's
always the possibility that someone might view this method as being
too hacked together to be worthy of including in Selenium's official
code.

Anyways, I have detailed what I have done so far in the following blog
post:

http://bit.ly/bNKlYN

I have also have the source code up at the following BitBucket
repository:

http://bitbucket.org/shaderop/htmlunitdriver

Hope this helps, and if there's anything I can do to make the code
more suitable for inclusion, then please tell me what need to be done
and I'll try my best to do it.

Mohammad "SahderOp" Abdulfatah

Jim Evans

unread,
Aug 13, 2010, 10:15:07 AM8/13/10
to Selenium Developers
At the time the .NET bindings were originally being developed, the
concentration was on Remote, Firefox and Chrome, after IE had been
mostly finished. We ended up taking on a dependency on JSON.NET for
use with the Remote driver and its descendants, and another on
DotNetZip to be able to implement the Firefox and Chrome drivers. When
the discussion came up about HtmlUnit, we [1] specifically put off
building one to avoid yet another dependency, in this case, IKVM.
Since then, I don't think anyone has gotten the time to revisit the
decision. I'd love to look at your code, and will do so soon.

What questions, specifically, do you have about the build process
for .NET components? I can help answer some of those, though I'm in
the process of revamping that to bring it more in line with the
CrazyFun build process [2] used for other language bindings.

Regards,
--Jim

[1] By "we", I mean "I". It was an arbitrary decision on my part.
[2] http://code.google.com/p/selenium/wiki/CrazyFunBuild

Mohammad Abdulfatah

unread,
Aug 13, 2010, 3:44:17 PM8/13/10
to selenium-...@googlegroups.com
Hi Jim,

Thanks for the reply and the bit of history you've provided.

Regarding the build process, I was unable to figure out where to start
with integrating my build steps into the source code. I saw some Rake
build files, and saw Maven mentioned a few times. I also couldn't figure
out what sort of webserver you guys were using for the unit tests. The
fact that I know very little about rake and nothing about Maven didn't
help much.

In my own source code I have IKVM libs and binaries and the HtmlUnit JAR
files. There's a small batch file that rebuilds the .NET HtmlUnit assembly
when I need to update it. And I also have Cassini web server executable
that hosts the HTML test pages and launches automatically when the unit
tests start.

I would have no problem re-organizing my source code to fit with
Selenium's structure. I just don't know where to start with the other
stuff.

Please do take a look at the source code when you can and tell me if
there's anything I can do. It's nothing fancy; mostly it's just a
translation of the Java source code. Although I did make a slight
modification to the FindElement(s)ByClassName methods so it would be
possible to find elements that have multiple CSS classes.

Mohammad

Jim Evans

unread,
Aug 13, 2010, 5:04:37 PM8/13/10
to Selenium Developers
Rake is the tool used for building the entire suite. You're not
missing anything about the unit tests for the .NET bindings. Those
tests are not integrated into the build process yet. We have been
running them manually using the Visual Studio Development Web Server
(which is the version of Cassini included with VS). Again, it's a
matter of not having time to do the integration work. When the
Albacore 0.2.0 releases, I'll be changing the .NET build process to
use it, and will use the opportunity to integrate the .NET unit tests
with the rest of the build process.

In the meantime, I'll be looking at the code you've written.

Regards,
--Jim

On Aug 13, 3:44 pm, Mohammad Abdulfatah <moham...@abdulfatah.net>
wrote:
> [2]http://code.google.com/p/selenium/wiki/CrazyFunBuild- Hide quoted text -
>
> - Show quoted text -

Daniel Wagner-Hall

unread,
Aug 14, 2010, 10:13:00 PM8/14/10
to selenium-developers
On 13 August 2010 20:44, Mohammad Abdulfatah <moha...@abdulfatah.net> wrote:
> Hi Jim,
>
> Thanks for the reply and the bit of history you've provided.
>
> Regarding the build process, I was unable to figure out where to start
> with integrating my build steps into the source code. I saw some Rake
> build files, and saw Maven mentioned a few times. I also couldn't figure
> out what sort of webserver you guys were using for the unit tests. The
> fact that I know very little about rake and nothing about Maven didn't
> help much.
>
> In my own source code I have IKVM libs and binaries and the HtmlUnit JAR
> files. There's a small batch file that rebuilds the .NET HtmlUnit assembly
> when I need to update it. And I also have Cassini web server executable
> that hosts the HTML test pages and launches automatically when the unit
> tests start.
>
> I would have no problem re-organizing my source code to fit with
> Selenium's structure. I just don't know where to start with the other
> stuff.
>
> Please do take a look at the source code when you can and tell me if
> there's anything I can do. It's nothing fancy; mostly it's just a
> translation of the Java source code. Although I did make a slight
> modification to the FindElement(s)ByClassName methods so it would be
> possible to find elements that have multiple CSS classes.

The Java versions should be doing that already - what problems were
you running in to with them?
org.openqa.selenium.ElementFindingTest#testShouldFindElementsByClassWhenItIsThe{First,Last,Middle}NameAmongMany
tests that behaviour - do you have a failing test you can share?

Mohammad Abdulfatah

unread,
Aug 14, 2010, 10:35:48 PM8/14/10
to selenium-...@googlegroups.com
> The Java versions should be doing that already - what problems were you
> running in to with them?
> org.openqa.selenium.ElementFindingTest#testShouldFindElementsByClass
> WhenItIsThe{First,Last,Middle}NameAmongMany
> tests that behaviour - do you have a failing test you can share?
>

Sorry, that was my mistake. It wasn't that the Java version implemented
find(s)ElementByClassName incorrectly. I'm looking at the code that I
worked from and the HtmlUnitDriver class doesn't implement the
FindsByClassName interface at all. I've just looked at the source code in
the trunk, and it's identical to the Java code I've on my disk.

I don't know why I thought the Java code implemented the
findElement(s)ByClassName methods incorrectly when it didn't implement
them at all. I apologize for the mix-up on my part. Is there a more recent
version of the code than the one in the trunk? I might have missed it
altogether.

I didn't run the Java unit tests at all, so I don't know if the
ShouldFindElementsByClass test passes or not in Java, but it is passing
just fine in my own .NET code.

Reply all
Reply to author
Forward
0 new messages