Questions tagged [capybara]

Capybara is a web application testing framework for Rack applications, such as Rails, Sinatra and Merb.

Capybara aims to simplify the process of integration testing Rack applications, such as Rails, Sinatra or Merb. Capybara simulates how a real user would interact with a web application. It is agnostic about the driver running your tests and currently comes bundled with rack-test, Culerity, Celerity and Selenium support built in.

A complete reference is available at rubydoc.info.
A great capybara cheat sheet is available here.

5916 questions
174
votes
6 answers

How can I check that a form field is prefilled correctly using capybara?

I have a field with a proper label that I can fill in with capybara without a problem: fill_in 'Your name', with: 'John' I'd like to check the value it has before filling it in and can't figure it out. If I add after the fill_in the following…
Marc-André Lafortune
  • 78,216
  • 16
  • 166
  • 166
154
votes
6 answers

How to get current path with query string using Capybara

The page url is something like /people?search=name while I used current_path method of capybara it returned /people only. current_path.should == people_path(:search => 'name') But it fails saying expected: "/people?search=name" got: "/people" How…
kriysna
  • 6,118
  • 7
  • 30
  • 30
148
votes
11 answers

How to select option in drop down using Capybara

I'm trying to select an item from a drop down menu using Capybara (2.1.0). I want to select by number (meaning select the second, third, etc option). I've Googled like crazy trying all sorts of things but no luck. I was able to select it by using…
Farooq
  • 1,925
  • 3
  • 15
  • 36
142
votes
7 answers

How to click first link in list of items after upgrading to Capybara 2.0?

How to click first link in that case: within ".item" do first(:link, "Agree").click end and I get this error: Capybara::Ambiguous: …
tomekfranek
  • 6,852
  • 8
  • 45
  • 80
135
votes
14 answers

How to check a checkbox in capybara?

I'm using Rspec and Capybara. How can I write a step to check a checkbox? I've tried check by value but it can't find my checkbox. I'm not sure what to do, as I have in fact same ID with different values Here is the code:
John Dow
  • 1,431
  • 2
  • 11
  • 8
127
votes
3 answers

RSpec: describe, context, feature, scenario?

describe, context, feature, scenario: What is the difference(s) among the four and when do I use each one?
Mike Glaz
  • 5,352
  • 8
  • 46
  • 73
120
votes
6 answers

How to find an element by matching exact text of the element in Capybara

I have following two elements in HTML Berlin Berlin Germany I am trying to find the element by using following Capybara method find("a", :text => "berlin") Above will return two elements because both…
amjad
  • 2,876
  • 7
  • 26
  • 43
118
votes
7 answers

ERROR: Error installing capybara-webkit:

Any suggestions on how to fix? gem install capybara-webkit -v '0.11.0' Building native extensions. This could take a while... ERROR: Error installing capybara-webkit: ERROR: Failed to build gem native extension. …
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
104
votes
9 answers

Capybara Ambiguity Resolution

How do I resolve ambiguity in Capybara? For some reason I need links with the same values in a page but I can't create a test since I get the error Failure/Error: click_link("#tag1") Capybara::Ambiguous: Ambiguous match, found 2 elements…
neilmarion
  • 2,372
  • 7
  • 21
  • 36
101
votes
9 answers

How to get parent node in Capybara?

I'm working with many jQuery plugins, that often create DOM elements without id or other identification properties, and the only way to get them in Capybara (for clicking for example) - is to get their neighbor (another child of its ancestor) first.…
sandrew
  • 3,109
  • 5
  • 19
  • 29
95
votes
5 answers

How to use fill_in with find in Capybara (if possible)

I'd like to do the following but can't due to the nature of fill_in expecting a locator as the first argument. find(:css, "input[id$='donation_pledge_hundreds']").fill_in :with => "10" I've also tried doing element = find(:css,…
ants
  • 1,097
  • 1
  • 7
  • 13
95
votes
7 answers

undefined method `visit' when using RSpec and Capybara in rails

I can't get capybara working with rspec. It gives me this error: undefined method `visit' for # I know there are lots of posts about this but non of the solutions are working for me. Most…
lightswitch05
  • 9,058
  • 7
  • 52
  • 75
93
votes
6 answers

How to assert number of elements using Capybara with proper error message?

I know that in Capybara, you can do something like this: page.should have_css("ol li", :count => 2) However, assuming that page has for instance only one matching element, the error is not very descriptive: 1) initial page load shows greetings …
merryprankster
  • 3,369
  • 2
  • 24
  • 26
93
votes
4 answers

Capybara: How do I fill in a input field by its ID

I have this:
How do I fill in a that field by…
Nerian
  • 15,901
  • 13
  • 66
  • 96
91
votes
10 answers

capybara assert attributes of an element

I'm using RSpec2 and Capybara for acceptance testing. I would like to assert that link is disabled or not in Capybara. How can I do this?
kriysna
  • 6,118
  • 7
  • 30
  • 30
1
2 3
99 100