I am trying to launch chrome driver in between Windows Test execution. I know, I can create separate Tests and create separate test suites and configure in Test Suite Collection.
But my need is to get some data from a Web Page while most of the test would run in a Windows Application.
The following code demonstrates how to open Chrome Browser without calling WebUI.openBrowser(). The WebUI.openBrowser() keyword does almost the same as this internally.
import org.openqa.selenium.WebDriver
import org.openqa.selenium.remote.DesiredCapabilities
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.driver.WebUIDriverType
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
DesiredCapabilities options = new DesiredCapabilities()
WebDriver driver = DriverFactory.openWebDriver(WebUIDriverType.CHROME_DRIVER, options)
DriverFactory.changeWebDriver(driver)
// you can use any WebUI.* keywords after changeWebDirver(driver)
WebUI.navigateToUrl("http://demoaut.katalon.com/")
WebUI.delay(3)
WebUI.closeBrowser()
You can read the source of com.kms.katalon.core.webui.driver.DriverFactory class (though it is very old version) at:
That piece of code did not work for me. I tried debugging and found out that, âopenWebDriver()â first looks for the chromedriver in [projectdir]/include/ section. (But Katalon actually keeps it in Installation folder).
When it does not find in that place, it goes to else condition, where it looks for system configuation property. Since, the system configuration is loaded with WINDOWS Preferred configuration, it throws exception.
Since your Katalon Studio project is set with WINDOWS Prefered configuration, your Katalon Studio is not able to find the binary of ChromeDriver. Therefore you can not rely on Katalon Studio to resolve the location of the binary at runtime when you run your WINDOWS project. This is what you reported, I did not know. Thank you for your investigation.
However, a countermeasure is possible. In order to let your project run successful, you need to find out where the ChromeDriver binary is located. Once you have got it, you can explicitly specify the location string of the binary in your test script.
Q1 How can you find the location of the binary of ChromeDriver?
For research purpose, you want to create a new project of âWebUI configurationâ. In that project, you call DriverFactory.getChromeDriverPath, which will return a string. The returned string tells where you can find the ChromeDriver binary bundled in Katalon Studio.
Q2 How can you start up the ChromeDriver while specifying the path of the binary?
com.kms.katalon.core.webui.driver.DriverFactory class is there to let you use the ChromeDriver binary bundled in the Katalon Studio project.
If you do not like hard coding the path of the binary, an alternative is available
This library enables you to download and install the latest ChromeDriver into your machine, outside Katalon Studioâs control, and make it available to your code in Groovy/Java including Katalon Test Case script.
You need to download and place the jar of webdrivermanager in the Drivers folder as the following doc describes:
Yup, I was also trying to find the binary location of the chrome driver in runtime. Tried debugging in few internal classes. That would be the best solution to sustain on its own for periodical driver update.