Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an HtmlUnitDriver for .NET?

Tags:

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?

like image 237
Dan Tao Avatar asked Feb 23 '11 17:02

Dan Tao


People also ask

Does HTMLUnitDriver API is the fastest?

HTML UnitDriver is the most light weight and fastest implementation headless browser for of WebDriver. It is based on HtmlUnit. It is known as Headless Browser Driver. It is same as Chrome, IE, or FireFox driver, but it does not have GUI so one cannot see the test execution on screen.

What is the use of HTMLUnitDriver in selenium?

HtmlUnitDriver is headless driver providing non-GUI implementation of Selenium WebDriver. It is based on HtmlUnit, fastest and light-weight browser implemented in Java.

Can we take screenshot in HTMLUnitDriver?

htmlunit driver does not support screenshots · Issue #1361 · SeleniumHQ/selenium-google-code-issue-archive · GitHub.

Is HtmlUnit headless browser?

HtmlUnit is a headless web browser written in Java. It allows high-level manipulation of websites from other Java code, including filling and submitting forms and clicking hyperlinks. It also provides access to the structure and the details within received web pages.


1 Answers

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()) 
like image 66
AutomatedTester Avatar answered Sep 23 '22 20:09

AutomatedTester