javascript加载
If you follow me on Twitter, you've probably noticed me whining about ChromeDriver. For some reason it seems as though tests run before the document has properly loaded, leading to transient test failures and loads of frustration.
如果您在Twitter上关注我 ,您可能已经注意到我对ChromeDriver的抱怨。 由于某种原因,似乎在正确加载文档之前就进行了测试,从而导致短暂的测试失败和沮丧。
I thought the best way to avoid these problems was to ensure the document had loaded before each test run -- that way there's no excuse for transient loading problems. Here's the snippet I use to check if the page is ready:
我认为避免这些问题的最佳方法是确保在每次测试运行之前都已加载文档-这样就不会为暂时加载问题辩解。 这是我用来检查页面是否准备就绪的代码段:
// The basic check if(document.readyState === 'complete') { // good to go! } // Polling for the sake of my intern tests var interval = setInterval(function() { if(document.readyState === 'complete') { clearInterval(interval); done(); } }, 100);I found it ironic that for years we went looking for the ultimate "domready" script and here I am in 2015 trying to figure out if the document has completed loading. This is why we drink.
具有讽刺意味的是,多年来我们一直在寻找最终的“ domready”脚本,而我在2015年试图弄清楚文档是否已完成加载。 这就是为什么我们喝酒。
翻译自: https://davidwalsh.name/document-readystate
javascript加载