简体   繁体   中英

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.

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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