【发布时间】:2021-05-06 06:08:11
【问题描述】:
我无法在我的项目目录中下载文件我如何下载任何人帮助我解决这个问题 下面是我的代码
downloadlink.click();
String Resumedownloadpath="C:\\Users\\admin\\Downloads\\cb-comAutomation\\src\\test\\resources\\Download"
Assert.assertTrue(isFileDownloaded(Resumedownloadpath,"new_resume_001 (1).docx"),"Failed to download Expected document");//this is verify using assert
public boolean isFileDownloaded(String Resumedownloadpath, String fileName){//this function is validation
boolean flag = false;
File dir = new File(Resumedownloadpath);
File[] dir_contents = dir.listFiles();
for (int i = 0; i < dir_contents.length; i++) {
if (dir_contents[i].getName().equals(fileName))
return flag=true;
}
return flag;
}
【问题讨论】:
-
试试
Thread.sleep(time in ms) -
文件已下载但在本地目录中我想在项目目录中下载如果我单击 downloadlink.click() 文件会在本地目录中自动下载我也提供项目目录的路径但文件未下载到文件夹中我给了那条路
-
您在哪里以及如何“提供项目目录的路径”?
-
解决方法是将该文件移动到您的适当位置
-
我想在这个路径中移动那个文件-\\src\\test\\resources\\Download