2
votes

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 "[email protected]" 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?

2
What version of firefox are you using? I would get the lastest version of FF and download newest selenium drivers. More info here: stackoverflow.com/questions/12588082/…trueinViso
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
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 workRich Gray
I think you need to install selenium-client.trueinViso

2 Answers

2
votes

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/

0
votes

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