ruby-on-rails - Selenium Webdriver ruby​​ 升级(write_timeout 错误)

标签 ruby-on-rails ruby selenium selenium-webdriver cucumber

我正在尝试从 ruby​​ 2.4.4 升级到 ruby​​ 2.6.1,但我的所有支持 Javascript 的 Cucumber 测试都不起作用。运行 cucumber 测试时出现以下错误:

      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 中的内容(自动生成的注释被抑制):

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 的测试部分

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

最佳答案

我认为你应该升级你的 gem ,检查一下:

webmock

他们专门添加了对 ruby​​ 2.6 的支持,也许值得一试?你检查过其他人了吗?

关于ruby-on-rails - Selenium Webdriver ruby​​ 升级(write_timeout 错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54816782/

相关文章:

javascript - Rails 3 转义 html 标签在浏览器中作为 JSON 时未转义

ruby-on-rails - Rails/Ruby - 如何检查用户下载和上传速度?

java.lang.NoSuchMethodError : org. openqa.selenium.support.ui.Wait.until(Lcom/google/common/base/Function;)使用selenium-server-standalone-3.12.0

ruby - 带 Ruby 的吉他调音器

java - 如何使用 selenium java 将鼠标悬停在圆环图弧上?

javascript - 如何使用Appium在iOS设备上执行向左滑动

css - 在 Ruby on rails 错误中使用 Bootstrap

ruby-on-rails - 在 Rails 中,如何将多个模型关联到一个将统领所有模型的模型?

ruby - 无法运行 Jekyll 新命令

ruby-on-rails - 在 Ruby on Rails 中@或不@