我正在使用 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/