首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Selenium Webdriver升级(write_timeout错误)

Selenium Webdriver升级(write_timeout错误)
EN

Stack Overflow用户
提问于 2019-02-21 21:51:44
回答 1查看 1.3K关注 0票数 5

我正在尝试从ruby 2.4.4升级到ruby 2.6.1,而我的支持Javascript的黄瓜测试都不起作用。在运行黄瓜测试时,我得到以下错误:

代码语言:javascript
复制
      unknown keyword: write_timeout (ArgumentError)
      ./features/support/env.rb:58:in `block in <top (required)>'
      ./features/support/sign_in_step_helper.rb:4:in `sign_in'
      ./features/step_definitions/session_steps.rb:2:in `"I log in"'
      features/quote_wizard/quotes_wizard.feature:40:in `When I log in'

write_timeout并不存在于整个项目的任何地方。

这就是我在features/support/env.rb中所拥有的(自动生成的评论被抑制):

代码语言:javascript
复制
require 'simplecov'
require 'cucumber/rails'
require 'capybara'
require 'capybara/dsl'
require 'capybara/cucumber'
require 'cucumber/rspec/doubles'
require 'selenium-webdriver'
require_relative './download_helper
SimpleCov.at_exit do
  puts 'Simplecov complete'
end

Capybara.default_max_wait_time = 5 

Capybara.register_driver :chrome do |app|
  options = Selenium::WebDriver::Chrome::Options.new(
    args: %w[no-sandbox disable-extensions headless] # Remove `headless` to view test runs in browser
  ) 
  options.add_argument('--window-size=1920,1080')
  options.add_preference(:download,
                         directory_upgrade:   true,
                         prompt_for_download: false,
                         default_directory:   DownloadHelper::DEFAULT_DIR)

  options.add_preference(:browser, set_download_behavior: { behavior: 'allow' })

  driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)

  bridge = driver.browser.send(:bridge)

  path = '/session/:session_id/chromium/send_command'
  path[':session_id'] = bridge.session_id

  bridge.http.call(:post,
                   path,
                   cmd:    'Page.setDownloadBehavior',
                   params: {
                     behavior:     'allow',
                     downloadPath: DownloadHelper::DEFAULT_DIR
                   })
  driver
end

Capybara.javascript_driver = :chrome

ActionController::Base.allow_rescue = false

:truncation instead.
begin
  DatabaseCleaner.strategy = :transaction
rescue NameError
  raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end

require 'constant_tables'
ConstantTables.load!
Cucumber::Rails::Database.javascript_strategy = :truncation, { except: ConstantTables.table_names }
World(FactoryBot::Syntax::Methods)

编辑:这是Gemfile的测试部分

代码语言:javascript
复制
group :development, :test do
  gem 'parallel_tests'
  gem 'site_prism'
  gem 'capybara-email'
  gem 'cucumber-rails', :require => false
  gem 'database_cleaner'
  gem 'factory_bot_rails'
  gem 'rspec-rails'
  gem 'rubocop-rails'
  gem 'rubocop-rspec'
  gem 'selenium-webdriver'
  gem 'shoulda'
  gem 'timecop'
  gem 'chronic'
  gem 'sinatra', '~> 2.0.0.rc2'
  gem 'simplecov', :require => false
  gem 'paratrooper', '3.0.2'
  gem 'platform-api', '2.0'
  gem 'activerecord-import'
  gem 'rb-readline'
end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-21 22:04:16

我认为你应该升级你的宝石,看看这个

网模拟

他们特别增加了对ruby2.6的支持,也许值得一试吗?你查过其他人了吗?

票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54816782

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档