4
我剛剛通過gargoylesoftware學習htmlunit,並遇到問題。 頁面上有一個iframe,點擊按鈕後會出現。當我嘗試通過名稱獲得這個iframe時,我得到一個ElementNotFoundException
。此外,我嘗試page.getFrames()
並返回幀,但沒有我正在尋找的幀或它是空白的。所以它看起來像js/ajax沒有更新它。我對JCPENNY工作(點)的COM和問題出現時,我嘗試從「購物袋」 頁面在「結帳」是我的Web客戶端的設置HtmlUnit無法獲得添加了IFRAME的js/ajax
BrowserVersion bv = BrowserVersion.CHROME_16;
bv.setUserAgent("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
CookieManager cm = new CookieManager();
cm.clearCookies();
cm.setCookiesEnabled(true);
WebClient webClient = new WebClient(bv);
webClient.setCookieManager(cm);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.setJavaScriptTimeout(15000);
webClient.setCssErrorHandler(new SilentCssErrorHandler());
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.waitForBackgroundJavaScript(15000);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getOptions().setRedirectEnabled(true);
webClient.getOptions().setUseInsecureSSL(true);
webClient.setRefreshHandler(new ThreadedRefreshHandler());
if iframe沒有名字怎麼辦?我試圖訪問的iframe的id不是名稱。