4

I want to check downloading a file using Selenide download() method, but catch FileNotFoundException and error 'Intercepted 1 responses', though file was downloaded.

I have button, click on which results in downloading a zip file. Element doesn't have href attribute.

I use Selenide 5.0.0, chromdriver.exe 2.43

I have following settings

    Configuration.proxyEnabled = true;
    Configuration.fileDownload = FileDownloadMode.PROXY;

Following code invoke error

public static SelenideElement actionButton() {return $(By.xpath("//div[@class='task-list_container_scroll-view']/div[1]/div[@class='ng-star-inserted'][1]//common-task-view//span[@role='button']"));}
File file = actionButton().download(10000);

java.io.FileNotFoundException: Failed to download file {By.xpath: //div[@class='task-list_container_scroll-view']/div[1]/div[@class='ng-star-inserted'][1]//common-task-view//span[@role='button']} in 10000 ms.Intercepted 1 responses. 200 "" {Server=nginx/1.13.12, Cache-Control=private, Access-Control-Allow-Origin=*, Access-Control-Allow-Methods=POST, GET, OPTIONS, DELETE, PUT, Connection=keep-alive, Expires=Thu, 01 Jan 1970 00:00:00 GMT, Access-Control-Max-Age=3600, X-Application-Context="frontend":staging:80, Content-Length=1271853, Date=Wed, 31 Oct 2018 12:41:32 GMT, Access-Control-Allow-Headers=Content-Type, x-requested-with, X-Custom-Header, accept, authorization} application/octet-stream (1202830 bytes) at com.codeborne.selenide.impl.DownloadFileWithProxyServer.firstDownloadedFile(DownloadFileWithProxyServer.java:94) at com.codeborne.selenide.impl.DownloadFileWithProxyServer.clickAndInterceptFileByProxyServer(DownloadFileWithProxyServer.java:49) at com.codeborne.selenide.impl.DownloadFileWithProxyServer.download(DownloadFileWithProxyServer.java:33) at com.codeborne.selenide.commands.DownloadFile.execute(DownloadFile.java:51) at com.codeborne.selenide.commands.DownloadFile.execute(DownloadFile.java:18) at com.codeborne.selenide.commands.Commands.execute(Commands.java:144) at com.codeborne.selenide.impl.SelenideElementProxy.dispatchAndRetry(SelenideElementProxy.java:99) at com.codeborne.selenide.impl.SelenideElementProxy.invoke(SelenideElementProxy.java:65) at com.sun.proxy.$Proxy11.download(Unknown Source)

Madhur Bhaiya
  • 28,155
  • 10
  • 49
  • 57
Svetlana
  • 43
  • 5

2 Answers2

1

you should use try catch because of your project setting, use this:

        try {
        $("selector").download();
    }catch(FileNotFoundException e){}
1

Try this:

    Configuration.fileDownload = FileDownloadMode.FOLDER;
Ou Sir
  • 11
  • 1