为什么这些水豚匹配者会有不同的结果?它们在这里不应该是等价的吗?
我一直试图找出匹配器不匹配的原因,这导致我进行以下两个测试:
subject.has_field?("filter").should be_true
subject.has_xpath?(".//input[contains(@id, 'filter')]").should be_true
第二个测试成功,但第一个测试失败。但 has_field 的定义似乎表明,在任何情况下,第二个通过的情况下,第一个也应该通过。我在这里缺少什么?
这是 HTML 元素:
<input id="filter_1" type="checkbox" name="type[ids][]">
I have been trying to figure out why me matchers aren't matching, and that's lead me to the following two tests:
subject.has_field?("filter").should be_true
subject.has_xpath?(".//input[contains(@id, 'filter')]").should be_true
The second of these tests results in a success, but the first fails. But the definition of has_field seems to indicate that in any situation where the second passes, the first should pass as well. What am I missing here?
Here's the HTML element:
<input id="filter_1" type="checkbox" name="type[ids][]">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是猜测:
has_field?
应该只匹配“可输入”字段(和复选框) - 它会过滤掉带有type=image
、type=submit
的输入> 和type=hidden
。这可能是您出现问题的原因吗?另外,
has_field?
检查等效性,至少在 id 方面,因此它不会与 id 中尾随字符匹配。Just a guess:
has_field?
should match only "typable" fields (and checkboxes) - it filters out inputs withtype=image
,type=submit
andtype=hidden
. Could this be a reason for your problem?Also,
has_field?
check for equivalence, at least in regards to ids, so it wouldn't match something with trailing characters in the id.