String url = "xx.jsp";WebClient wc = new WebClient(BrowserVersion.CHROME);wc.getCookieManager().setCookiesEnabled(true);wc.setAjaxController(new NicelyResynchronizingAjaxController());WebRequest request = new WebRequest(new URL(url));WebResponse response = wc.loadWebResponse(request);System.out.println(response.getContentAsString());// HtmlPage page = HTMLUnitUtil.getHTMLPageByURL(wc, url, false);////// // 獲取頁面元素// HtmlForm form = page.getForms().get(0);//// HtmlInput company = form.getInputByName("companyCode");// company.setValueAttribute("xx");//// HtmlInput userID = form.getInputByName("userID");// userID.setValueAttribute("xx");//// HtmlImage goImg = form.getOneHtmlElementByAttribute("img", "name", "goImg");//// Page temp = goImg.click();拿到的temp還是之前的page內(nèi)容
用htmlunit拿到的htmlImage元素,調(diào)用click事件不能觸發(fā)元素的onclick事件
明月笑刀無情
2018-08-16 10:09:32