Selenium + HtmlUnitDriver / GhostDriver is exactly what you are looking for. Oversimplified, Selenium is a library for using various browsers for automation - testing, cleaning, task automation.
There are various WebDriver classes with which you can control the actual browser. HtmlUnitDriver - headless. GhostDriver is a WebDriver for PhantomJS, so you can write C # while PhantomJS will do the hard work.
code snippet from Selenium docs for Firefox, but code with GhostDriver (PhantomJS) or HtmlUnitDriver is almost identical.
using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; class GoogleSuggest { static void Main(string[] args) {
If you run this on a Windows computer, you can use the actual Firefox / Chrome driver, because it will open the actual browser window, which will work as programmed in your C #. HtmlUnitDriver is the easiest and fastest.
I successfully ran Selenium for C # (FirefoxDriver) on Linux using Mono . I believe that HtmlUnitDriver will also work as well as others, so if you need speed, I suggest you switch to Mono (you can develop, test and compile using Visual Studio on Windows, no problem) + Selenium HtmlUnitDriver running on a Linux host without a desktop,
shturm
source share