When I used WATIN I am able to hide the browser and my tests are a lot quicker. Now I am looking to do the same with selenium in c# if possible.
2 Answers
I don't know about C# unfortunately, but when using Selenium
in Java for my web tests, I use it with HtmlUnit, which is a GUI-less browser made specially for that. They may have a version for C# or not, I'm not sure.
I've found similar questions on SO though. I haven't read the answers, but you can:
-
We want to use a real browser so the tests are as valid as possible. thanks though – user880954 Nov 11 '11 at 16:29
-
HtmlUnit should be available. Your main concern about testing with HtmlUnit and not a real browser is that you're not validating your site against a browser you intend to support directly. No users will ever browse your site using HtmlUnit. The value of Selenium is getting real world user acceptance tests to validate, using HtmlUnit is a massive value loss. – Chris Marisic Nov 11 '11 at 16:30
-
1@user880954: a real browser is a real browser. No way to "hide" the UI (that I know of). – Guillaume Nov 11 '11 at 16:31
-
@Chris Marisic : I kind of disagree here. Selenium used in conjunction with HtmlUnit allows you to add your web acceptance tests to an automatic build (continuous integration) which is invaluable to me. I agree it is definitely interesting to have the possibility to run the same tests using a real browser (especially IE, that bugger) from time to time to validate complex AJAX interactions, but Selenium is done well enough to allow you to do that. – Guillaume Nov 11 '11 at 16:36
-
Selenium WebDriver will just as easily allow your CI server to robocall your web browser(s) of choice. – Chris Marisic Nov 11 '11 at 17:09
-
Really? in headless mode? I'll check it out then – Guillaume Nov 11 '11 at 17:10
-
@Guillaume It would most likely just need the ability to run processes interactively so it can truly launch the web browsers and drive them. But yes you should be able to use the real browsers with your CI server. – Chris Marisic Nov 14 '11 at 13:37
As @Guillaume answered, your choice is to use HtmlUnitDriver. However I would like to add that HtmlUnitDriver can simulate real browsers too, here is how you could do that in Java. I am not too familiar with c# bindings. I am sure there must be something similar.
HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
Or you could use the capabilities like below,
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setBrowserName("firefox");
capabilities.setVersion("3.6");
capabilities.setJavascriptEnabled(true);
HtmlUnitDriver driver = new HtmlUnitDriver(capabilities);
Note that this is not recommended, from the wiki page "You should not really be doing this, as web-applications are better coded to be neutral of which reasonably recent browser you are using."

- 14,131
- 7
- 65
- 79