根据错误跟踪日志
Maven未能执行目标,如下所示:
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
其结果
org.testng.TestNGException如下:
[ERROR] org.testng.TestNGException:[ERROR] [ERROR] An error occurred while instantiating class buyer.testcases.solicitation.CreateSolicitation: null
其结果
org.openqa.selenium.WebDriverException:org.apache.http.conn.HttpHostConnectException如下:
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)
这是
driver.version:您的
WebDriver实例未被检测到的结果,如下所示:
[ERROR] Driver info: driver.version: PCDriver
造成这种情况的唯一原因是,按您的 开关(浏览器) ,你没有带设置的 系统属性 通过 System.setProperty()
解决方案:
一旦使用 switch (browser)
并定义 case "firefox"
等等,您需要进行
SystemProperty如下设置:
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确保
/etc/hosts
您的Linux Box
包含以下条目:127.0.0.1 localhost.localdomain localhost


![org.apache.http.conn.HttpHostConnectException:连接到localhost:19538 [localhost /0:0:0:0:0:0:0:0:1]失败:连接 org.apache.http.conn.HttpHostConnectException:连接到localhost:19538 [localhost /0:0:0:0:0:0:0:0:1]失败:连接](http://www.mshxw.com/aiimages/31/386099.png)
