When I attempt to open a second browser, the browser opened first is closed, without there being a close browser command. For example…
…results in only one browser open at the end of the test.
Is this deliberate behaviour, or perhaps a defect? Is there any way to be able to open two concurrent browsers, does anyone know please? I need a second browser open to perform an action that will affect the outcome of the session in the first browser.
you can open two WebDrivers manually and switch between them. Drivers are located in Katalon installation folder - configuration\resources\drivers
WebDriver chrome = new ChromeDriver()
WebDriver ff = new FirefoxDriver()
// let Katalon know that chrome driver is usedDriverFactory.changeWebDriver(chrome)// Katalon keywords work as usual
WebUI.navigateToUrl("www.chrome.com")// now you can switch to FF driver
Thank you Marek, that looks very interesting, I’ll give that a try.
Thinking ahead, how will this work when I eventually end up running my tests in a Test Suite Collection, for a variety of browsers?
And do you know why Katalon closes the browser currently without a close browser commmand? Is this expected/desired behaviour?
When you end your work, just call close() on both/all drivers - it terminates them.
Regarding closing browser after test case - I think it is desired behavior of Katalon, but don’t know why. Maybe some kind of resource protection, if you forget to terminate driver, you can run out of HW resources after few tests.
If anyone is having a hard time finding which import statements are needed to get the above code to work, the following should do:
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.firefox.FirefoxDriver as FirefoxDriver
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.chrome.ChromeDriver as ChromeDriver
On macOS, drivers can be found in the following directory:
What is the folder path for katalon inside docker?
Kevin, Did you ever figure out a good approach for opening and using multiple browsers across test cases within a test suite?
Hi, I’m afraid I didn’t find a good solution, I just worked-around this issue by re-opening a browser when required (I still don’t know if the closing of browser 1 when browser 2 is opened is for technical reasons, or a defect, or something else).
I’ve found this works well for me guys
def currentWindow = WebUI.getWindowIndex()
WebUI.switchToWindowIndex(currentWindow + 1)
Do some other actions here ....