I was using my own code launch the driver hence used below code to set default download directory
DesiredCapabilities caps = DesiredCapabilities.chrome();
ChromeOptions co = new ChromeOptions();
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("download.default_directory", System.getProperty("user.dir")+"\\downloads\\); -------------Dynamic Path
co.setExperimentalOption("prefs", chromePrefs);
capabilities.merge(co);
WebDriver driver = new ChromeDriver(caps);
Now our organization has provided an internal framework that uses their inbuilt driver. The only way to set capabilities is through the JSON profile.
{
"capabilities": {
"browserName": "chrome",
"browserVersion": "81",
"chromeOptions": {
"args": [
"--headless"
"--start-maximized"
]
}
"prefs": {
"profile.default_content_settings.popups": 0,
"download.default_directory": "C:\Users\workspace\project\downloads\" -------------Path is Static
},
}
}
Hardcoded the download path and changing manually in every machine I run. Is there any way to make this path Dynamic same as above?