水豚没有
find_select
:select
选择器类型-
https://github.com/teamcapybara/capybara/blob/2.15.1/lib/capybara/selector.rb#L358
第一个参数
find
是选择器类型(如果省略,则默认为:css),因此您可以使用它做任何事情
assert_equal true, find(:select, 'id').readonly?
因为它使用了非水豚提供的断言,所以它的缺点是不使用任何等待/重试行为。如果元素的状态正在动态变化,则可能会导致计时问题和不稳定的测试。如果你的页面上出现这种情况,你最好使用
:field
选择器类型,提供
readonly
https://github.com/teamcapybara/capybara/blob/2.15.1/lib/capybara/selector.rb#L88
-并且还可以匹配选择元素(
:选择
assert_selector :field, 'id', type: 'select', readonly: true
假设您已经加载了水豚提供的minitest断言,该断言也可以写成
assert_field 'id', type: 'select', readonly: true
或使用“:select”选择器断言和过滤器块
assert_select('i') { |el| el.readonly? }
assert_field 'id', type: 'select', disabled: true
assert_select 'id', disabled: true
等