黄瓜:下拉菜单应该选择项目吗? xpath 怎么样?或者也许是别的什么?
<select id="search_user_id_equals_any" name="search[user_id_equals_any]">
<option value="2">My Stuff</option>
<option value="-1,1,2,3,4,5">All Users</option>
<option value="3">The Cat</option>
</select>
所以,上面是我想要验证的下拉菜单。
现在,当您单击某些内容时,它不会将 selected="selected" 添加到您单击的任何选项中,所以我不知道如何计算出选择。
想法?
<select id="search_user_id_equals_any" name="search[user_id_equals_any]">
<option value="2">My Stuff</option>
<option value="-1,1,2,3,4,5">All Users</option>
<option value="3">The Cat</option>
</select>
So, above is the drop down I want to verify something is selected in.
Now, when you click on something, it doesn't add the selected="selected" to whatever option you click, so I don't know how to figure out the selection.
ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
怎么样:
?
How about:
?
您可以从 Capybara 源码 中看到value 方法的工作原理:
所以看起来按照设计,它将返回选项的值(如果存在),否则它将返回文本内容。请注意,如果未选择任何选项,它将默认为第一个,就像真正的浏览器一样。
为了获得你想要的行为,你可以这样做:
You can see from the Capybara source how the value method works:
So it looks like by design it will return the option's value, if present, and otherwise it will return the text content. And note how if no option is selected, it will default to the first, as a real browser would.
To get the behaviour you want, you could do something like this: