我刚刚安装selenium-webdriver
(2.45.0)与capybara
(2.4.0)一起使用进行功能测试(版本来自bundle show
)。我从gemfile
中删除了这两个版本号,以确保我获得最新版本。当我收到此错误时,我搜索了SO并随后将Firefox
降级为版本33。
我已经阅读了所有"无法在60秒内获得稳定的firefox连接" SO上的帖子和主题通常是相同的 - selenium-webdriver
的版本不适用于最新版本的Firefox
。不幸的是,我已经尝试了所有建议并仍然得到相同的错误。
还有其他(非常基本的)我可能会遗漏的东西(记住我刚刚开始使用硒)吗?另请注意,我使用的是Cloud9 IDE。
更新 - 我的测试环境设置(为简洁起见删除了评论):
Rails.application.configure do
config.cache_classes = true
config.eager_load = false
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_dispatch.show_exceptions = false
config.action_controller.allow_forgery_protection = false
config.action_mailer.delivery_method = :test
config.active_support.test_order = :random
config.active_support.deprecation = :stderr
config.action_mailer.delivery_method = :test
end
答案 0 :(得分:1)
我几个月前遇到了同样的问题,我通过下载稳定版的firefox解决了这个问题,把它放到我的本地目录然后 在 - / featutes / support / env.rb文件中我设置了Selenium :: WebDriver :: Firefox :: Binary.path的路径
这是我的代码: ..............
Capybara.register_driver :selenium do |app|
Selenium::WebDriver::Firefox::Binary.path=("/localpath/firefox/firefox") if REGISTRY[:local_path_for_selenium] # I have used condition so it will not effect my production enviroment
profile = Selenium::WebDriver::Firefox::Profile.new
profile.assume_untrusted_certificate_issuer = false
profile.secure_ssl = false
http_client = Selenium::WebDriver::Remote::Http::Default.new
http_client.timeout = 410
Capybara::Selenium::Driver.new(app, :profile => profile,:http_client => http_client)
end
Capybara.default_driver = :selenium
.............