I am trying to download xls file from a website using Htmlunit. When I click the link to download the file, I get a javascript confirm box.
I tried multiple options but not able to find the slution:
ConfirmHandler okHandler = new ConfirmHandler(){
@Override
public boolean handleConfirm(Page arg0, String arg1) {
// TODO Auto-generated method stub
return true;
}
};
webClient.setConfirmHandler(okHandler);
Also tried with
final String page = currentPage.getElementById("downloadExcel").click().getWebResponse().getContentAsString();
String buttonJavaScript = "window.location='...........'";
ScriptResult result = page.executeJavaScript(buttonJavaScript);
webClient.waitForBackgroundJavaScript(1000);
It would be really helpful if some one can suggest the solution for this.