Selenium::WebDriver::错误:未知错误:无效的内容类型



在我的Ruby on Rails 5应用程序中,我有以下测试开始失败,代码没有任何更改:

require 'rails_helper'
RSpec.describe 'Agent Groups Index Page' do
let(:active_user) {FactoryBot.create(:agent)}
let(:user_group) {FactoryBot.create(:group, servicing_agent_id: active_user.id)}
let(:other_user) {FactoryBot.create(:agent, :other_agent)}
let(:other_group) {FactoryBot.create(:group, servicing_agent_id: other_user.id)}
let(:zip_code) {FactoryBot.create(:zip_code)}
before do
visit new_user_session_path
fill_in 'user_email', with: active_user.email
fill_in 'user_password', with: active_user.password
click_button 'Login'
end
context 'has no groups' do
before do
other_user
other_group
visit groups_path()
end
scenario 'sees empty list', js: true do
expect(page).to have_content 'No data available in table'
end
end
end

它返回以下错误:

Failure/Error: click_button 'Login'
Selenium::WebDriver::Error::UnknownError:
Invalid Content-Type
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/http/common.rb:81:in `new'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/http/common.rb:81:in `create_response'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/http/default.rb:104:in `request'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/bridge.rb:164:in `execute'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/w3c/bridge.rb:535:in `execute'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/remote/w3c/bridge.rb:358:in `click_element'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/selenium-webdriver-3.11.0/lib/selenium/webdriver/common/element.rb:72:in `click'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/capybara-3.0.2/lib/capybara/selenium/node.rb:94:in `click'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/capybara-3.0.2/lib/capybara/node/element.rb:133:in `block in click'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/capybara-3.0.2/lib/capybara/node/base.rb:83:in `synchronize'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/capybara-3.0.2/lib/capybara/node/element.rb:133:in `click'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/capybara-3.0.2/lib/capybara/node/actions.rb:58:in `click_button'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/capybara-3.0.2/lib/capybara/session.rb:740:in `block (2 levels) in <class:Session>'
# /Users/override23/.rvm/gems/ruby-2.5.1@-global/gems/capybara-3.0.2/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
# ./spec/support/helpers/session_helpers.rb:7:in `signin'
# ./spec/features/agents/groups/groups_index_spec.rb:11:in `block (2 levels) in <top (required)>'

你知道是什么导致了这种奇怪的行为吗?

我在基于Docker的CI设置中遇到了同样的问题。我能够通过指定与水豚对话的Selenium图像的版本来修复它。

因此,在docker-compose.yml中,我们的配置从:

firefox:
image: selenium/standalone-firefox
volumes:
- /dev/shm:/dev/shm

收件人:

firefox:
image: selenium/standalone-firefox:3.11
volumes:
- /dev/shm:/dev/shm

除上述内容外,我们在本项目的Gemfile中指定了capybaraselenium-webdriver的版本,以确保兼容性。我们将来会步调一致地对它们进行升级,但这是同时保持工作的好方法。

相关内容

最新更新