在执行我的脚本时,脚本能够打开浏览器,但无法输入我使用 driver.get() 方法的 url。然后我尝试添加和增加 sleep 时间,之后我的脚本能够加载网址并且它按预期工作,但大多数时候它失败我不知道这是时间问题还是驱动程序问题,请建议我正确的解决方案。
使用的平台 - Windows 7 语言-java 工具 - Selenium Web 驱动程序 2.48.2 火狐-34.0
用于创建驱动程序实例的代码如下:
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver = new FirefoxDriver();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
driver.get(myurl);
}
错误日志如下:
Slenium web driver : Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output...and ...Receiving org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH)
最佳答案
我遇到了同样的问题,即无法在浏览器中加载baseurl...您需要替换
System.setProperty("webdriver.gecko.driver","C:\Marionette\geckodriver_1.exe");代替 System.setProperty("webdriver.firefox.marionette","C:/Users/admin/Downloads/geckodriver-v0.11.1-win32/geckodriver.exe");
或者尝试反向
关于java - Selenium 网络驱动程序 : Able to open Firefox browser but unable to load Url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40542082/