Is there an HtmlUnitDriver for .NET?
Asked Answered
R

3

24

I'm using Selenium's WebDriver to run some SpecFlow tests for an ASP.NET MVC app I'm working on for self-education.

Using FirefoxDriver, ChromeDriver, etc. all take so long to run, it's actually pretty frustrating to use them (in my opinion).

I have read about an HtmlUnitDriver that is supposedly much faster than the browser-based drivers; but I can't seem to find a version in the .NET client library (only Java). Is there a .NET version out there?

Rodolphe answered 23/2, 2011 at 17:35 Comment(0)
L
25

To use HtmlUnit you need to use the RemoteWebDriver and pass in the desired capabilities for it.

IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.HtmlUnit())

and away you go. If you want the Firefox implementation to run use

IWebDriver driver = new RemoteWebDriver(DesiredCapabilities.HtmlUnitWithJavaScript())
Leavetaking answered 23/2, 2011 at 18:34 Comment(4)
MUCH faster than the other drivers, and perfect for simple HTML tests. Thanks!Rodolphe
Don't forget this means you need to start the Selenium-Server-Standalone.jar on the machine you want to run the browserBlackberry
This approach doesn't seem to work... 13:29:08.259 INFO - WebDriver remote server: Executing: [new session: null] at U RL: /session) 13:29:08.269 INFO - WebDriver remote server: Exception: java.lang.NullPointerExc eptionOpulent
Didn't work for me using Selenium 2.53.1: The best matching driver provider org.openqa.selenium.edge.EdgeDriver can't create a new driver instance for Capabilities [{browserName=htmlunit, version=, platform=ANY}]Reactant
C
2

The RemoteWebDriver approach is the one the Selenium devs recommend: discussion

As per that link however, if you prefer, it is easy enough invoke HtmlUnit via IKVM; that worked well for me.

I think Steve Sanderson described this first.

Caia answered 21/5, 2011 at 8:21 Comment(0)
R
0

Well, looks like the answer right now is unfortunately no. I found this on the Google Code site; a user asked:

Is this possible to transfer to C#?

...to which one of the developers responded:

Not without taking a dependency on IKVM, which is not something we are prepared to do at this time.

Oh well :(

Rodolphe answered 23/2, 2011 at 18:34 Comment(2)
The other reason is there isnt a decent enough .NET JavaScript engine where Java has a few...Leavetaking
Does the selected answer is the answer or the ultimate answer is no ?!?!Epilate

© 2022 - 2024 — McMap. All rights reserved.