简体   繁体   English

硒:停止页面加载

[英]Selenium : Stop page loading

I am using Selenium to test a bunch of URLs. 我正在使用Selenium测试一堆URL。 But some of those are not valid and the browser may take quite a lot of time to stop loading. 但是其中一些无效,浏览器可能会花费大量时间停止加载。
The set_page_load_timeout( ) works well and will continue the execution of the code if the timeout has been reached but the next URL won't be tested until the browser has finished with its previous work... set_page_load_timeout( )运作良好,如果达到了超时时间,它将继续执行代码,但是直到浏览器完成之前的工作后,下一个URL才会被测试...
I also tried to send a Javascript code ( window.stop() ) but it does not work until the page has been loaded. 我也尝试发送Javascript代码( window.stop() ),但是直到页面加载完毕后,它才起作用。

Is there any proper way to do this ? 有什么适当的方法吗? If not, I will try any proposed solution. 如果没有,我将尝试任何建议的解决方案。

If I understand correctly that by "they're not valid" you mean they may not exist, why not try: 如果我正确理解“无效”,则表示它们可能不存在,为什么不尝试:

 try {
     URL myURL = new URL("http://test.com/");
     URLConnection myURLConnection = myURL.openConnection();
     myURLConnection.connect(); 
}  catch (MalformedURLException e) {  }  
catch (IOException e) {    //end test }

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

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