capybara

Cucumber/Capybara Selecting Button from Specific Class?

感情迁移 提交于 2019-12-20 02:59:07
问题 So i've ran into an issue, im trying to click a button...which unfortunately has the same text (IE there are 2 buttons on the page which the same text, basically a save button) Lets pretend the button text is just "Save". I did notice that they had different classes. <button data-action="submit" class="btn btn-primary btn-save">Save</button> whereas the other button is: <button name="button" type="submit" class="btn btn-primary set-right"> <i class="glyphicon glyphicon-floppy-disk"></i> Save

Checking checkboxes with Capybara

∥☆過路亽.° 提交于 2019-12-20 00:59:10
问题 Using Capybara I cannot for the life of me select a checkbox on my form. In my request spec I've tried: check("First Name") page.check("First Name") page.check("pickem_option_ids_10") find(:css, "#pickem_option_ids_11[value='11']").set(true) find(:css, "#pickem_option_ids_11").set(true) Snippet from my form: <div class="control-group check_boxes optional"> <label class="check_boxes optional control-label">Options:</label> <div class="controls"> <label class="checkbox"> <input class="check

how to use capybara has_text

让人想犯罪 __ 提交于 2019-12-19 11:17:00
问题 So now I've got cucumber/capybara/selenium hitting a google app script, which is great, but for some reason I can't seem to check for text in the body of the page in the way I expect. In the debugger I can grab the page object, which I can in the browser has the expected text. Scanning the html directly shows the text appearing twice, and yet page.has_text? appears false: (rdb:1) p page.html.scan(/Introduction Video/) ["Introduction Video", "Introduction Video"] (rdb:1) p page.has_text?

how to use capybara has_text

流过昼夜 提交于 2019-12-19 11:16:03
问题 So now I've got cucumber/capybara/selenium hitting a google app script, which is great, but for some reason I can't seem to check for text in the body of the page in the way I expect. In the debugger I can grab the page object, which I can in the browser has the expected text. Scanning the html directly shows the text appearing twice, and yet page.has_text? appears false: (rdb:1) p page.html.scan(/Introduction Video/) ["Introduction Video", "Introduction Video"] (rdb:1) p page.has_text?

Checking existence of images and favicons with RSpec and Capybara

ぐ巨炮叔叔 提交于 2019-12-19 06:26:19
问题 Is there a good way to check on existence of images and favicons using rspec and capybara? I can check on the DOM of favicons and images, but I want to be able to check that those images load as well. Is this possible with rspec and capybara? 回答1: describe "check images and favicon" do before { visit "url/to/check") it "should have the images" do page.should have_css('img', text: "image1.jpg") it "should have the favicon" do page.should have_xpath("/html/head/link[@href='favicon.ico']" end

How to Stub out Warden/Devise with Rspec in Capybara test

99封情书 提交于 2019-12-19 05:43:23
问题 I want to stub out a logged in user (with Devise/Warden) using rspec mocks in a Capybara test suite in my Rails app. This would save a ton of time, and would mean that my test suite can/will be run regularly. Previously I was able to do this using authlogic by stubbing out my session model with some code like this: def login(user) user_session = mock_model(UserSession, {:user => user}) UserSession.stub(:find).and_return(user_session) end Now that i'm using Devise, i no longer have access to a

Can I use before :all with capybara?

寵の児 提交于 2019-12-19 03:10:50
问题 I have a describe block like this: describe "Documents" do subject { page } let (:course) { FactoryGirl.create(:course) } describe "new" do before do visit new_course_document_path(course) fill_in "Name", with: "TestDocument" attach_file "Original document", "#{Rails.root}/spec/fixtures/03_GUI_concurrency.pdf" end it { should have_selector('title', text:"Upload document")} it { should have_selector('h1', text:"Upload document")} describe "when clicking upload" do before { click_button "Upload

Capybara: Unable to find css

两盒软妹~` 提交于 2019-12-18 18:38:06
问题 I am using capybara to click a checkbox, however it can't seem to find it no matter what I do. I am able to correctly find both the span and the label inside the span, but not the input I actually need. Here is the checkbox <span class="checkbox tos"> <input id="agreement" name="agreement" onclick="agreeValidate();" type="checkbox" value="false"> <label for="agreement">I accept the <a href="http://www.dev.com:3000/terms" target="_blank">Terms of Use</a>, <a href="http://www.dev.com:3000

capybara/selenium with rspec before :all hook

≡放荡痞女 提交于 2019-12-18 14:53:53
问题 In an attempt to reduce the number of page visits with selenium, I wanted to call the visit method from a before :all hook and run all my examples with a single page load. However, when I specify before :all vs before :each , the browser opens, but the url is never visited. Below is a simplified and contrived example... describe 'foobar', :js => true do before :all do Capybara.default_wait_time = 10 obj = Factory(:obj) visit obj_path(obj) end it 'should have foo' do page.should have_content(

How to test for a redirect with Rspec and Capybara

吃可爱长大的小学妹 提交于 2019-12-18 14:08:12
问题 I don't know what I'm doing wrong, but every time I try to test for a redirect, I get this error: "@request must be an ActionDispatch::Request" context "as non-signed in user" do it "should redirect to the login page" do expect { visit admin_account_url(account, host: get_host(account)) }.to redirect_to(signin_path) end end 1) AdminAccountPages Admin::Accounts#show as non-signed in user should redirect to the login page Failure/Error: expect { visit admin_account_url(account, host: get_host