capybara

How to put capybara output html to a specific folder?

When I use the "Show me the page" step, with Capybara / Cucumber, can I control where the files get output? I can't seem to find the config for this, and my google fu is failing me. Right now it appears that by default they go to the root of my rails folder and clutter up things there. ...

How to use Capybara in pure Ruby (without Rails)?

I'm trying to get Capybara running in a simple Ruby script -- i.e. without/outside of Rails. Here's the script: require 'rubygems' require 'capybara' require 'capybara/dsl' include Capybara Capybara.current_driver = :selenium Capybara.app_host = 'http://www.google.com' visit('/') The problem is that when I run this I get this error...

How can I get Capybara @javascript tags executing correctly in Cucumber on a Rails 3 project?

I've swapped out Webrat for Capybara on a new Rails 3 project. I ran through Tim Riley's great post on it here ( http://openmonkey.com/articles/2010/04/javascript-testing-with-cucumber-capybara ), and also cloned his repository, executed the example cucumber feature, and saw the browser window fire open. So the whole Cucumber, Capybara, ...

Rails 3 route name

Im using Cucumber + Capybara. This is how one of my step definitions looks like. When /^(?:|I )go to (.+)$/ do |page_name| visit path_to(page_name) end And here is my routing file: match "home" => "home#index" resources :searches root :to => 'firstpage#index' What is the name of a path? ...

Can I run multiple RSpec/Selenium tests in order without resetting browser state?

So I just started using Steak, which in turn uses Capybara, which in turn uses Selenium. So I've heard it's good RSpec practice to split testing into lots of little it-clauses, each testing a small piece of functionality. But then it makes a test run take a lot longer, because the same steps get repeated for each test. Say I'm testing...

How can I make cucumber with capybara and selenium fire Ajax on page load

I have the following as a cucumber story: @javascript Scenario: Showing the page Given I am a logged in user And there is a member with a site And I go to the home page ..... When that home page is loaded, there is a drop down that is populated via AJAX on page, in the selenium run browser test the $(document).ready(funtion...

Cucumber and Capybara, clicking a non-link or button element

I am trying to test an inplace editor using Cucumber/Capybara/Selenium stack, but my problem is that the editor is activated by clicking a div and not a link or button. I can not seem to figure out how to get Capybara to do this. Is there a way of doing this? ...

Is there a way to detect that I'm in a Selenium Webdriver page from Javascript

I'd like to suppress the initialization of TinyMCE inside my tests and can do this easily if the Javascript can detect that I'm running inside a Selenium-automated page. So, is there some JS code that I can use to detect the Selenium driver? Alternatively, how can I extend the userAgent string to include a pattern that I can detect from...

Cucumber,Capybara and ElementNotFound

In my rails application, I have a page with a link that execute a javascript function : <%= link_to_function("Add an address", "add_fields(this)".html_safe) %> In my cucumber feature I have : And I press "Add an address" And the message I get is : Capybara::ElementNotFound: no button with value or id or text 'Add an address' fou...

How to follow redirect from javascript in cucumber?

I have a a button (not a submit button) which does ajax calls before submitting another form. What I want to do is Given I am viewing homepage When I press "JustAButton" Then I should be on "/users/home" But the redirection happens somewhat late and "Then" statement fails considering that the page is still in homepage. How can I wait...

Log-in through authlogic without having to fill in form every time

I have a number of Cucumber scenarios which run with capybara on a project I am working on. Most of these scenarios start with a "Given I am logged in" step. Currently my implementation of this is: visit path_to('the login page') fill_in('Username', :with => 'user') fill_in('Password', :with => 'password') click_button('Login')...

How to solve a Capybara::ElementNotFound Error

Hi, I'm stuck with the following problem, this is the first time I use capybara, have you an idea how I can solve this issue, thanks I use rails 3.0.0 and the following gems gem 'rails', '3.0.0' gem 'capybara' gem 'database_cleaner' gem 'cucumber-rails' gem 'cucumber' gem 'rspec-rails' gem 'spork' gem 'launchy' I have the following ...

Can't get Cucumber script to pass when trying to follow a link in a table

I am using Rails 3 with Cucumber, Capybara and Factory_Girl. I am trying to test following the "Show" link for just one of the rows on an HTML table. I am using the syntax: And I follow "Show" within "Net 30" I gives me the following error: unexpected '30' after 'DESCENDANT_SELECTOR' (Nokogiri::CSS::SyntaxError) /System/Library/Fra...

How to verify the page title

I am using cucumber and capybara along with rails 2.3.9. How do I verify the page title. I try to have a good page title for every GET request and would like to verify that in my tests. ...

How to verify number of records using capybara

I am using capybara along with cucumber on a Rails 2.3.9 project. I have users index page and I have two records there. Using capybara how do I assert that there are only two records in the page. HTML structure is like this <div class='records'> <li>record 1<li> <li>record 2 </li> </div> ...

How to verify an link points to the right image and has the right target and title

I am using capybara with cucumber in rails 2.3.9 application. Here is my html code <a href="http://twitter.com/dorelal" target="_blank" title="twitter"> <img alt="twitter" src="/images/social/twitter.png?1284129939" /> </a> I want to verify following items image should be ending with twitter.png image alt should be "twitter" link ...

Rails3, Cucumber, Capybara, File upload => bad content body (EOFError) ?

I'm having a hard time getting a simple file upload test working. I'm using Rails 3.0.0 on ruby 1.9.2 with Cucumber and Capybara. View: <%= form_tag "/upload/create", :multipart => true do %> <label for="file">File to Upload:</label> <%= file_field_tag "file" %> <%= submit_tag "Upload" %> <% end %> Cucumber Step: When /^I upl...

Cucumber: how to switch sessions in Rails (multi-session)

I need to change session during one cucumber scenario. For example Given session name is "1st unauthenticated user" And make some things Given session name is "2st unauthenticated user" And make some other things I found a solution, but it doesn't work with Rails 3, Cucumber and Capybara. Are there any other solutions? ...

Cucumber + Spork = undefined method `visit' for #<Object:0x82fcc588> (NoMethodError) ???

I'm tearing my hair out here. When running Cucumber in Spork-compatible mode (--drb) the visit() method doesn't work. Simply trying the feature step: When I go to the home page calls web step: When /^(?:|I )go to (.+)$/ do |page_name| visit path_to(page_name) end Running "cucumber" on the command line produces the following err...

[Rails] Capybara doesn't recognize dynamically added DOM elements?

I seem to be having trouble testing the slick javascript things I do with jQuery when using Capybara and Selenium. The expected behavior is for a form to be dynamically generated when a user clicks on the link "add resource". Capybara will be able to click the link, but fails to recognize the new form elements (i.e. "resource[name]"). ...