Copied from here:
I need to save files from websites using HtmlUnit. I am currently navigating to pages that have several anchors that use javascript:
o
It's more simple than that. Just simulate the click event and then get the WebResponse:
WebResponse
HtmlElement anchorAttachment = (HtmlElement) pageETrackerItem.getByXPath(".../a").get(0); InputStream is = anchorAttachment.click().getWebResponse().getContentAsStream();