capybaracapybara is the next generation testing library for web apps acceptance testing. It took me 3 days to migrate 128 scenarios (806 steps) from webrat to capybara. Here are the problems I have encountered and how I solved them: have_tag matcherAPI: Rack::Test unofficial support for http vebs ssl_requirement plugincapybara does not play well with ssl_requirement (Rails plugin written by DHH) webrat had no problem with it so I suspect it is a capybara bug SslRequirement.module_eval do def ensure_proper_protocol true end end case sensitive texts symbol for ids in fill_in session_id changes when subdomain changes solution: Before do WirecardGateway.stub_xml_response_with 'wirecard_cc_success_response.xml' host! "wwww.betterplace.local" end Testing presence of imagesThen /^I should see the image "([^\"]*)"$/ do |file_name| page.should have_xpath("//*/img[contains(@src, '#{file_name}')]") end def should_have_exclamation_mark(selector, colour, scale) with_scope(selector) do src = exclamation_mark_src(colour, scale) page.should have_xpath(".//img[contains(@src, '#{src}')]") end end webratUse tag#id with have_tag matcherThen /^I should not see the payment option "([^\"]*)"$/ do |payment_option| response.should_not have_tag("input##{payment_option}") end Posted by Mike Gehard on Tuesday September 21, 2010 at 07:58AM Ever wanted to be able to debug an HTML page using the power of Firebug while running Cucumber/Capybara features/steps? Follow these simple steps and you can get it to work: 1) Create a new "WebDriver" Firefox profile using the instructions found here 2) Fire up Firefox using the newly created profile and install/configure Firebug the way you want it. See instructions above. 3) Run your Cucumber/Capybara steps and pause the feature using a sleep() statement long enough for you to poke around in the page with Firebug. **Note this has been proven to work on OS X, your mileage on other OS's may be limited. |