水豚 click_link 有时不起作用
我使用默认配置的 Capybara 1.0.0。
click_link "一些现有文本" # --sometimes-- 不起作用。诡异的。
find_link“一些现有文本”#总是有效
这可能是一个计时问题;或者也许不是,因为 find_link 工作得非常好。
我已经通过 save_and_open_page 检查了生成的输出文件,也可以。另外,我增加了等待时间等。但是,都没有帮助。
在我完全了解水豚的来源之前。您认为哪里出了问题?
问候
I'm using Capybara 1.0.0 with default configuration.
click_link "some existing text" # --sometimes-- doesn't work. weird.
find_link "some existing text" # always works
This may be a timing problem; or maybe not because find_link works brilliantly ok.
I've checked the produced output file via save_and_open_page, it's ok too. Also, I've increased the wait time etc. But, neither did help.
Before I goto the source of Capybara completely. What do you think that is gone wrong?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
每当我的测试遇到间歇性问题时,我首先检查的事情之一就是它们的运行顺序。
根据您的 Rspec 设置方式,它可能会在每次运行 Rspec 时随机化规范的运行顺序套房。这意味着有时一切都会过去,有时却不会。
Rspec 将输出一个种子值,您可以使用它以相同的顺序重新运行测试以进行调试。
Whenever I'm getting intermittent problems with my tests one of the first things I check is the sequence they are being run in.
Depending on how you have Rspec setup, it is probably randomising the order the specs are run in each time you run the suite. This means sometimes everything passes and other times not.
Rspec will output a seed value you can use to re-run the tests in the same order for debugging purposes.
尝试使用此语法
click_link('', href: some_path)
。Try to use this syntax
click_link('', href: some_path)
.该链接可能与另一个元素(如弹出窗口)重叠,或者在页面加载一段时间后由 Ajax 激活。这很大程度上取决于您操作的页面类型。
作为一般提示,我建议直接使用查找器,例如:
The link may be ovelapped with another element (like Popup window), or it is activated by Ajax after a while after page is loaded. It's strongly depends of what kind of page you operate with.
As a general tips, I would recommend to use finders directly, like: