capybara

create a post request using poltergeist and capybara

杀马特。学长 韩版系。学妹 提交于 2020-02-24 12:01:32
问题 I'm transitioning from Capybara backed by the default Rack driver to Capybara backed by Poltergeist. For frustrating reasons, I need to manipulate session data before loading a page. But I couldn't figure out how to manipulate the session directly with the Rack driver, so I Capybara.current_session.driver.submit :post, "/current_search", {:session => :data } Unfortunately, the Poltergeist driver object has no submit method, as the Rack driver had. There are three possibilities: How do I

How to reuse scenarios within different features with rspec + capybara

荒凉一梦 提交于 2020-02-01 03:42:24
问题 Say I have some scenarios that I want to test under different contexts, or "features". For example, I have scenarios which involve the user visiting certain pages and expecting certain ajax results. But, under different conditions, or "features", I need to perform different "background" tasks which change the state of the app. In this case I need to run the same scenarios over and over again to make sure that everything works with the different changes to the state of the app. Is there a way

Disabling JavaScript when using Capybara + Selenium

回眸只為那壹抹淺笑 提交于 2020-01-29 17:45:26
问题 I have an app that's designed to still be functional when JavaScript is disabled, so I wanted to write some specs that covered those cases. I'm using Selenium (Firefox) with Capybara and I'm registering an new driver with JavaScript disabled (via Selenium's javascript.enabled property) # spec/rails_helper.rb Capybara.configure do |config| config.ignore_hidden_elements = true config.default_driver = :selenium end Capybara.register_driver :disable_js do |app| profile = Selenium::WebDriver:

rails tutorial expected css title with text to return something

好久不见. 提交于 2020-01-24 01:24:09
问题 I am working through the RoR tutorial at ruby.railstutorial.org and am currently on chapter 4. The tests aren't validating and I have no idea why. Top part of my spec file looks like this. The other methods all look identical to Help: describe "StaticPages" do let(:page_title) {"Ruby on Rails Tutorial Sample App"} let(:h1_test) {"should have the h1"} let(:title_test) {"should have the title"} describe "Home page" do |title_test, h1_test| it "#{h1_test} 'Sample App'" do visit '/static_pages

Selenium doesn't work with Cucumber/Capybara (out of the box) - MacOSX

安稳与你 提交于 2020-01-21 05:03:21
问题 I'm having trouble trying to get a cucumber example to run under selenium. I'm running Rails3 Cucumber 0.10.0 Capybara 0.4.1.2 Reading the doco on https://github.com/jnicklas/capybara, it would appear that all that I need to get an example to run under selenium is to do the following: Step 1: Prefix the scenario with @javascript @javascript Scenario: User does x ... Step 2: Configure env.rb to tell capybara which driver to use: Capybara.javascript_driver = :selenium When I run: bundle exec

How do I confirm a javascript popup with Capybara?

旧街凉风 提交于 2020-01-19 06:52:06
问题 I've tried several examples found online, but with no luck. I am looking to confirm the confirm message of a delete link. The last attempt was the code below, but that resulted in an Capybara::NotSupportedByDriverError error. def confirm_dialog page.evaluate_script('window.confirm = function() { return true; }') end 回答1: First of all switch to using Selenium as the driver by putting an @javascript tag in front of your scenario. The following code in your cucumber step will then confirm the

Rspec and capybara, difference between visit and get methods, with regards to the current_path object

狂风中的少年 提交于 2020-01-19 04:04:25
问题 I'm possibly confusing rack and capybara methods here let!(:admin){FactoryGirl.create(:admin)} # test passes describe "visiting #edit page" do before { visit edit_user_path(admin) } specify { current_path.should eq(edit_user_path(admin)) } end # test fails describe "getting #edit page" do before { get edit_user_path(admin) } specify { current_path.should eq(edit_user_path(admin)) } end The second test fails with: Failure/Error: specify { current_path.should eq(edit_user_path(admin)) }

Using cucumber with staging database without truncation and transactions

不打扰是莪最后的温柔 提交于 2020-01-17 06:58:32
问题 We have a Ruby on Rails 2.3.8 project, where data are almost exclusively read only. We would like to write acceptance tests which use staging database (copy of the production database) So we do not want to use transactions or truncation of the database tables before or after features and scenarios. Is it possible? 回答1: My solution was to switch DatabaseCleaner to transaction cleaning strategy in features/support/env.rb if defined?(ActiveRecord::Base) begin require 'database_cleaner'

Capybara::ElementNotFound on all specs only on Travis

浪尽此生 提交于 2020-01-15 08:15:35
问题 I'm using selenium, capybara with rspec for testing, i noticed all tests pass locally, but on travis all tests fail with this error on each spec. Capybara::ElementNotFound: I'm not sure what is wrong here, here is the specs runner on .travis.yml script: - xvfb-run bundle exec rspec spec/features/*.rb for spec_helper.rb here is my config: RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.use_transactional_fixtures = false config.infer_base_class

Cucumber `press button` failure (Capybara::ElementNotFound)

旧时模样 提交于 2020-01-15 05:41:07
问题 I'm a relative newbie starting up a new Ruby on Rails app. I started by following a combination of instructions at https://github.com/intridea/omniauth, http://www.communityguides.eu/articles/16, http://intridea.com/2011/1/31/easy-rails-admin-login-with-google-apps-and-omniauth?blog=company . At the point everything appeared to work correctly, I started to write my very first cucumber features and steps. I was able to get a couple of steps up and running, but I've been bogged down on a step