朋友们,我正在使用 selenium webdriver 在我的 java 桌面应用程序中获取页面源。每次我尝试获取此URL 时,我都会遇到一个问题,即“ http://www.greenbergdental.com/offices/university ”,我当前的 Java 线程被卡住并且整个应用程序都停止了。请给我一些解决方案,我已经尝试过Pagetimeout,Scripttimeout。注意:由于某种原因,我无法启用 javascript。所以请不要给我一些建议,比如打开我不能打开的 javascript。
websiteURL ="http://www.greenbergdental.com/offices/university";
WebDriver htmlUnitDriver = new HtmlUnitDriver();
htmlUnitDriver.manage().timeouts().pageLoadTimeout(15,TimeUnit.SECONDS);
htmlUnitDriver.manage().timeouts().setScriptTimeout(15,TimeUnit.SECONDS);
htmlUnitDriver.get(websiteURL);
String pagesource = htmlUnitDriver.getPageSource();