org.apache.http.conn.HttpHostConnectException: Connect to localhost:19538 [localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) org.apache.http.conn.HttpHostConnectException: Connect to localhost:19538 [localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused) jenkins jenkins

org.apache.http.conn.HttpHostConnectException: Connect to localhost:19538 [localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)


As per the error trace logs Maven failed to execute the goal as follows :

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project com.perfect.wp: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process

Which was the result of org.testng.TestNGException as follows :

[ERROR] org.testng.TestNGException:[ERROR] [ERROR] An error occurred while instantiating class buyer.testcases.solicitation.CreateSolicitation: null

Which was the result of org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException as follows :

org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:15327 [localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)

Which is the result of driver.version: i.e. your WebDriver instance is not getting detected as follows :

[ERROR] Driver info: driver.version: PCDriver

The only reason for that is as per your switch (browser) you havn't set the System Property through System.setProperty()

Solution :

Once you use switch (browser) and define case "firefox" or so on you need to set the System Property as follows :

  • case "firefox":

    System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");//configuration starts here
  • case "chrome":

    System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");//configuration starts here
  • case "ie":

    System.setProperty("webdriver.ie.driver", "C:\\Utility\\BrowserDrivers\\IEDriverServer.exe");//configuration starts here
  • case "phantomjs":

    File path=new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");System.setProperty("phantomjs.binary.path",path.getAbsolutePath());//configuration starts here
  • Ensure that /etc/hosts on your Linux Box contains the following entry :

    127.0.0.1               localhost.localdomain localhost