capybara

testing with specs, capybara from railstutorial chapter 3 does not work (have_selector('title', :text => ' | Home'))

三世轮回 提交于 2020-01-01 08:44:45
问题 im working on ruby.railstutorial.org/ruby-on-rails-tutorial-book. Im using rails 3.2.7, spork, rspec, capybara, launchy and some guards :) i have a really weird problem in Chapter 3 with testing: It seems like the tests arent working for what is inside the <head> -Tag. If i put the <title> -tag inside the <body> -tag instead of the head-tag it works fine. Also it works when i put <h1> -tags above the <title> inside <head> -Tags. It is weird, isnt it? Please help me figur out. The example is

How do I find an image generated by Dragonfly with Cucumber/Capybara?

怎甘沉沦 提交于 2020-01-01 07:20:27
问题 In the comments to the solution for How do I find an image on a page with Cucumber/Capybara, somebody asked: I can't seem to figure how to get this to work with URLs generated by Dragonfly. They look like this: /media/BAh_some_long_string_AwIw/12_11_52_810_5x5.jpg?s=7e360000, where 5x5.jpg is my file name. I've tried something like: //img[@src="/media/ / #{image}?s=*"] but it doesn't work. Got any tips? – Ramon Tayag Feb 25 at 4:18 I have a similar problem, only worse - in my case, the

Capybara can find but not fill_in

為{幸葍}努か 提交于 2020-01-01 04:19:20
问题 I am having some very strange behaviour with Capybara. It stubbornly refuses to fill in the fields of my login form. <fieldset> <div class="clearfix"> <label for="user_email">E-Mail Adresse</label> <div class="input"> <input id="user_email" name="user[email]" size="30" type="email" value=""> </div> </div> <div class="clearfix"> <label for="user_password">Passwort</label> <div class="input"> <input id="user_password" name="user[password]" size="30" type="password" value=""> </div> </div> <div

Unable to trigger mouse event in Capybara test

≡放荡痞女 提交于 2020-01-01 03:59:10
问题 I am using Capybara 1.0.0, and I have a link in my page which gets visible when mouse hover over that block. So I want to trigger mouse over in test so that I can click that hidden link. I googled it, but couldn't find the solution that suits me. Can you guys help me with this? 回答1: I've chosen to use Capybara webkit, and sadly I had to resort to executing javascript using jQuery: page.execute_script('$(".ClassSelector").trigger("hover")') 回答2: This blog has the answer: http://aokolish.me

Capybara+Selemium: How to initialize database in an integration test code and make it visible in Rails application?

血红的双手。 提交于 2019-12-31 12:59:14
问题 Configuration: Integration tests for Rails project using RSpec, Capybara, Selemium driver, SQLite database. Situation: I had few integration tests with Capybara and default rack_test driver. They create a user registration (for Devise gem) directly in database. Then they login and test a scenario using Capybara DSL like a user would do. Problem: I tried to change a driver to Selenium to test JavaScript code as well. Now the tests fail because application does not see a user registration that

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

情到浓时终转凉″ 提交于 2019-12-31 07:57:38
问题 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 line: find_field('Your name').should have_content('John') That test fails, although the filling just before worked as I've verified by saving the page. What am I missing? 回答1: You can use an xpath query to check if there's an input element with a

CasperJS dynamic selectlists

不羁的心 提交于 2019-12-31 00:56:07
问题 Need help I am scraping data from this website which has a form that contains three selectlists interconnected to each other that is if the any option from the from the first select list is selected this function is called onchange="Javascript:submitForm2(); and the second selectlist is populated. And subsequently if an option from the second selectlist is selected the same js function is called onchange="Javascript:submitForm2();" And finally two submit buttons for this form each call

Having trouble using Capybara and Selenium to find an svg tag on a page

自古美人都是妖i 提交于 2019-12-30 07:02:07
问题 I had a test case like this: scenario "there should be an SVG tag" do ... page.find("svg") end For some reason, Capybara could not find the svg tag even though when I looked in the page's source, the tag was there (and also visually). I was only able to get it to find the SVG tag after I did something like: scenario "there should be an SVG tag" do ... page.find("#layers *[xmlns='http://www.w3.org/2000/svg']") end (Note, the svg is within the "layers" ID). Does anyone have any ideas? I use

What does Steak add beyond just using Capybara and RSpec in Rails testing?

随声附和 提交于 2019-12-30 06:10:30
问题 I'm trying to understand the need for Steak. I get that its like Cucumber, except that you can use pure ruby instead of mapping your english language specs to ruby like in Cucumber, but it says that it mainly adds a wrapper around the RSpec DSL, and lets you use that taken from: http://jeffkreeftmeijer.com/2010/steak-because-cucumber-is-for-vegetarians/ module Spec::Example::ExampleGroupMethods alias scenario example alias background before end module Spec::DSL::Main alias feature describe

Change default Capybara browser window size

筅森魡賤 提交于 2019-12-30 03:45:06
问题 So, with respect to integration testing using Capybara and RSpec, I know I can do this: page.driver.browser.manage.window.resize_to(x,y) per How to set Browser Window size in Rspec (Selenium) for specific RSpec tests, but is there a way to do this globally so that every test that is affected by media queries doesn't have to define this? 回答1: You could define that under before(:all) describe "Test" do before(:all) do ... ... page.driver.browser.manage.window.resize_to(x,y) #Mention it here end