首页 新闻 赞助 找找看

用htmlunit拿到的htmlImage元素,调用click事件不能触发元素的onclick事件

0
悬赏园豆:40 [已解决问题] 解决于 2018-08-10 10:24

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内容

摘花的主页 摘花 | 初学一级 | 园豆:172
提问于:2018-08-06 11:50
< >
分享
最佳答案
0

直接触发JS function吧

摘花 | 初学一级 |园豆:172 | 2018-08-10 10:23
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册