Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Selenium 来测试一堆 URL。但其中一些是无效的,浏览器可能需要很长时间才能停止加载。 ) 运行良好,set_page_load_timeout(如果达到超时,将继续执行代码,但在浏览器完成之前的工作之前不会测试下一个 URL ... 我也尝试发送 Javascript 代码 ( window.stop()) 但是在页面加载之前它不起作用。
set_page_load_timeout(
window.stop()
有没有合适的方法来做到这一点?如果没有,我会尝试任何建议的解决方案。
如果我正确理解“它们无效”是指它们可能不存在,为什么不尝试:
try { URL myURL = new URL("http://test.com/"); URLConnection myURLConnection = myURL.openConnection(); myURLConnection.connect(); } catch (MalformedURLException e) { } catch (IOException e) { //end test }