Search code examples
jenkinsselenium-webdriverselenium-grid

Firefox Driver hangs on creation when using Jenkins node


I have just installed the Selenium Grid plugin for Jenkins and beginning to explore distributing tests with it. I have created a simple test that just opens a browser, gets a url, and then closes the browser. This seems to work for Chrome (on Mac) and IE (on Windows) but for some reason when using Firefox 18.0.2 on Mac, I see the browser window open but the url I'm supposed to load never shows up in the url bar and things hang and I get an error:

WebDriverException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:

It is hanging somewhere in the constructor to create the RemoteDriver. I added a trace statement right after the constructor and the code never gets there.

The weird thing is the test executes just fine if I start up a local Selenium Grid node on the same machine that fails and direct my tests there instead of the Jenkins Selenium Grid hub. So it seems to potentially be an issue with how I set up the Jenkins node but I can't figure out how to troubleshoot this. Any help would be appreciated.

My code is something like this:

WebDriver driver = null;

public Browser(String gridUrl) {
     driver = makeFirefox(gridUrl);
     driver.get(url);
}


private WebDriver makeFirefox(String gridUrl) {

      FirefoxProfile prof = new FirefoxProfile();
      prof.setEnableNativeEvents(true);

      DesiredCapabilities capabilities = DesiredCapabilities.firefox();
      capabilities.setCapability(FirefoxDriver.PROFILE, prof);

      WebDriver driver = null;
      try{
         driver = new RemoteWebDriver(new URL(gridUrl), capabilities);
      } catch (MalformedURLException e) {
         e.printStackTrace();
      }

      return driver;
   }

Solution

  • For anyone who runs into this, I was able to at least temporarily "solve" the problem by downgrading to Firefox 17. Things work fine there, just not Firefox 18.