gpt4 book ai didi

download - Selenium 化物。下载()返回 FileNotFoundException : Failed to download file

转载 作者:行者123 更新时间:2023-12-03 21:18:21 29 4
gpt4 key购买 nike

我想检查使用 Selenide download() 方法下载文件,但捕获 FileNotFoundException 和错误“拦截 1 个响应”,尽管文件已下载。

我有按钮,点击它会下载一个 zip 文件。元素没有 href 属性。

我使用 Selenide 5.0.0,chromdriver.exe 2.43

我有以下设置

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

以下代码调用错误
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)

最佳答案

由于您的项目设置,您应该使用 try catch ,请使用:

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

关于download - Selenium 化物。下载()返回 FileNotFoundException : Failed to download file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53084058/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com