How do I get the HTML in an element using Capybara?
You can call HTML DOM innerHTML Property: find(‘//tr[2]//td[7]’)[‘innerHTML’] Should work for any browser or driver. You can check all available properties on w3schools
You can call HTML DOM innerHTML Property: find(‘//tr[2]//td[7]’)[‘innerHTML’] Should work for any browser or driver. You can check all available properties on w3schools
This feature was added to Capybara on April 25th, 2011 with this commit – https://github.com/jnicklas/capybara/commit/a00435d63085ac2e74a0f64e7b7dedc0f7252ea9 You can can now specify a custom header when using a custom Capybara driver. See http://automagical.posterous.com/creating-a-custom-capybara-driver for code examples.
I use this to turn on ansi color interpretation in my compilation buffer: (require ‘ansi-color) (defun colorize-compilation-buffer () (let ((inhibit-read-only t)) (ansi-color-apply-on-region (point-min) (point-max)))) (add-hook ‘compilation-filter-hook ‘colorize-compilation-buffer)
The problem with the @wip tag, I’ve found, is that it doesn’t make your test suite yellow. It completely ignores the wip features, and you tend to forget they exist. This has bitten my team in the rear when scenarios are tagged as @wip and then forgotten. I wish there was a better solution. The … Read more
Then show me the page calls webrat/capybara’s underlying save_and_open_page method. Found that useful when working with steak.
You are getting the user and collecting it to new variable @user but while you are calling the sign_in method again you did initialize the new variable user with using(eg. @user)
You can click on an element via Capybara::Element.click. I add the following for this in my web_steps.rb to click on divs. When /^(?:|I )click within “([^”]*)”$/ do |selector| find(selector).click end There is also Element.trigger(‘mouseover’) which appears to enable hover albeit not working with Selenium. It is also very likely you will need to decorate your … Read more
Run Cucumber with rerun formatter: cucumber -f rerun –out rerun.txt It will output locations of all failed scenarios to this file. Then you can rerun them by using cucumber @rerun.txt
The correct way is to run it using the cucumber executable if you’re using Rails 2, or bundle exec cucumber if you’re using Rails 3 (and thus Bundler). To run a specific feature: [command] features/signing_in.feature To run a specific scenario from that feature: [command] features/signing_in.feature:6 The line number can be any line inside that feature, … Read more
Capybara is a tool that interacts with a website the way a human would (like visiting a url, clicking a link, typing text into a form and submitting it). It is used to emulate a user’s flow through a website. With Capybara you can write something like this: describe “the signup process”, :type => :feature … Read more