[英]Selenium webdriver: Connection refused (connection refused) error in Ubuntu14.04
I'm trying to set up selenium webdriver3.4 in Ubuntu14.04 . 我正在尝试在Ubuntu14.04中设置Selenium webdriver3.4。 While running selenium script I'm getting HttpHostConnectionException error.
运行Selenium脚本时,出现HttpHostConnectionException错误。 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
[RemoteTestNG]检测到TestNG版本6.12.0 1507297197197 geckodriver INFO geckodriver 0.19.0 1507297197226 geckodriver INFO侦听127.0.0.1:13663失败的配置:@BeforeTest f org.openqa.selenium.WebDriverException:org.apache.http.conn.HttpHostConnectException:连接到localhost:13663 [localhost / 127.1.0.0]失败:连接被拒绝(连接被拒绝)构建信息:版本:'3.4.0',修订版本:'未知',时间:'未知'系统信息:主机:'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.version:FirefoxDriver
Please help me on troubleshooting this exception 请帮助我排除此异常
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. 它正在我的系统中运行,并且还使用其他URL运行。 I tried same code with another it is working fine.
我尝试与另一个相同的代码,它工作正常。 Change the port number of Localhost and try
更改Localhost的端口号,然后尝试
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);
}
}
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. 如果
127.0.0.1 localhost
有其他IP,请确保在/etc/hosts
输入了127.0.0.1 localhost
,然后将其删除。 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
连接到
localhost:13663 [localhost/127.1.0.0]
表示localhost
出于某种原因转到127.1.0.0
而不是127.0.0.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.