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


#1

The context is i’m using https://zalando.github.io/zalenium/ 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?


#2

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”)

}


#3

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


#4

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 ?