capybara

Capybara Ambiguity Resolution

北战南征 提交于 2019-12-29 11:31:51
问题 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 matching link "#tag1" The reason why I can't avoid this is because of the design. I'm trying to recreate the twitter page with tweets/tags on the right and the tags on the left of the page. Therefore it will be inevitable that identical links page shows up on

Capybara Ambiguity Resolution

瘦欲@ 提交于 2019-12-29 11:31:16
问题 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 matching link "#tag1" The reason why I can't avoid this is because of the design. I'm trying to recreate the twitter page with tweets/tags on the right and the tags on the left of the page. Therefore it will be inevitable that identical links page shows up on

RSpec2 and Capybara

独自空忆成欢 提交于 2019-12-28 13:29:12
问题 Capybara is confusing me. If I use Capybara in combination with Ruby on Rails 3 and RSpec 2, then in RSpec request tests, the following matcher works: response.body.should have_selector "div.some_class" The response object has the class ActionDispatch::TestResponse . But the following line, which should work officially, does not work: page.should have_selector "div.some_class" The page object has the class Capybara::Session . In which cases do you have to use the response.body object and when

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

有些话、适合烂在心里 提交于 2019-12-28 08:06:13
问题 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, "input[id$='donation_pledge_hundreds']") fill_in element.<method> , :with => "10" but there are no methods that return any data to identify the element to fill_in. Any ideas of the best way of finding a field via a regex for use with fill_in? 回答1: Going from memory so

How can I test the page title with Capybara 2.0?

喜夏-厌秋 提交于 2019-12-27 12:27:19
问题 Trying to test that page contains <title>My Title</title> with: # spec/features/reports_spec.rb require 'spec_helper' feature "Archive Management" do subject { page } describe "Index Page" do before(:all) { 10.times { FactoryGirl.create(:randomreport) } } after(:all) { Report.delete_all } describe "when no search terms present" do before { visit reports_path } it { should have_selector('title', text: 'My Title') } # <= Fails w/Capybara 2.0 it { should have_selector('title') } # <= passes it {

How can I test the page title with Capybara 2.0?

可紊 提交于 2019-12-27 12:22:33
问题 Trying to test that page contains <title>My Title</title> with: # spec/features/reports_spec.rb require 'spec_helper' feature "Archive Management" do subject { page } describe "Index Page" do before(:all) { 10.times { FactoryGirl.create(:randomreport) } } after(:all) { Report.delete_all } describe "when no search terms present" do before { visit reports_path } it { should have_selector('title', text: 'My Title') } # <= Fails w/Capybara 2.0 it { should have_selector('title') } # <= passes it {

Why can't I access Rails' URL helpers from my Rspec tests?

一曲冷凌霜 提交于 2019-12-25 13:09:18
问题 Initially I wrote my tests with Cucumber and Capybara, and that worked fine. Then I switched to using Rpsec and Capybara, and that worked fine too. Then I deleted my gemlock file while trying to get the asset pipeline working and suddenly the URL helpers in my tests stopped working. Sample error: Failure/Error: visit report_areas_path(@report) NoMethodError: undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007f978c64e058> # ./spec/features/area_spec.rb:12:in

Selenium: How do I start Chrome with RailsPanel Extension loaded?

给你一囗甜甜゛ 提交于 2019-12-25 07:33:59
问题 What is the right way to do this? Capybara.register_driver :chrome do |app| client = Selenium::WebDriver::Remote::Http::Default.new extension_path = '/Users/jill/Documents/rails_panel-master/rails_panel' caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => ['--load-extension=' + extension_path]}) Capybara::Selenium::Driver.new(app, :browser => :chrome, http_client: client, desired_capabilities: caps ) end Also, --load-extension with switches worked, but there

Rails - How to stub a certain response time for a stubbed / fake http or ajax response

℡╲_俬逩灬. 提交于 2019-12-25 07:28:26
问题 I want to test a feature that in my app sends the usera custom message when a Rails UJS/ajax times-out. The code to timeout the Rails UJS request is itself on the app: $.rails.ajax = function(options) { if (!options.timeout) { options.timeout = 10000; } return $.ajax(options); }; When observing on chrome dev tools what happened when it timed out on my local dev mode, I notice the code status is strangely 200 but as it "times out", my message is indeed displayed to the user. on('ajax:error'

Is it possible to use siteprism variables to define new variables when defining the page object?

余生长醉 提交于 2019-12-25 06:53:44
问题 I'm working on a cucumber, ruby, capybara, siteprism project and we're defining most UK variables in a siteprism page object. Is there a way for me to use the siteprism variables that I create as part of the definition for new variables? For example, if I've got a siteprim page that looks like: sections :user_container, "#user_container" do sections :address_module, "#address" do element :house_number, "#house_number" end end Can I somehow define new variables on the same pageobject