Hi,
My goal is to update the Download path of my Chrome so that I know where to get the download file. This will be run on a VM so the path cannot be hardcoded
Desired download path = ProjectDir + ‘Download’ folder
Also needed to also have safebrowsing.enabled as true to keep the popup “This type of file can harm your computer” away
I tried to manually set everything at Project > Settings > Desired Caps > WebUI > Chrome:
And you can also check it in the com.kms.katalon.core.webui.chrome.properties
{"CHROME_DRIVER":{"prefs":{"download.default_directory":"C:\Users\btp\WorkSpace\btp-mlab\Downloads","safebrowsing.enabled":true}}}
So if I just run my test case it will run smoothly without issue.
HOWEVER, since I cannot hardcode the path since my test cases will be run in a VM I need to update the com.kms.katalon.core.webui.chrome.properties at runtime.
So I have this code:
@Keyword
def updateDownloadPath() {
String strDownloadsPath = RunConfiguration.getProjectDir() + ‘/Download’
strDownloadsPath = strDownloadsPath.replace('/', '\\')
String data = '{"CHROME_DRIVER":{"prefs":{"download.default_directory":"' + strDownloadsPath + '","safebrowsing.enabled":true}}}'
FileUtils.writeStringToFile(file, data, Charset.defaultCharset(), false)
}
This will overwrite everything in com.kms.katalon.core.webui.chrome.properties
IF I call this method @BeforeTestCase it will just be ignored the hardcoded data above will still be what Katalon will use. Also I noticed after the runtime the Capabilities disappear
IF I call this method before I click the download button still it is ignored.
Did I miss an important thing for this to work? Will really appreciate if you can help me. Thank you!