Override desiredCapabilities at runtime using com.kms.katalon.core.annotation.BeforeTestSuite

The context is i’m using Zalenium - A flexible and scalable Selenium Grid. to run my test remotely, it run successfully.
But what i want to achieve is to naming the zalenium’s ‘test name’ in dashboard properly. in the documentation of zalenium it said to naming the test we just append desired new capability become desiredCapabilities.setCapability(“name”, “myTestName”);
I read https://docs.katalon.com/display/KD/Execution+Settings and it works correctly when i added that desired capability in custom driver (builder) properties. which is when using zalenium I would create every test case need to run with its own custom driver (where i put capability test name)

So my question is there any way to add (append) custom desiredCapabilities at the runtime, for example using test listener com.kms.katalon.core.annotation.BeforeTestSuite?

Hi Fachrul,

Of course you can. You can use this function from RunConfiguration class to help you

import com.kms.katalon.core.configuration.RunConfiguration

@BeforeTestSuite

def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) {

RunConfiguration.setWebDriverPreferencesProperty(“name”, “myTestName”)

}

1 Like

Hi Vinh Nguyen,
it works like a charm. thank you!
Mission accomplished :slight_smile:

Hello Vinh

I have firefox anda Katalon 5.8 …

Don’t work for me here with :

profile.setPreference(“browser.download.manager.showWhenStarting”, false)
profile.setPreference(“browser.download.useDownloadDir”, false)
profile.setPreference(“browser.helperApps.neverAsk.saveToDisk”, “text/csv”)
profile.setPreference(“browser.helperApps.neverAsk.openFile”, “text/csv”)
profile.setPreference(“browser.download.folderList”, 2)
profile.setPreference(“intl.accept_languages”, “fr”)
profile.setPreference(“browser.download.downloadDir”, “C:\XXX\YYY”)

I have put them like you said in “sampleBeforeTestSuite” of the “Test Listener”

Is because i’m using Firefox ?