Can 'browserType='Remote' be set from test cases being executed?

Katalon Studio Version:
KSE 8.2.5, Build 208
Windows 10 Enterprise (64-bit)
Chrome: 97.0.4692.99 (Official Build) (64-bit)

Hi Folks, I have the following included in my Katalon ‘Remote Desired Capabilities’ setup:
Remote Server URL: http://username:xxxxxxxxxxxxxx@hub.lambdatest.com/wd/hub
browserName|String|Chrome
version|String|97.0
platform|String|Windows 10
build|String|TestBuild
name|String|TestName
RemoteServerUrl1

When I manually execute test cases from “Run > Remote” they run on the ‘Remote Server’ as expected. To run test cases through Katlon (TestCases/TestSuites), I have to set the ‘Default execution browser’ to ‘Remote’. We only have a few test cases that need to be run on the “Remote Server” so I need to have my ‘Default execution browser’ set to ‘Chrome’. Is there a way we can set the 'browserType=‘Remote’ from the test case being executed?

I am using the following TCs to override the Remote Desired Capabilities ‘build’ & ‘name’ settings based on test case run. These work as expected.

//TC02-www.google.com
//Overrides Remote Desired Capabilities 
import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
RunConfiguration.setDriverPreferencesProperty('Remote', 'browserName', 'Chrome')
RunConfiguration.setDriverPreferencesProperty('Remote', 'version', '97.0')
RunConfiguration.setDriverPreferencesProperty('Remote', 'platform', 'Windows 10')
RunConfiguration.setDriverPreferencesProperty('Remote', 'build', 'BuildOne')
RunConfiguration.setDriverPreferencesProperty('Remote', 'name', 'TC01-www.google.com')

//Opens Google.com
WebUI.openBrowser('')
WebUI.navigateToUrl('https://www.google.com')
WebUI.waitForPageLoad(30)
WebUI.delay(5)
WebUI.closeBrowser()
//TC02-www.google.ca
//Overrides Remote Desired Capabilities 
import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
RunConfiguration.setDriverPreferencesProperty('Remote', 'browserName', 'Chrome')
RunConfiguration.setDriverPreferencesProperty('Remote', 'version', '97.0')
RunConfiguration.setDriverPreferencesProperty('Remote', 'platform', 'Windows 10')
RunConfiguration.setDriverPreferencesProperty('Remote', 'build', 'BuildOne')
RunConfiguration.setDriverPreferencesProperty('Remote', 'name', 'TC02-www.google.ca')

//Opens Google.ca
WebUI.openBrowser('')
WebUI.navigateToUrl('https://www.google.ca')
WebUI.waitForPageLoad(30)
WebUI.delay(5)
WebUI.closeBrowser()

@Brandon_Hein

You could always create a RemoteWebDriver instance with all the capabilities that you want, then tell Katalon to use this custom driver:

ChromeOptions options = new ChromeOptions();
// add all desired capabilities...
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://username:xxxxxxxxxxxxxx@hub.lambdatest.com/wd/hub"), options);
DriverFactory.changeWebDriver(driver);

This way you have full control over how the driver is configured for this specific test (or set of tests), and don’t need to fuss with setting it in the project settings. On that note, if you have more than one test that will use this remote driver, I would recommend wrapping this in a method (custom keyword) so you don’t repeat yourself.

1 Like

Thanks @Russ_Thomas & @Brandon_Hein,
This is working as expected.

Cheers,
Dave

1 Like