2017-05-09 54 views

回答

0

您首先需要唯一地找到该元素,然后在其上调用value。如何找到元素的唯一性可以高度依赖于页面其余部分的结构,但是基于您提供的单个元素HTML(并且您实际上并不知道该值已经是什么),以下任一项都可能是一个首发位置

find('.class-of-checkbox').value 
find_field(type: 'checkbox', class: 'class-of-checkbox').value 

如果你只是想与预期验证元素的值,那么你可以这样做(假设RSpec的黄瓜)

expect(page).to have_field(type: 'checkbox', with: 'facebook', class: 'class-of-checkbox') # you can also pass :checked option if you want to verify it is checked - or use have_checked_field/have_unchecked_field