在最近更新Ubuntu 16.04之后,Capybara硒Xvfb抛出文件结尾错误 [英] Capybara selenium xvfb throwing end of file error after recent update of Ubuntu 16.04

查看:90
本文介绍了在最近更新Ubuntu 16.04之后,Capybara硒Xvfb抛出文件结尾错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,在我的Ruby on Rails应用程序中,黄瓜测试正在使用 capybara gem并使用硒进行

Currently in my Ruby on Rails application cucumber test are being run with the capybara gem and using selenium.

最近,在将系统更新到Ubuntu 16.04之后,测试开始失败,并出现 EOFError:文件结尾已达到错误

Recently after a system update to Ubuntu 16.04 the tests started failing with EOFError: end of file reached errors

此外,它偶尔还会包含以下错误。

Additionally, it also occasionally includes the following error.

session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData": "frameId":"14314.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=54.0.2840.59)
(Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 4.4.0-43-generic x86_64) (Selenium::WebDriver::Error::SessionNotCreatedError)

This question also refers to something similar but with minitest.

这是我认为应该与之相关的部分capybara env.rb 文件:

This what I believe to be the relevant part of the capybara env.rb file:

require 'cucumber/rails'
require 'capybara'
require 'capybara/cucumber'
require 'capybara-screenshot'
require 'capybara-screenshot/cucumber'
require 'rails/test_help'
require 'minitest/rails'
require 'mocha/mini_test'
require 'headless'
require 'selenium-webdriver'
require 'rack_session_access/capybara'
require 'webmock/cucumber'
WebMock.allow_net_connect!
include Sprig::Helpers

ActionController::Base.allow_rescue = false
Dir.mkdir('test_result') unless File.exist?('test_result')
# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
 DatabaseCleaner.strategy = :truncation, { only: [] }
 DatabaseCleaner.clean_with :truncation, { only: [] }  

rescue NameError
  raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end

Capybara.register_driver :selenium do |app|
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = 15
  Capybara::Selenium::Driver.new(app, browser: :chrome, http_client: client)
end

Capybara.default_driver = :selenium
Capybara.javascript_driver = :selenium
Capybara.raise_server_errors = true
Capybara.default_selector = :css
Capybara.default_max_wait_time = 15
Capybara.save_and_open_page_path = 'tmp/capybara'

我查看了capybara-webkit宝石中的线程看起来很相关,但是我实际上并没有使用webkit。

I've looked over at a thread in the capybara-webkit gem that looks related, but I'm not actually using webkit.

任何帮助将不胜感激。

推荐答案

原来,我使用的是 chromedriver-helper 使用rbenv覆盖实际正在使用的chromedriver版本水豚和硒用于运行测试。 gem自述文件据说可以在Rails应用程序的上下文中尝试运行 chromedriver-update ,从而清除了所有内容。

Turns out I'm using a gem called chromedriver-helper that was using rbenv to override the version of chromedriver that was actually being used by capybara and selenium to run the tests. The gem readme said to try running chromedriver-update in the context of the rails app, which cleared everything up.

这篇关于在最近更新Ubuntu 16.04之后,Capybara硒Xvfb抛出文件结尾错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆