[英]Selenium::WebDriver::Error::UnknownError: Invalid Content-Type
In my Ruby on Rails 5 app I have the following test that started failing without any changes to the code:在我的 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
it returns the following error:它返回以下错误:
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)>'
Any ideas what can cause this strange behavior?有什么想法会导致这种奇怪的行为吗?
I had the same problem with our Docker-based CI setup.我在基于 Docker 的 CI 设置中遇到了同样的问题。 I was able to fix it by specifying the version of the Selenium image that Capybara talks to.我可以通过指定 Capybara 与之交谈的 Selenium 图像的版本来修复它。
So in the docker-compose.yml
our configuration went from:所以在docker-compose.yml
我们的配置来自:
firefox:
image: selenium/standalone-firefox
volumes:
- /dev/shm:/dev/shm
To:至:
firefox:
image: selenium/standalone-firefox:3.11
volumes:
- /dev/shm:/dev/shm
In addition to the above, we specified the versions of capybara
and selenium-webdriver
in the Gemfile
for this project to give us certainty about compatibility.除了上述之外,我们在此项目的Gemfile
中指定了capybara
和selenium-webdriver
的版本,以便我们确定兼容性。 We will upgrade them all in lockstep in the future, but this is a good way to keep things working in the meantime.我们将在未来同步升级它们,但这是同时保持工作正常的好方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.