Question

I have a blog I'm working on and I added some javascript to make the form for the blog pop up when you click on new post. Everything works fine. I got tests working with minitest and capybara and I installed the gem selenium-webdriver everything works fine when I test it locally. However, when I push up to Github and travis-ci takes in my info and runs my tests it gives me this error

unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)

I'm a little confused because I was getting that error locally until I updated to the gem selenium-webdriver to version 2.39.0. I just downloaded firefox so as far as I know everything is up to date. here is some of my files if that helps.

my test

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 file

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

test helper file

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 full error

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)>'

does anyone understand why this works locally but not with travis-ci?

Was it helpful?

Solution

hey Reck you pointed me in the right direction; however, I found that the problem was in my .travis.yml file

if you go to

http://karma-runner.github.io/0.8/plus/Travis-CI.html

they will tell you that to set up travis to use firefox you need to add

before_script:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start

to your travis file.

after changing my .travis.yml file to

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

everything worked fine with travis

OTHER TIPS

Try setting transactional_fixture to false in your rspec_spec.rb:

config.use_transactional_fixtures = false
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top