【问题标题】:Rspec Test : How do we check for an input field in a bootstrap modal? And how do we fill in that field?Rspec 测试:我们如何检查引导模式中的输入字段?我们如何填写该字段?
【发布时间】:2015-09-25 09:10:54
【问题描述】:

我的模态中有这两个输入字段:

Amount: <%= f.text_field :prin, :onKeyPress=>"return isNumberKey(event)"  , :required => 'true'%>
Rate: <%= f.number_field :interest_rate, :min => "12", :max => "30", :required =>'true'  %>

典型的fill_in 在规范测试中不适用于此。

【问题讨论】:

  • 在填充过程中它们是否可见?
  • 如果没有看到typical fill_in 的测试,真的很难说出任何事情。
  • 我的回答有效吗?

标签: ruby-on-rails rspec rspec-rails


【解决方案1】:

您可以使用within 来识别模态框的class name 并使用fill_in,如下所示

within(".your_modal_class_name") do 
  fill_in 'prin', with: 'some_value'
  fill_in 'interest_rate', with: 'some_value'
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-24
    • 2012-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多