简体   繁体   English

如何设置上传下载目录Java+Serenity BDD?

[英]How to set upload and download directory Java + Serenity BDD?

I'm trying to set upload and download directories in order to upload files from the directory and download files to a particular folder in my framework.我正在尝试设置上传和下载目录,以便从目录上传文件并将文件下载到我框架中的特定文件夹。 I tried many different ways to write the file path in the Serenity Configuration file, but none of them worked.我尝试了许多不同的方法来在 Serenity 配置文件中写入文件路径,但都没有奏效。

chrome_preferences.download.default_directory = ./src/test/resources/downloads
chrome_preferences.download.default_directory = "{user.dir}/src/test/resources/downloads"
chrome_preferences {
 download.default_directory = /src/test/resources/downloads
}

For the upload directory, I found only one solution: directly in my method I specified upload file path like this对于上传目录,我只找到了一种解决方案:直接在我的方法中指定上传文件路径,如下所示

String fileSeparator = System.getProperty("file.separator");
String filePath = System.getProperty("user.dir") + fileSeparator + "src" + fileSeparator + "test" + fileSeparator + "resources" + fileSeparator + "test_data" + fileSeparator + "testFile.xml";

But this method doesn't work for the download functionality.但是这种方法不适用于下载功能。 Please advise me, how can I solve this problem?请告诉我,我该如何解决这个问题?

So, the only option I found was in the Serenity Configuration file to write the download path like this:因此,我发现的唯一选项是在 Serenity 配置文件中编写下载路径,如下所示:

chrome_preferences.download.default_directory = "${user.dir}"

It allows me to download only to the project directory, not to a specific folder, which is not good.它只允许我下载到项目目录,而不是特定文件夹,这不好。 But at least I'm able to download it.但至少我可以下载它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM