How to configure HtmlUnit Driver



  • I clearly missed a step trying to get HtmlUnit driver working with my app. I am getting the following exception:

    OpenQA.Selenium.WebDriverException was unhandled HResult=-2146233088 Message=Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:4444

    I am invoking the HtmlUnit driver with the follwing:

    IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
                                            DesiredCapabilities.HtmlUnit());
    

    I suspect I need to either use a different Uri or configure something else on my machine. I am running this on Windows 7 Pro x64 bit. Is there something I should be doing with the selenium-server-standalone-2.33.0.jar file?

    As a note things are working find with both the IE and Chrome web drivers. I am just experimenting with this as a solutions to see if it is faster.



  • The issue I had is that the HtmlUnit driver requires works a bit differently than the FireFox, Chrome or InternetExplorerDriver. Those drivers will get started by the application that is calling them. For this I actually had to start the stand alone server on my box. This was accomplished simply by navigating to the directory that contains the stand alone server jar and starting it. So for me this meant I had this: c:\Program Files (x86)\Selenium\Drivers>java -jar selenium-server-standalone-2.33.0.jar

    Then it was simply a matter of ensuring that the Uri I was using matches that shown in console window for the stand alone server for RemoteWebDriver instances.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2