ruby-on-rails – Devise / Capybara模糊匹配
发布时间:2020-12-16 22:35:46 所属栏目:百科 来源:网络整理
导读:我正在使用设计来创建注册向导, 但水豚(2.0.2)升高 Feature: Signing up In order to be attributed for my work As a user I want to be able to sign uScenario: Signing up Given I am on the homepage When I follow "Sign up" And I fill in "Email" wi
我正在使用设计来创建注册向导,
但水豚(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的“模糊匹配”部分,对此进行了更长的解释. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |