Skip to content Skip to sidebar Skip to footer

Htmlunit Download File

I am trying to download file via HTMLUnit. But every time when I use code like this: InputStream stream = anchor.click().getWebResponse().getContentAsStream(); i get website inst

Solution 1:

Pagepage= anchor.click();
BinaryPagebp=newBinaryPage(page.getWebResponse(),page.getEnclosingWindow());
InputStreaminput= bp.getInputStream();

What is inside your page? Maybe it is a 40X or other 50X error page?

Solution 2:

If you want get page see below:

finalHtmlPageenclosedPage= (HtmlPage) anchor.click().getEnclosingWindow().getEnclosedPage();

Post a Comment for "Htmlunit Download File"