Reputation: 201
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:
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
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'
gem 'tzinfo-data'
gem 'rails', '4.1.5'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'oauth', '~>0.4.6'
gem "jquery-rails", "~> 2.3.0" gem 'jquery-ui-rails', '4.1.2'
gem 'turbolinks'
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?
Upvotes: 2
Views: 1080
Reputation: 4099
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
Upvotes: 0
Reputation: 419
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/
Upvotes: 2