从昨晚开始,FirefoxDriver 一直在这个页面打开:https://www.mozilla.org/en-US/firefox/42.0/firstrun/learnmore/
。我尝试过更改默认配置文件设置,但没有成功。
以下问题,http://stackoverflow.com/questions/33937067/firefox-webdriver-opens-first-run-page-all-the-time
,是类似的,但我这样做不知道在哪里实现这四行代码,我个人尝试将其放入我的脚本中已被证明是徒劳的。
这个问题昨晚完全是突然出现的。我今天有演示要做,但我的任何脚本都无法运行。
像这样实例化我的 WebDriver 实例将导致 NoSuchMethodError:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.startup.homepage", "about:blank");
profile.setPreference("startup.homepage_welcome_url", "about:blank");
profile.setPreference("startup.homepage_welcome_url.additional", "about:blank");
driver = new FirefoxDriver(profile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
但是在 FirefoxDriver
中删除 profile
会将其带回到上面提到的首次运行页面。
最佳答案
我在使用 Selenium Webdriver 和 Poltergeist 以及 Firefox 作为 Rails 应用程序的浏览器运行 RSpec/Capybara 测试时遇到了这个问题。尝试以各种方式重新配置 Firefox,但无济于事,但通过简单地更新我的 Gemfile 中的 selenium-webdriver gem 来修复(gem 'selenium-webdriver'
):
捆绑更新 selenium-webdriver
感谢@lucetzer
关于FirefoxDriver 总是从 "firstrun"页面开始,破坏了所有测试脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34069224/