Questions tagged [capybara]

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

capybara
Filter by
Sorted by
Tagged with
2 votes
1 answer
2k views

How to inspect the session hash with Capybara and RSpec?

Found various posts about this on Stack Overflow, but didn't find a solution. From within an integration test, how to inspect the session hash with Capybara and RSpec? puts session.inspect throws an ...
B Seven's user avatar
  • 45.3k
2 votes
1 answer
2k views

Capybara ajax race conditions

I am frequently running into issues in capybara with request tests failing because capybara is not waiting for ajax events to complete before moving on. Google seems to indicate I should be using :...
Chris's user avatar
  • 6,196
2 votes
1 answer
3k views

Cucumber `press button` failure (Capybara::ElementNotFound)

I'm a relative newbie starting up a new Ruby on Rails app. I started by following a combination of instructions at https://github.com/intridea/omniauth, http://www.communityguides.eu/articles/16, ...
MacSean's user avatar
  • 251
2 votes
0 answers
426 views

Writing integration tests against external resources which are A/B testing

I have a bit of a design question and I'm curious if other users have run into this and how to develop the most elegant solution. I have some integration type feature tests in Cucumber using Capybara/...
Chet's user avatar
  • 21.7k
2 votes
2 answers
1k views

How do I attach a file when the input.file has a dynamic id?

I have run into a snag with dynamic ids. The attach_file command needs the id name of the input type="file". The problem is that the id is dynamic (id="document_22") #indicating the 22nd document ...
TangibleDream's user avatar
2 votes
2 answers
1k views

Using Capybara how would I would I overwrite an existing field value?

I am currently testing a form on a page with Capybara that has existing values filled out in the form's fields. I want to test being able to put new values into the fields and submitting the form with ...
jklina's user avatar
  • 3,417
2 votes
1 answer
206 views

Unexpected nil variable in RSpec

I have a very basic RSpec example that doesn't work. Here's the code: require 'spec_helper' describe "Referral-type functionality" do describe "Affiliate system" do before { @affiliate = ...
Eric Yang's user avatar
  • 1,879
2 votes
1 answer
262 views

autotest and rspec giving different answers

I have an application that I'm testing with rspec2 (2.6.4), capybara and selenium. When I run any request spec directly with rspec, the test passes. When I run the request specs with autotest ...
chrispanda's user avatar
  • 3,224
2 votes
3 answers
4k views

how to stop selenium chromedriver from logging to the screen

How do I stop selenium chromedriver from logging errors to the screen? I am running some cucumber tests and Im using capybara & the selenium chromedriver to drive the tests. In the last few ...
snowstreams's user avatar
2 votes
1 answer
6k views

Why i can not get current_user while writing test case with Rspec and Capybara

I have to write integration test case for my one feature listing page and that feature index method has code like below def index @food_categories = current_user.food_categories end Now when i try ...
Chirag Shah's user avatar
2 votes
1 answer
5k views

How correctly config rails test to run it in browser? ( site_prism, cucumber, capybara, selenium webdriver )

I am writing test for rails app, I use site_prism, capybara, selenium and cucumber. How can I setup Selenium driver to run my tests in browser (firefox)? For example, it is one of features: ...
bmalets's user avatar
  • 3,257
2 votes
1 answer
3k views

Test Alert Dialog Text Using Capybara Webkit 1.3.1

I'm looking to test the text in an alert dialog using Capybara Webkit. I'm aware of the accept_js_confirms and reject_js_confirms methods, but I'm looking to evaluate the contents of the dialog prior ...
Luke Keller's user avatar
  • 2,538
2 votes
2 answers
6k views

Rspec Capybara test with ajax call not updating record

I have a form where when a user submits an ajax form with a single name field, a record is created that belongs to a Template object. This all works fine manually, but for some reason when I test this ...
Matt Ramirez's user avatar
2 votes
1 answer
1k views

MiniTest, Capybara, Fixture, Database_Cleaner not passing at second time

The following test passed first time (after rake db:test:prepare) but failed gave error on subsequent run. Capybara::ElementNotFound: Unable to find css "#sale_payment_btn" require "test_helper" ...
Tun's user avatar
  • 1,397
2 votes
2 answers
1k views

Cucumber/Capybara: tests fail randomly under PhantomJS

When I run cucumber scenarios under PhantomJS I get Capybara::ElementNotFound: Unable to find css ".given_class" exceptions in random places it looks like driver does not wait for element ...
claveesh's user avatar
2 votes
1 answer
839 views

Capybara Poltergeist/PhantomJS testing - disable javascript on a page

On of my projects is fairly javascript intensive, so I have a <noscript> alert for users that might come in with Javascript disable on their browsers. I'm trying to write a test for my test ...
Bryce's user avatar
  • 2,832
2 votes
1 answer
861 views

Sending rails errors to rspec output

I am using Capybara in combination with rspec for integration testing of rails apps. I would like any errors (routing errors, errors in a controller, anything) generated during a test to be printed ...
Lee Quarella's user avatar
  • 4,732
2 votes
1 answer
1k views

Capybara won't fill in form fields (although it finds them)

I'm developing a Rails 4.2.1 using Ruby 2.2.1 and Capybara 2.2.4. Writing a spec to sign up users, Capybara does find the fields (I'm not getting the ElementNotFound Error) but when I try to validate ...
Hugo Carlos's user avatar
2 votes
1 answer
494 views

Capybara fill_in only works with field id, why?

While runnng my rspec tests, I was getting an error Capybara::ElementNotFound: Unable to find field "First Name" My rspec test is as follows describe "with valid information" do before do ...
Matthew's user avatar
  • 21
2 votes
1 answer
8k views

RSpec: Include a custom helper module in spec_helper.rb

I am trying to include a custom helper module in all my feature tests. I have tried creating the module in spec_helper.rb, but I get the following error: uninitialized constant FeatureHelper (...
Marco Prins's user avatar
  • 7,289
2 votes
0 answers
139 views

Why does visiting my root path require warmup time to make my test data available?

I am in the process of switching from capybara-webkit to poltergeist/phantomjs. I'm experiencing a timing problem and I've determined which line of code needs warmup time, but I can't determine why ...
John Bachir's user avatar
  • 22.6k
2 votes
2 answers
226 views

How can I protect my Capybara tests against arbitrary text changes?

In general I like how Capybara works. I just find it hard to believe that it's really a good idea to codify user-visible text in the tests; e.g. click_link('Delete', match: :first) OK, so I write my ...
sosiouxme's user avatar
  • 1,246
2 votes
2 answers
3k views

rails 3.1, capybara-webkit, how to execute javascript inside link?

Can I execute a javascript in a link with capybara click_link('next_page') ? The link looks like this: <a onclick="$('#submit_direction').attr('value', '1');$('#quizForm').submit()" id="next_page"...
simo's user avatar
  • 24k
2 votes
1 answer
662 views

Capybara cannot fill Stripe Checkout.js fields

I am having a difficult time testing Stripe's Checkout.js product with Capybara. The problem is Stripe has some tricky client side validation that fools Capybara's javascript driver, so when I tell ...
picardo's user avatar
  • 24.8k
2 votes
2 answers
711 views

RSpec + Capybara: How do I test a Bootstrap progress bar

I am testing a page that has a bootstrap progress bar using RSpec. How do I test the different Aria attributes in the Div? <div class="progress-bar progress-bar-success" role="progressbar" ...
learning_to_swim's user avatar
2 votes
1 answer
645 views

Capybara::ElementNotFound on all specs only on Travis

I'm using selenium, capybara with rspec for testing, i noticed all tests pass locally, but on travis all tests fail with this error on each spec. Capybara::ElementNotFound: I'm not sure what is ...
kebomix's user avatar
  • 846
2 votes
1 answer
1k views

Replacing text with regexp Ruby Capybara

I have a question running already linked to this problem, but this question is for a different approach. I have a string of text on a webpage that produces includes a timestamp (hhmmss) after a ...
Tom's user avatar
  • 1,075
2 votes
0 answers
281 views

How can I include javascript with javascript_include_tag at the top of the page for a capybara test

I am trying to test one javascript class in a spec test with capybara. I have static page player.haml in which I am loading the javascript class definition with javascript_include_tag. It looks like ...
Baruh's user avatar
  • 102
2 votes
5 answers
3k views

capybara can not find file input field to attach file

I use ruby, cucumber and capybara. My html looks like this: <tr> <th> Promotion codes </th><td><div class="t-zone" id="promocodesZone"&...
Slicey4's user avatar
  • 31
2 votes
2 answers
2k views

save_and_open_page has stopped serving up my css

My testing setup was working very nicely serving up pages correctly formatted with css whenever I called save_and_open_page from within a test. I then set up some javascript tests and made a few ...
brad's user avatar
  • 9,683
2 votes
1 answer
546 views

Models created with FactoryGirl aren't available in controller

Original question I'm trying to write some feature tests with RSpec and Capybara and wonder, why my gon object is always empty allthough it was set in my controller: app/controllers/...
Slevin's user avatar
  • 4,364
2 votes
1 answer
1k views

create a post request using poltergeist and capybara

I'm transitioning from Capybara backed by the default Rack driver to Capybara backed by Poltergeist. For frustrating reasons, I need to manipulate session data before loading a page. But I couldn't ...
chadoh's user avatar
  • 4,353
2 votes
3 answers
2k views

How to get poltergeist/PhantomJS to delay returning the page to Capybara until AJAX is loaded?

How do I keep PhantomJS from returning the page to Capybara for several seconds to allow AJAX to finish loading? The HTML body I am getting back is: <!--div class='loading'>PLEASE WAIT WHILE ...
bkunzi01's user avatar
  • 4,543
2 votes
1 answer
1k views

attach_file isn't working the right way with capybara-webkit

I'm trying to attach some files to this input: <input type="file" name="image" multiple="" accept="image/*"> My code, that is working when I use selenium driver, is: attach_file('image', File....
fabdurso's user avatar
  • 2,406
2 votes
2 answers
2k views

How to use Cucumber to test non-Ruby, non-Rack API's

I use cucumber for lots of things. I really like it as a BDD environment. So I'd like to use it as an external tool to test an API. I'd like to do things like: Scenario: Hit api /info path and get ...
Kevin Bedell's user avatar
  • 13.4k
2 votes
1 answer
3k views

Difference between click_on and click_link?

I am writing request specs and I am using poltergeist-1.0.2 and capybara-1.1.2. I have the following code: login_as @user, 'Test1234!' click_on 'Virtual Terminal' the login has flash message ...
Tsvetelina Borisova's user avatar
2 votes
0 answers
315 views

Capybara selecting root node rather than specified node

When running locally, the code works as expected, but when running on CI server (circle CI) it behaves strangely. I call the #find method passing in a css selector, this normally returns the specific ...
Shiyason's user avatar
  • 771
2 votes
3 answers
4k views

Testing views with will_paginate Gem using Capybara/Rspec

Doing Michael Hartl's Rails Tutorial, on chapter 10, section 5, exercise 2. I am - very simply - trying to write tests to ensure that a pagination div appears on a couple pages using the will_paginate ...
toblerpwn's user avatar
  • 5,465
2 votes
0 answers
2k views

Rails, Rspec, Capybara::ElementNotFound: Unable to find link or button

I have an rspec test in rails that keeps failing, it says: Failure/Error: click_on "New Part" Capybara::ElementNotFound: Unable to find link or button "New Part" Here is my spec file: require ...
PFKrang's user avatar
  • 259
2 votes
1 answer
571 views

Capybara with Rails: how to find ONLY invisible elements

I am using Capybara(capybara 3.1.0) for system tests in Rails project(Rails 5.2.0). What is the way to ensure element is not visible. I was using the visible: false option until I just found it ...
Jeni's user avatar
  • 1,088
2 votes
0 answers
226 views

Using Capybara-Webkit, Inject Javascript before client code runs

Is there a way to inject the javascript sooner? visit("/path/to/my/page") page.execute_script("document.getElementsByTagName('html')[0].className += ' hybrid-app';") I'm testing some things that ...
Onato's user avatar
  • 10.1k
1 vote
1 answer
1k views

Check page response on multiple pages with Capybara

I'm using Capybara with Ruby on Rails to create an integration test that will fill in all of the fields and submit the form. This will then load a new page to the browser. Is it possible to get the ...
Kishan's user avatar
  • 43
1 vote
0 answers
123 views

Redirect_to sign in page if AJAX call is not authorized

I have a form and when you click submit it will make an AJAX call to update the thing you want to change. My user session expires in 4 hours, so if the user wants to update the form and his session ...
marimaf's user avatar
  • 5,400
1 vote
0 answers
125 views

Different configurations for features test and rspec

I'm facing a strange issue after updated rails from 4.2 to 5.2. My features test needs following configuration to run config.redis_config = { driver: :hiredis, host: ENV['REDIS_HOST'] || 'redis', ...
Asnad Atta's user avatar
  • 3,933
1 vote
1 answer
1k views

Capybara & rspec combination can't work together, hanging on it for 2 days

I am new to capybara & rspec and i wrote a simple test(under spec/requests) to test the my root path: # encoding: utf-8 require 'spec_helper' describe "select a course" do before { visit ...
tomwang1013's user avatar
  • 1,405
1 vote
1 answer
182 views

Capybara RSpec empty html - Nokogiri::CSS::SyntaxError: unexpected '$' after ''

I have a simple web test scenario with Capybara running webrick and poltergeist, but it is driving me mad: let(:person) { create(:person) } scenario 'works with their password', js: true do # ...
xeruf's user avatar
  • 2,852
1 vote
1 answer
2k views

RSpec tests pass in isolation, but fail when run together

In my code_controller_spec.rb my tests pass when I just run the tests in code_controller_spec.rb. However, when I run the suite, only the create, edit, and update tests fail within ...
kyle's user avatar
  • 207
1 vote
1 answer
1k views

Does site_prism allow using other selectors than CSS?

I'm researching gems that allow me to use Page Object Pattern along Capybara. I found out site_prism and looks very promising. My question is, is there a way to define elements with selectors other ...
adids's user avatar
  • 137
1 vote
1 answer
1k views

Error using capybara-webkit (really QtWebKit webkit_server) on MacOS X due to libpng version incompatibility

I get the following error when trying to execute any capybara test using the capybara-webkit driver: dyld: Library not loaded: /usr/X11/lib/libpng15.15.dylib Referenced from: /usr/local/Cellar/...
Chris Hart's user avatar
  • 2,163
1 vote
3 answers
3k views

Capybara with headless chrome doesn't clear session between test cases which use different subdomains

I switched my rails tests from capybara-webkit to headless chrome. When I run a test which visits not the default Capybara host the first case passes but the second one fails because the user are ...
Hirurg103's user avatar
  • 4,913

1
6 7
8
9 10