Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 使用htmlunit下载excel文件_File_Download_Htmlunit_Window.location - Fatal编程技术网

File 使用htmlunit下载excel文件

File 使用htmlunit下载excel文件,file,download,htmlunit,window.location,File,Download,Htmlunit,Window.location,我正在尝试使用Htmlunit从网站下载xls文件。当我点击链接下载文件时,我会看到一个javascript确认框 我尝试了多个选项,但找不到该选项: ConfirmHandler okHandler = new ConfirmHandler(){ @Override public boolean handleConfirm(Page arg0, String arg1) {

我正在尝试使用Htmlunit从网站下载xls文件。当我点击链接下载文件时,我会看到一个javascript确认框

我尝试了多个选项,但找不到该选项:

        ConfirmHandler okHandler = new ConfirmHandler(){              

            @Override
            public boolean handleConfirm(Page arg0, String arg1) {
                // TODO Auto-generated method stub
                return true;
            }
        };
        webClient.setConfirmHandler(okHandler);
也试过了

        final String page = currentPage.getElementById("downloadExcel").click().getWebResponse().getContentAsString();
        String buttonJavaScript = "window.location='...........'";
        ScriptResult result = page.executeJavaScript(buttonJavaScript);
        webClient.waitForBackgroundJavaScript(1000);

如果有人能提出解决方案,这将是非常有帮助的。

请用URL发布完整的案例,以便其他人可以复制这个问题。例如,考虑这个URL:点击这里,所有文件都被直接下载,但在我的例子中,我使用window.location获得下载窗口,我不知道如何使用htmlunit处理这个问题。