栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

org.apache.http.conn.HttpHostConnectException:连接到localhost:19538 [localhost /0:0:0:0:0:0:0:0:1]失败:连接

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

org.apache.http.conn.HttpHostConnectException:连接到localhost:19538 [localhost /0:0:0:0:0:0:0:0:1]失败:连接

根据错误跟踪日志

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


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/386099.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号