简体   繁体   English

等待JS加载

[英]Wait for JS load

I have a problem with the js load at my spec script. 我的规范脚本中的js加载有问题。 I used js: true and wait_for_ajax , but it does not work well, cause I use ActionMailer::Base.deliveries.count to access the email. 我使用js: truewait_for_ajax ,但是效果不佳,因为我使用ActionMailer::Base.deliveries.count访问电子邮件。

Is there another way to make the test wait until js is loading? 还有另一种方法可以让测试等到js加载完毕?

select 'Colombia', from: 'country_box'
sleep 10 
select 'Bogota', from: 'state_select' 
sleep 10 
select 'Bogota', from: 'city_select'

I tried this, but this did not work. 我试过了,但这没用。

Thanks all 谢谢大家

You shouldn't be worrying about waiting for JS (nor using any type of wait_for_ajax )- instead you should be asserting/expecting for visible page changes that indicate the state of the page is in a condition to move on in the test. 您不必担心等待JS(也不使用任何类型的wait_for_ajax )-相反,您应该断言/期待可见的页面更改,这些更改指示页面的状态处于测试中可以继续进行的状态。

I would give more details on how to do it in your specific case, but it's not very clear what exactly you're doing (no idea what ActionMailer has to do with selecting from a dropdown), no example of the page HTML, and you haven't provided any details on what exactly the error is - see https://stackoverflow.com/help/how-to-ask 在具体情况下,我会提供更多详细信息,但是还不清楚您到底在做什么(不知道ActionMailer从下拉菜单中选择什么),没有页面HTML的示例,而您尚未提供有关错误确切原因的任何详细信息-请参阅https://stackoverflow.com/help/how-to-ask

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM