I’m facing a strange situation where local test run has no issues, but running tests via CI/CD using KRE > failed with below reason:
com.kms.katalon.core.webui.exception.BrowserNotOpenedException: Browser is not opened
Driver info: driver.version: unknown
This is happening randomly not all the time - I was not able to find the reason
About my configuration, I wrote a custom webdriver class to pick a local webdriver file within project repo
class ChromeCustomDriver {
public static WebDriver mydriver = null;
public static CommonDriverUtils commonDriverUtils = new CommonDriverUtils();
public void initializeCustomDriver(driver, mode) {
ChromeOptions options = new ChromeOptions()
options.setExperimentalOption("prefs", commonDriverUtils.setDefaultDownloadPath(driver));
options.addArguments("start-maximized");
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--no-sandbox"); // Bypass OS security model
options.addArguments("--ignore-ssl-errors=true")
options.addArguments("--ignore-certificate-errors")
options.headless=mode
options.addArguments("--window-size=1920x1080");
// options.setBinary('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome')
mydriver = new ChromeDriver(options);
mydriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS)
DriverFactory.changeWebDriver(mydriver);
WebUI.maximizeWindow()
WebUI.enableSmartWait()
WebUI.navigateToUrl(GlobalVariable.hostUrl);
// int loopCount =5;
WebUI.waitForPageLoad(10)
}
}
Also, I have a test listener which call the selected browser
class RunDriver {
/**
* Executes before every test case starts.
* @param testCaseContext related information of the executed test case.
*/
public static ChromeCustomDriver chrome = new ChromeCustomDriver();
public static FirefoxCustomDriver firefox = new FirefoxCustomDriver();
public static IECustomDriver ie = new IECustomDriver();
public void selectBrowser(BROWSER,MODE) {
switch(BROWSER) {
case 'Chrome': chrome.initializeCustomDriver(BROWSER,MODE)
break;
case 'Firefox': firefox.initializeCustomDriver(BROWSER,MODE)
break;
case 'IE': ie.initializeCustomDriver(BROWSER,MODE)
break;
case 'Safari':''
break;
}
}
@BeforeTestCase
def initDriver() {
selectBrowser('Chrome', true)
}
@AfterTestCase
def tearDown() {
WebUI.closeBrowser();
// DriverFactory.closeWebDriver();
}
}
Everything works fine locally, but running tests with KRE 50/50
Again, I have no issues with path to driver or permissions to execute the file, the problem could be in the KRE itself