0

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.

Bhoomi Akhani
  • 25
  • 1
  • 5
  • Please post your complete case with URL, so others can reproduce the issue. – Ahmed Ashour Oct 17 '15 at 18:34
  • For example consider this url : http://nrldc.org/WBS/injsch.aspx?date=25-02-2013 Here when click on All file is getting downloaded directly, but in my case I'm getting download window using window.location and I don't know how to handle this thing using htmlunit. – Bhoomi Akhani Oct 18 '15 at 16:29

0 Answers0