[英]error“ org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/” with GeckoDriver and Firefox
Hello i can't test my junit this my error when i try to compile if someone can help me thank you你好,我无法测试我的 junit 这是我尝试编译时的错误,如果有人可以帮助我,谢谢
org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:18218 Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z' System info: host: 'UTILISA-3AHNTLM', ip: '10.2.10.137', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191' Driver info: driver.version: FirefoxDriver
org.openqa.selenium.WebDriverException:java.net.ConnectException:无法连接到 localhost/0:0:0:0:0:0:0:1:18218 构建信息:版本:'3.14.0',修订: 'aacccce0',时间:'2018-08-02T20:05:20.749Z' 系统信息:主机:'UTILISA-3AHNTLM',ip:'10.2.10.137',os.name:'Windows 10',os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191' 驱动信息: driver.version: FirefoxDriver
Here is code for your reference: Note : It works fine on mac when i build with Junit这是供您参考的代码:注意:当我使用 Junit 构建时,它在 mac 上运行良好
package ca.qc.grasset_420_pa4_ag.lab05.authentification;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import ca.qc.grasset._420_pa4_ag.lab05.commons.AbstractFunctionalTest;
public final class InvalidUsernameLoginTest
extends AbstractFunctionalTest {
public InvalidUsernameLoginTest() {
super();
}
@Test
public void test() {
getDriver().get("https://the-internet.herokuapp.com/");
getDriver().findElement(By.linkText("Form Authentication"))
.click();
getDriver().findElement(By.id("username"))
.click();
getDriver().findElement(By.id("username"))
.clear();
getDriver().findElement(By.id("username"))
.sendKeys("fdjkfgjkgfhkgf");
getDriver().findElement(By.id("password"))
.click();
getDriver().findElement(By.id("password"))
.clear();
getDriver().findElement(By.id("password"))
.sendKeys("SuperSecretPassword!");
getDriver().findElement(
By.xpath(
"(.//*[normalize-space(text()) and normalize-space(.)='Password'])[1]/following::button[1]"))
.click();
validate();
}
@Override
protected void validate() {
WebElement element = getDriver().findElement(By.xpath("//*[@id=\"flash\"]"));
String actualMessage = element.getText();
Assert.assertTrue("Your username is invalid!\n×".equals(actualMessage));
}
}
This error message...这个错误信息...
org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:18218
...implies that the ConnectException was raised while initializing the WebDriver session. ...暗示在初始化WebDriver会话时引发了ConnectException 。
Some more information regarding the binaries you are using might have been helpful to debug this issue which are as follows:有关您正在使用的二进制文件的更多信息可能有助于调试此问题,如下所示:
Some of the potential solutions to your issue are:您的问题的一些潜在解决方案是:
Ensure that /etc/hosts
on your system contains the following entry:确保系统上的
/etc/hosts
包含以下条目:
127.0.0.1 localhost.localdomain localhost #or 127.0.0.1 localhost loopback
Ensure the GeckoDriver-Firefox Mapping确保 GeckoDriver-Firefox 映射
Test
as a non-root user.Test
。The answer of Wojciech-Kopec helps me solve this issue, that maybe u not install Microsoft Visual Studio redistributable yet Wojciech-Kopec的回答帮助我解决了这个问题,也许你还没有安装Microsoft Visual Studio 可再发行组件
Try to download and install the appropriate .exe file here尝试在此处下载并安装相应的 .exe 文件
Hope this helps!希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.