我有一个我正在研究的博客,并且我添加了一些javascript,以便在您点击新帖子时弹出博客的表单。一切正常。我使用minitest和capybara进行测试,我安装了gem selenium-webdriver,当我在本地测试时,一切正常。但是,当我向Github推送并且travis-ci接收我的信息并运行我的测试时它会给我这个错误
unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)
我有点困惑,因为我在本地收到错误,直到我更新到gem selenium-webdriver到版本2.39.0。我刚刚下载了firefox,据我所知,一切都是最新的。这是我的一些文件,如果这有帮助。
我的考试
feature "as a student I want a working blog so people can post" do
# this is line 10
scenario "User can make a post", :js => true do
dude_sign_up
dude_log_in
visit posts_path
click_on "New Post"
create_post
page.must_have_content "Post was successfully created"
end
# this is line 19
的Gemfile
group :development, :test do
gem 'sqlite3'
gem 'minitest-rails'
gem 'launchy'
gem 'coveralls', require: false
gem 'minitest-rails-capybara'
gem 'turn'
gem 'pry'
gem "selenium-webdriver", "~> 2.39.0"
end
.travis.yml文件
language: ruby
rvm:
- "2.0.0"
env:
- DB=sqlite
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- rake minitest:features
bundler_args: --binstubs=./bundler_stubs
测试帮助文件
require 'simplecov'
SimpleCov.start 'rails'
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rails/test_help"
require "minitest/rails"
require "minitest/rails/capybara"
require 'selenium-webdriver'
require 'coveralls'
Coveralls.wear!
# To add Capybara feature tests add `gem "minitest-rails-capybara"`
# to the test group in the Gemfile and uncomment the following:
# require "minitest/rails/capybara"
# Uncomment for awesome colorful output
# require "minitest/pride"
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
class ActionDispatch::IntegrationTest
include Rails.application.routes.url_helpers
#include Capybara::RSpecMatchers
include Capybara::DSL
end
Turn.config.format = :outline
def dude_sign_up
visit new_user_path
fill_in "Name", with: "thedude"
fill_in "Email", with: "thedude@cool.com"
fill_in "Password", with: 'password'
fill_in "Bio", with: "the bio"
fill_in "Password confirmation", with: 'password'
click_on "Submit"
end
def dude_log_in
visit new_session_path
fill_in "Email", with: "thedude@cool.com"
fill_in "Password", with: 'password'
click_on "Log In"
end
def create_post
fill_in "Title", with: "this is a test title"
fill_in "Content", with: "oh how this is some crazzzzy content"
click_on "Create Post"
end
travis完整错误
test_0002_User can make a post 1:00:23.767 ERROR
unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)
Exception `Selenium::WebDriver::Error::WebDriverError' at:
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/firefox/launcher.rb:79:in `connect_until_stable'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/firefox/launcher.rb:37:in `block in launch'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/firefox/bridge.rb:24:in `initialize'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/common/driver.rb:31:in `new'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver/common/driver.rb:31:in `for'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/selenium-webdriver-2.39.0/lib/selenium/webdriver.rb:67:in `for'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/capybara-2.1.0/lib/capybara/selenium/driver.rb:11:in `browser'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/capybara-2.1.0/lib/capybara/selenium/driver.rb:43:in `visit'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/capybara-2.1.0/lib/capybara/session.rb:193:in `visit'
/home/travis/.rvm/gems/ruby-2.0.0-p353/gems/capybara-2.1.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
test/test_helper.rb:35:in `dude_sign_up'
test/features/blog_system_works_test.rb:12:in `block (2 levels) in <top (required)>'
是否有人理解为什么这在本地工作但与travis-ci无关?
答案 0 :(得分:6)
如果你去
http://karma-runner.github.io/0.8/plus/Travis-CI.html
他们会告诉你要设置travis使用firefox你需要添加
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
到你的travis文件。
将.travis.yml文件更改为后
language: ruby
rvm:
- "2.0.0"
env:
- DB=sqlite
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- rake minitest:features
bundler_args: --binstubs=./bundler_stubs
使用travis一切正常
答案 1 :(得分:0)
尝试在transactional_fixture
中将false
设为rspec_spec.rb
:
config.use_transactional_fixtures = false