我有一个有适当标签的字段,我可以用水豚来填写它,没有问题:
fill_in 'Your name', with: 'John'
我想在填充它之前检查它的值,但是我不能计算出来。
如果我在fill_in
后面添加以下行:
find_field('Your name').should have_content('John')
这个测试失败了,尽管之前的填充工作正常,我已经通过保存页面进行了验证。
我遗漏了什么?
发布于 2016-10-22 05:47:12
如果您特别想测试占位符,请使用:
page.should have_field("some_field_name", placeholder: "Some Placeholder")
或者:
expect(page).to have_field("some_field_name", placeholder: "Some Placeholder")
如果要测试用户输入的值:
page.should have_field("some_field_name", with: "Some Entered Value")
发布于 2020-09-28 04:54:15
如果该字段是id为'some_ field‘的隐藏字段,则可以使用
expect(find("input#somefield", :visible => false).value).to eq 'John'
https://stackoverflow.com/questions/10503802
复制相似问题