且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

轮询时如何解决黄瓜期望值错误?

更新时间:2021-11-29 05:46:25

您无需执行任何操作.

You shouldn't need to do any of that.

Capybara具有强大的同步功能意味着您无需手动等待异步过程完成

Capybara has Powerful synchronization features mean you never have to manually wait for asynchronous processes to complete

您对page.should have_content的测试只需要多一点时间,您可以在步骤中或作为常规设置进行测试.默认等待时间是2秒,您可能需要5秒或更长时间.

Your test for page.should have_content just needs a bit more time, you can give it to it in the step or as a general setup. The default wait is 2 seconds, and you might need 5 seconds or more.

添加Capybara.default_wait_time = 5

在上面的链接中,向下搜索并找到异步JavaScript(Ajax和朋友)

In the link above, search down and find Asynchronous JavaScript (Ajax and friends)

您应该可以完全删除AsyncSupport.请记住,如果您将其设置为一个步骤,并且希望等待时间为2秒,则可能需要ensure块将其设置为原始时间.

You should be able to delete your AsyncSupport entirely. Just remember, if you set this inside a step and you want the wait to be 2 seconds otherwise, you might want an ensure block to set it back to the original time.