Hello i can't test my junit this my error when i try to compile if someone can help me thank you
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
Here is code for your reference: Note : It works fine on mac when i build with Junit
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.
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:
127.0.0.1 localhost.localdomain localhost #or 127.0.0.1 localhost loopback
Ensure the GeckoDriver-Firefox Mapping
Test
as a non-root user.The answer of Wojciech-Kopec helps me solve this issue, that maybe u not install Microsoft Visual Studio redistributable yet
Try to download and install the appropriate .exe file here
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.