webrat

How do I check that a form is pre-populated with values using Cucumber and Webrat?

I am learning Cucumber and Webrat with Rails and would like some advice on the best way to test an "edit" form. When I browse to a user's profile I am presented with an edit form with the user's information pre-populated in the form fields. I would like to be able to test that the fields do in fact contain the information I expect. Here'...

Finding a label with Webrat that contains a link

So I'm doing BDD with Cucumber and have a form with checkboxes populated from a database. The labels for the checkboxes contain hyperlinks. So far, not too exotic (note, this is HAML and not Erb, but it should be readable enough for any Rails person): I would like my donation to support: %br - for podcast in @podcasts = check_box_ta...

selecting page elements with webrat

There is a list of products (html table). Each row has got product name and ends with 'add to cart' button. How to add 2 'coffee' and 3 'tea' in the cart from webrat? Corresponding html: <tr class="odd"> <td><img src="/images/menu_items_images/7/PICT0020_thumb.jpg" /></td> <td>cofee</td> <td>americano</td> <td>1...

Using webrat's contain(text) matcher with haml

I'm using the following webrat matcher: response.should contain(text) With the following haml: %p You have = current_user.credits credits I've written the cucumber step 'Then I should see "You have 10 credits"', which uses the webrat matcher above. The step fails, webrat does not find the text in the response because the ham...

Practicing BDD with integration tests -- do I need unit tests too?

At present, my development process flows like this: I describe the expected behaviour as an integration test using using WebRat I write the Ruby on Rails code to provide that behaviour, so passing the test I refactor, ensuring the tests still pass at the end of the process I write the next integration test It seems to me that by defi...

Cucumber/Webrat: follow link by CSS class?

Hello there, is it possible to follow a link by it's class name instead of the id, text or title? Given I have (haha, cucumber insider he?) the following html code: <div id="some_information_container"> <a href="edit" class="edit_button">Translation here</a> </div> I do not want to match by text because I'd have to care about the ...

How do I fill in a specific field in Webrat when several share the same name and id?

I'm just getting started with Cucumber and Webrat, and am adding feature specifications to an existing Rails application. One page in the app has multiple forms on it, representing different ways to build a new Character object. Here's a simplified example: <form id="adopt_character_form"> .... <input type="text" name="charact...

Checking an element is absent using WebRat

The following works just fine: Then /^I should see a button called "([^\"]*)"$/ do |name| response.should have_selector("li") do |li| li.should have_selector("a") do |a| a.should contain(name) end end end Now I need to complement it with a step like this: Then /^I should not see a button called "([^\"]*)"$/ do |name...

Error in webrat installation

I'm getting the following error when I'm trying to install webrat in my OS X, please suggest me how can i solve this problem. ERROR: Error installing webrat: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /System/Li...

Annoying Webrat/Selenium Warning when changing domain names

When I'm working with AJAX + Webrat in Selenium mode, I'll often have to specify real domains and subdomains. Consequentially I'll get this message a lot: 14:00:45.222 WARN - you appear to be changing domains from http://test.host:3001 to http://elabs.test.host:3001/dashboard this may lead to a 'Permission denied' from the...

Can't get webrat to work with a Rails 2.0.2 app

I have a simple test just to see if I can get webrat working that is failing. class AuthenticationTest < ActionController::IntegrationTest def test_logging_in_with_valid_username_and_password get login_url end end With the above all I get in the error message is: 1) Error: test_logging_in_with_valid_username_and_password(Authe...

Cucumber Table Diff and colspan

Hi guys, I love cucumber, and its table diff feature. But I, often use a td colspan to display the title of the table. And I can't seem to get the table diff to work when I use colspan. (Table diff expects a 2d array, and the colspan breaks it) Has anyone be able to get this to work. Thanks! Jonathan ...

Can I use Webrat for ASP.NET applications?

Does Webrat require that the web application be written in Ruby/Rails? I'd like to try it for writing tests against an ASP.NET web application. ...

jQuery UI Dialog Buttons Not Responding to click_button or selenium.click in Selenium/Webrat

Has anyone been able to get the jQuery UI Dialog buttons to respond to click_button or selenium.click? I can't seem to be able to get this to work. Basically, I'm trying to test a form in a jQuery UI Dialog in a Rails app using Cucumber/Webrat/Selenium. I have a page with many table rows, and each row on click fires off a dialog box w...

Using environment vars in non-rails cucumber test

I created a simple smoketest for a portal running java/tomcat/jahia (cms) fronted by cache servers and big ip. Cucumber + Webrat + Mechanize is a good fit for a simple smoketest of this setup. (and it has been very easy to get started). Right now I have hardcoded into /features/support/paths.rb the following lines: module NavigationHel...

Cucumber/webrat test fails after adding Subdomain-fu and redirection functionality

I added Subdomain-fu in my project. In ApplicationController I have before_filter which checks url and redirects app.com to www.app.com, www.subdomain.app.com to subdomain.app.com and checks account existence (redirects to home if not exists): before_filter :check_uri def check_uri if !subdomain? redirect_to http...

Cucumber + webrat + selenium, how do I ignore hidden text?

I am using Cucumber, webrat and selenium to test a web application. I use 'I should see "something"' to verify changes. However, in many places, text to be verified only changes from hidden to visible (this might be caused by removing 'hidden' class from itself or one of its ancestors). In this case, above test does not actually verify t...

Webrat verify content in iframe or frameset

I am using Cucumber + Webrat + Mechanize adapter and want to test contents of pages that are iframed or framed into the selected page. In other words: Scenario: View header on webpage Given I visit a page containing a frameset When there is a header frame Then I should see login details in frame header The problem is of course...

How do I click on a specific button using cucumber/webrat when the name of the button starts with the same word?

I have the following html with multiple inputs: <input type="submit" value="Save and close" name="commit"/> <input type="submit" value="Save" name="commit"/> and would like to use cucumber to test clicking on the "Save" button. However, when I do this in a cucumber test: When I press "Save" it clicks on the "Save and close" button,...

Webrat Mechanize outside of Rails

I'm trying to use Webrat in a standalone script to automate some web browsing. How do I get the assert_contain method to work? require 'rubygems' require 'webrat' include Webrat::Methods include Webrat::Matchers Webrat.configure do |config| config.mode = :mechanize end visit 'http://gmail.com' assert_contain 'Welcome to Gmail' I ...