黄瓜 +网络老鼠 + selenium,如何忽略隐藏文本?
我正在使用 Cucumber、webrat 和 selenium 来测试 Web 应用程序。我使用“我应该看到“某事””来验证更改。然而,在许多地方,要验证的文本仅从隐藏变为可见(这可能是由于从其自身或其祖先之一删除“隐藏”类引起的)。在这种情况下,上述测试实际上并没有验证更改。我正在尝试使用 'response.should_not have_tag("div#myId.hidden")',但这不起作用。推荐的测试方法是什么?
环境:cucumber 0.3.11,selenium-client 1.2.17,webrat 0.6.0
谢谢。
I am using Cucumber, webrat and selenium to test a web application. I use 'I should see "something"' to verify changes. However, in many places, text to be verified only changes from hidden to visible (this might be caused by removing 'hidden' class from itself or one of its ancestors). In this case, above test does not actually verify the change. I am trying to use 'response.should_not have_tag("div#myId.hidden")', which does not work. What is the recommended way to test this?
Environment: cucumber 0.3.11, selenium-client 1.2.17, webrat 0.6.0
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于这些情况,我使用这两个自定义步骤:
将它们放入 step_definitions/ 目录下的 Ruby 文件中。
因此,在您的情况下,不要使用 Then I should see "something",而应使用 Then the element matches by "something" should bevisible。
For cases as these I use those two custom steps:
Put those into a Ruby file under step_definitions/ directory.
So, in your case, instead of Then I should see "something" use Then the element matched by "something" should be visible.
使用 have_selector("div#myId.hidden") 代替时是否有效?
Does it work when using have_selector("div#myId.hidden") instead?
接受的解决方案不适用于以下环境:
Rails (3.0.0)、webrat (0.7.3) selenium-client (1.2.18)、cucumber (0.10.)
有效的解决方案(使用答案中提供的示例)现在是:
The accepted solution does not work with the following environment:
Rails (3.0.0), webrat (0.7.3) selenium-client (1.2.18), cucumber (0.10.)
The solution that works, with the example provided in the answer is now: