Reputation: 3
I'm trying to set up selenium webdriver3.4 in Ubuntu14.04 . While running selenium script I'm getting HttpHostConnectionException error. Please find below the script that I have used and the error:
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class SampleTest {
WebDriver driver;
@BeforeTest
public void f() {
System.setProperty("webdriver.gecko.driver","/usr/local/bin/geckodriver");
driver = new FirefoxDriver();
}
@Test
public void approvelisting()
{
driver.get("https://<domain name>/");
driver.manage().timeouts().implicitlyWait(500, TimeUnit.SECONDS);
}
}
[RemoteTestNG] detected TestNG version 6.12.0 1507297197197 geckodriver INFO geckodriver 0.19.0 1507297197226 geckodriver INFO Listening on 127.0.0.1:13663 FAILED CONFIGURATION: @BeforeTest f org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:13663 [localhost/127.1.0.0] failed: Connection refused (Connection refused) Build info: version: '3.4.0', revision: 'unknown', time: 'unknown' System info: host: 'admin-coddletech', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-30-generic', java.version: '1.8.0_141' Driver info: driver.version: FirefoxDriver
Please help me on troubleshooting this exception
Upvotes: 0
Views: 19154
Reputation: 146520
Please make sure you have entry of 127.0.0.1 localhost
in /etc/hosts
if there is any other IP for localhost then remove it. Connect to localhost:13663 [localhost/127.1.0.0]
indicates localhost
is for some reason going to 127.1.0.0
instead of 127.0.0.1
Upvotes: 1
Reputation: 4739
I think your code is correct it seems your local host is not setup properly.
it is running in my system and it is also running with different URL. I tried same code with another it is working fine. Change the port number of Localhost and try
This is my code:
public class Stackoverflow_demo {
WebDriver driver;
@BeforeTest
public void f() {
driver = new FirefoxDriver();
}
@Test
public void approvelisting()
{
driver.get("http://127.0.0.1:8080/");
driver.manage().timeouts().implicitlyWait(500, TimeUnit.SECONDS);
}
}
Upvotes: 0