java - 执行 Selenium WebDriver 测试期间,Firefox 已打开,但地址栏上未输入 URL

标签 java eclipse firefox selenium-webdriver testng

我正在使用 Selenium WebDriver 进行自动化测试。
IDE:eclipse
测试框架:TestNG
语言:Java

WebDriver driver = = new FirefoxDriver();

运行测试后发现如下错误:

[TestNG] Running:
  /tmp/testng-eclipse-2118619437/testng-customsuite.xml

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms

有人可以帮我吗?

最佳答案

您是否使用代理连接到互联网?如果是,那么您需要为您的 FF 驱动程序设置代理。

首先,您需要导入 Proxy 类 -

import org.openqa.selenium.Proxy;

然后,您需要创建 Proxy 类的实例并在其上设置代理 -

proxy= new Proxy();
proxy.setHttpProxy("10.1.2.47:80");

现在,创建 FF 驱动程序的实例,它应该可以正常工作。

关于java - 执行 Selenium WebDriver 测试期间,Firefox 已打开,但地址栏上未输入 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11188235/

相关文章:

javascript - 当 Firebug 运行时,jQuery 在 Firefox 中工作,当 Firebug 未运行时,jQuery 不起作用

html - 分区 :hover only working with mouse down in firefox and safari

java - 连接到 MS Access 数据库时出错

java - 如何解决这个没有为 Maven 上的构建指定目标?

java - 使用 ArrayLists 快速排序

java - OSGi 包未启动 : missing requirement osgi. wiring.package; > &(osgi.wiring.package=org.apache.felix.dm)

java - 使用 Eclipse 在第一个 Maven 项目中构建失败

java - 多线程中的多个选择器

eclipse - 不使用 Eclipse 运行 Selenium 测试用例/套件

html - Firefox 不水平扩展包含自动宽度图像的 DIV 容器