Is it possible to add relative path in Desired Capabilities

Is it possible to add relative path in Desired Capabilities?

Hi @discover.selenium.
No, it’s not possible to put there a relative path. I noticed this shortcoming when I was trying the same for my use case: A custom download path.
A workaround I found is using Test Listeners somewhere on this community is to set desired capabilities during run-time just before the browser is actually opened.
An example of my code that you should be able to adjust to your needs below (I trimmed it a bit down as it’s contains more, but isn’t valuable for your specific question). Nutshell: I have a global variable (profile) value called “downloadPath” which leads to a folder within my project repo. So it will run locally and in any build pipeline. These settings below are for chrome.
Hope this helps!


import com.kms.katalon.core.annotation.BeforeTestCase
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.util.KeywordUtil

import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.Files

import internal.GlobalVariable

class BeforeTc3SetSpecificDownloadDirectoryIfNeeded {
     * Executes before every test case starts.
    def setSpecificDownloadDirectoryIfNeeded() {

            Map desiredCapabilities = RunConfiguration.getDriverPreferencesProperties("WebUI")
            String projectDir = RunConfiguration.getProjectDir()
            Path projectPath = Paths.get(projectDir)
            Path downloadPath = projectPath.resolve(GlobalVariable.downloadPath)
            // you do not need / and \ here, which works on OS Windows & Linux!
            def customizedDownloadDirectory = downloadPath.toString()

                Map prefs = desiredCapabilities.get("prefs")
                if (prefs == null) {
                    prefs = [:]
                KeywordUtil.logInfo("BeforeTc3SetSpecificDownloadDirectoryIfNeeded: We detected test name contains \"download\" so we get current desiredCapabilities prefs =" + prefs.toString())
                KeywordUtil.logInfo("BeforeTc3SetSpecificDownloadDirectoryIfNeeded: ...and set desiredCapabilities to work with a customized download directory = RunConfiguration.getProjectDir() + / + GlobalVariable.downloadPath = : $customizedDownloadDirectory")
                prefs.put("download.default_directory", customizedDownloadDirectory)
                prefs.put("download_dir", customizedDownloadDirectory)
                prefs.put("download.directory_upgrade", true)
                prefs.put("download.prompt_for_download", false)
                prefs.put("plugins.always_open_pdf_externally", true)
                prefs.put("profile.default_content_settings.popups", "0")
                prefs.put("profile.content_settings.exceptions.automatic_downloads.*.setting", "1")
                RunConfiguration.setWebDriverPreferencesProperty("prefs", prefs)
                RunConfiguration.setWebDriverPreferencesProperty("args", ["--no-sandbox", "--disable-dev-shm-usage"])
                RunConfiguration.setWebDriverPreferencesProperty("useAutomationExtension", "false")

Thank you @joost.degeyndt :slightly_smiling_face: