I am trying to download something an attachment behind a javascript button with HtmlUnit. Performing other tasks works great (eg. navigating, login). I checked out the attac
Just in case anyone else is wondering: You need to use the AttachmentHandler.
ScriptResult result = page2.executeJavaScript(buttonJavaScript);
webClient.waitForBackgroundJavaScript(1000);
if( attachments.size() > 0 )
{
Attachment attachment = attachments.get(0);
Page attachedPage = attachment.getPage();
WebResponse attachmentResponse = attachedPage.getWebResponse();
String content = attachmentResponse.getContentAsString();
... write(content);
}