Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – Devise / Capybara模糊匹配大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用设计来创建注册向导,
但水豚(2.0.2)升高
Feature: Signing up
    In order to be attributed for my work
    As a user
    I want to be able to sign u

Scenario: Signing up
    Given I am on the homepage
    When I follow "Sign up"
    And I fill in "Email" with "user@ticketee.com"
    And I fill in "password" with "password"
    Ambiguous match,found 2 elements matching field "password" (Capybara::Ambiguous)
./features/step_definitions/web_steps.rb:10:in `/^(?:|I )fill in "([^"]*)" with "([^"]*)"$/'
features/signing_up.feature:10:in `And I fill in "password" with "password"'
    And I fill in "password confirmation" with "password"
    And I press "Sign up"
    Then I should see "You have signed up successfully."

步骤定义是

When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field,value|
  fill_in(field,:with => value)
end

解决方法

在版本2.0中,Capybara的find方法引发了一个Capybara :: Ambiguous异常,当匹配指定的定位器找到的几个元素.水豚不想为你做一个模糊的选择.

正确的解决方案是使用另一个定位器(例如find(‘#id’).set(‘password’)或fill_in(‘field_name’,with:’password’)

阅读Capybara 2.0 Upgrade guide的“模糊匹配”部分,对此进行了更长的解释.

大佬总结

以上是大佬教程为你收集整理的ruby-on-rails – Devise / Capybara模糊匹配全部内容,希望文章能够帮你解决ruby-on-rails – Devise / Capybara模糊匹配所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。