2

I just want to get my cucumber test to accept a confirm dialogue, with my cucumber test, I've installed selenium-webdriver and it gives me this error:

unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)

I tried running gem update selenium-webdriver, and that didn't work.

Here is my the feature file:

Feature: Delete User In order to remove an exisiting user As a user I want to be able to remove a user from the database

Scenario: User successfully deletes another user
    Given I am currently on the Users page
    When I select a user to delete
    Then the user should no longer visible on the users page

Here is relevant part of the steps file:

Feature: Delete User, Scenario: User successfully deletes another user

When /^I select a user to delete js: true$/ do page.evaluate_script('window.confirm = function() { return true; }') find(:xpath, "//a[@href='/users/2?page=1' and @data-confirm='Are you sure?']").click end

Then /^the user should no longer visible on the users page$/ do expect(page).to have_no_content "cwl0@aber.ac.uk" end

Here is the env.rb file:

require 'cucumber/rails' require 'selenium-webdriver'

Dir["../../spec/factories/*.rb"].each {|file| require_relative file }

ActionController::Base.allow_rescue = false

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 = :transaction rescue NameError raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." end

Before do DatabaseCleaner.start load Rails.root.join('db/seeds.rb') end

After do |scenario| DatabaseCleaner.clean end Cucumber::Rails::Database.javascript_strategy = :truncation

And here is the gemfile:

source 'https://rubygems.org'

gem 'thin'

gem 'paperclip', '~> 4.1'

gem 'simple-navigation'

gem 'will_paginate', '~> 3.0'

Required by Windows and some Linux platforms when running with Rails 4.1.5!

gem 'tzinfo-data'

Bundle edge Rails instead: gem 'rails', github: 'rails/rails'

gem 'rails', '4.1.5'

Use sqlite3 as the database for Active Record

gem 'sqlite3'

Use SCSS for stylesheets

gem 'sass-rails', '~> 4.0.3'

Use Uglifier as compressor for JavaScript assets

gem 'uglifier', '>= 1.3.0'

Use CoffeeScript for .js.coffee assets and views

gem 'coffee-rails', '~> 4.0.0'

gem 'oauth', '~>0.4.6'

See https://github.com/sstephenson/execjs#readme for more supported runtimes

gem 'therubyracer', platforms: :ruby

Use jquery as the JavaScript library

gem "jquery-rails", "~> 2.3.0" gem 'jquery-ui-rails', '4.1.2'

Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks

gem 'turbolinks'

Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder

gem 'jbuilder', '~> 1.2'

group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false end

group :test do gem 'cucumber-rails', :require => false gem 'launchy' gem 'database_cleaner' gem 'selenium-webdriver', "~> 2.38.0" gem 'rspec-rails', '~> 3.0.0' gem 'factory_girl_rails' end

Please can someone suggest the best way of testing this feature, which allows me to accept the confirm dialogue?

Rich Gray
  • 191
  • 2
  • 11
  • What version of firefox are you using? I would get the lastest version of FF and download newest selenium drivers. More info here: http://stackoverflow.com/questions/12588082/webdriver-unable-to-connect-to-host-127-0-0-1-on-port-7055-after-45000-ms – trueinViso Nov 18 '14 at 02:27
  • Just tried to update to the latest selenium driver with bundle update, and its giving me another error now, what a nightmare: An error occurred while installing ffi (1.9.6), and Bundler cannot continue. Make sure that `gem install ffi -v '1.9.6'` succeeds before bundling. – Rich Gray Nov 18 '14 at 11:06
  • ok managed to fix the ffi problem (hopefully), updated latest version of firefox and selenium, still getting the same problem. I'm not sure if I need to explicitly state that the tests should use selenium, or if I need to include something in the tests that use it, but it still doesn't work – Rich Gray Nov 18 '14 at 11:30
  • I think you need to install selenium-client. – trueinViso Nov 18 '14 at 17:41
  • https://github.com/cucumber/cucumber/wiki/Setting-up-Selenium – trueinViso Nov 18 '14 at 17:41
  • Just installed selenium-client, that doesn't work either. I also tried to use capybara-webkit today, but that gave me a different error which also seemed unsolveable, it was trying to connect to the users page using https and failed – Rich Gray Nov 18 '14 at 18:10
  • What version of JRE are you running? – trueinViso Nov 18 '14 at 18:31
  • Also is there a reason you are using version 2.38 of selenium-webdriver? The latest version is 2.44 – trueinViso Nov 18 '14 at 18:34
  • java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) – Rich Gray Nov 18 '14 at 19:57
  • I had specified version 2.38 of selenium-webdriver to try and fix the problem, as per a suggestion I found online, this didn't work, so I now have the latest version installed again – Rich Gray Nov 18 '14 at 19:59
  • When I tried with capybara-webkit it seemed to fail due to being unable to open the users page via https. To get the other tests which just use capybara running I have had to comment out a couple of lines to do with ssl: force_ssl except: [:destroy] (in sessions_controller), and: return unless config.use_ssl (in force_ssl_extension, under config/initializers). I wonder if the error with capybara-webkit is due to the ssl configuration and the fact that it doesn't work with https, but I'm not sure how to get it working with https even if that is the problem – Rich Gray Nov 18 '14 at 20:06

2 Answers2

2

Check the version of selenium-webdriver that you are using compared to your version of Firefox for compatibility and make the appropriate version change in your gemfile.lock file. https://selenium.googlecode.com/git/rb/CHANGES

Older Firefox versions can be found here https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/

Jarod Adair
  • 419
  • 2
  • 8
  • Thanks for this, I managed to get it partly working by rolling back to Firefox 25, but it still doesn't work properly. It manages to log a user in, but doesn't get any further than that in the javascript test, when it supposed to open the users page after logging in. – Rich Gray Nov 22 '14 at 16:18
0

In your Gemfile have the following:

group :test do
  gem "capybara"

  # selenium webdriver is a dependency of Capybara. However it needs updating
  # much more frequently to keep up with firefox. Including it in the Gemfile
  # allows us to run 'bundle update selenium-webdriver' when this happens.
  gem 'selenium-webdriver'
end

Then follow the instructions in the comment i.e. run

bundle update selenium-webdriver
diabolist
  • 3,990
  • 1
  • 11
  • 15