capybara

Does site_prism allow using other selectors than CSS?

让人想犯罪 __ 提交于 2019-12-24 13:13:52
问题 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 than css? Like Xpath, Dom, maybe just the id's of the elements, etc. Thanks and Regards! 回答1: UPDATE: It is possible, as of SitePrism 2.1 to use XPath expressions to find elements and sections, as well as CSS selectors. ===== CSS only at the moment. I may change that in the future though. 来源: https

ActionController::UrlGenerationError: missing required keys: [:id]

房东的猫 提交于 2019-12-24 10:35:36
问题 I'm running RSpec 3 tests and am getting this same error for this one particular path: Failure/Error: visit book_path ActionController::UrlGenerationError: No route matches {:action=>"show", :controller=>"books"} missing required keys: [:id] My test isn't quite finished, so I'm sure some of the latter code might be incorrect. But I can't get my visit path line to run: ... book = FactoryGirl.build(:book) reviews = FactoryGirl.build_list(:review, 5, book: book) visit book_path reviews.each do

how to run capybara commands once, then run some tests

吃可爱长大的小学妹 提交于 2019-12-24 08:55:51
问题 I have the given testing code: describe 'A new user', js: true do before do @new_user = Fabricate.build(:user) end it 'should sign up' do #login code visit '/' click_link 'Login' fill_in 'user[email]', :with => @new_user.email fill_in 'user[password]', :with => @new_user.password click_button 'Login now' #login code end page.should have_content("Hello #{@new_user.first_name}!") current_path.should == dashboard_path end it 'should receive a confirmation mail' do #same login code again visit '/

Cucumber capybara stubbing

拥有回忆 提交于 2019-12-24 08:35:01
问题 I have an index action in a rails controller called images_controller.rb that fetches images from an external service. I am trying to write cucumber scenarios and am struggling with how to write/stub out my visit index page step. How could I stub out the images it fetches without it making the request? Feature: Scenario: Image Index Given an image exists on the image server When I am on the images page Then I should see images Steps so far: Given(/^an image exists on the image server$/) do

Rspec Capybara test with ajax call not updating record

社会主义新天地 提交于 2019-12-24 05:31:31
问题 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 via rspec its telling me that the association was not created. Why isn't the template object updated here? describe "edit page" do before(:each) do visit edit_admin_template_path(template) end context "form sections", js: true do it "allows admin to create one" do find("#btn-add-section").click

ActionMailer not delivering confirmation emails in test environment - Rails 4

六月ゝ 毕业季﹏ 提交于 2019-12-24 03:27:11
问题 I'm using Rails (4.2.6), Ruby (2.2.4), Devise (4.1.1), Capybara (2.7.1), Capybara-email (2.5.0), Email_spec (2.1.0), Rspec (3.4.0), and Postgres (0.18.4) After I upgraded the application from Rails 4.1.15 to 4.2.6, several authentification & registration tests fail. Before the upgrade all tests were properly passing. The code works as expected in the development environment (for example, confirmation emails are sent & viewable in the Rails server terminal). The problem of non-delivered emails

Capybara selecting root node rather than specified node

我怕爱的太早我们不能终老 提交于 2019-12-24 02:43:08
问题 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 DOM node or throws an error. card = find('.card__title', text: display_name).ancestor('.card') expect(card).to have_no_selector('.read') On the CI server, it doesn't throw an error, rather the variable card has the value of: #<Capybara::Node::Element tag="html" path="/HTML"> and the expectations

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

两盒软妹~` 提交于 2019-12-24 02:06:14
问题 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 this is or how to solve it. I have a 225 line spec file with a couple dozen tests. On any given test run, 1 or 2 of them will consistently fail. It can be any of them, it's not consistent. This before block applies to all the tests. I've annotated the code to explain the situation. before do # -->

How to setup Capybara with Safari Technology Preview in Ruby

白昼怎懂夜的黑 提交于 2019-12-24 01:54:58
问题 I can't establish a session with Safari Technology Preview (STP) using Capybara and Selenium. Capybara won't even open a browser window. I've upgraded to Ruby 2.3.0 Capybara 2.14.2 Selenium 3.4.0 I downloaded and installed STP from https://developer.apple.com/safari/download/ I am trying to use the following code: Capybara.register_driver :selenium do |app| Capybara::Selenium::Driver.new( app, browser: :safari ) end Capybara.default_driver = :selenium How do I initialize Capybara to use the

Using Capybara-Webkit, Inject Javascript before client code runs

喜你入骨 提交于 2019-12-24 00:03:19
问题 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 only effect a web app when it is used from within a hybrid mobile app. My hybrid app related code does not run unless this class exists. From the native iOS code I inject some javascript which adds a class to the HTML tag before the page loads. The problem is that when do the same from the Capybara