Intuitively, and as per documantation,it should’ve been simple as this: openBrowser(‘’) - opens the browser, closeBrowser() - closes it.
Investigating an issue with running Katalon on Window agent on Jenkins with Katalon Plugin (there is no issue while running the same tests on Linux agent) Caused by: com.kms.katalon.core.webui.exception.BrowserNotOpenedException: Browser is not opened,
I’ve just learned that on my local Windows, it works like the following:
If you open a browser in each test of the test suite and never use WebUI.closeBrowser() , still the broswer gets closed after each test
If you have a test with just 1 line WebUI.closeBrowser(), the browser will be open and then closed
If you have a test with just 2 lines
the browser will be a) opened b) closed c) opened
Question #1: Is all this expected and what else additional logic is used (if any)?
Question #2: If this is expected, where is this documented?
Question #3: If it’s not documented, then WHY is it NOT documented?
Opening and closing a browser is a time consuming operation, so it would be great to have some conrol over it. Is it possible to determine whether or not the browser is open?
If 2 is expected, then it’s great (though I doubt that it’s intuitively expected), still, why is that logic not documented? The “codeless” testing is a Katlalon sale point, not “documentless” testing and not the testing when an ability to understand someone’s enterprise code is a must.
The WebUI.openBrowser() checks if a browser window is already opened by a previous call of WebUI.openBrowser(). If yes it reuses the previous browser. It refrains from opening a new browser window. Consequently, using WebUI.openBrowser keyword, you can open only a single browser window. Regardless accidentally or intentionally, you will not open 2 or more browser windows by WebUI.openBrowser keyword.
This behaviour is not equivalent to the 2nd Post-Execution Option: Terminate drivers after each Test Case.
This behaviour (WebUI.openBrowser opens does not open multiple browser windows) is good for usual cases; careless testers may forget calling WebUI.closeBrowsers(), and they may fall into a difficult situation. Therefore I think it is acceptable that this behaviour is NOT documented in detail.
I’m running the suite with multiple test cases and each of them has just one line WebUI.openBrowser(''). Visually it looks like the browser is opened and closed as many times as many test cases are included in the test suite. So, yes, as you wrote, I’ve never seen more than 1 browser open at the same time but , it looks (at least visually) like the previously opened browser (if any) gets closed and a new one gets opened every time and, if this is the case, it’s a waste of time and resources.
To the best of my knowledge, that’s what I see on Windows and it might be different on other OS. I started looking into it because there is an issue with running Katalon on Window agent on Jenkins with Katalon Plugin (there is no issue while running the same tests on Linux agent) Caused by: com.kms.katalon.core.webui.exception.BrowserNotOpenedException: Browser is not opened.
By the way, as an expert on Katalon, can you please explain witch Terminate drivers after each Test Suite would take preference
the one in the settings (as in the screenshot above)
I don’t think so. I think that a single WebDriver process is sustained and reused. But if you turn the option “Terminate drivers after each Test Case” ON, then yes the driver process will be terminated on end of each Test Cases (when a driver process terminates, it will close the browser window together).