简体   繁体   中英

How to use relative file path for firefox profile in Selenium webdriver using java?

I want to use relative file path in Firefoxprofile function, I have tried all possible ways but its throwing error. Here is my code- profile.setPreference("browser.download.dir", "/downloaded_files/");

folder "downloaded_files" is saved in root directory of my project. I tried all combinations of /,//,\\ still its not downloading filed in desired folder.

Try the following

profile.setPreference("browser.download.dir", "./downloaded_files/");

Or

String workingDir = System.getProperty("user.dir");
profile.setPreference("browser.download.dir", workingDir +"/downloaded_files/");

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