…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
System.setProperty("webdriver.chrome.driver","C:\\path\\to\\chromedriver.exe")
System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe")
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
DriverFactory.changeWebDriver(ff)
WebUI.navigateToUrl("www.firefox.com")
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:
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.executeJavaScript('window.open();', [])
WebUI.switchToWindowIndex(currentWindow + 1)
WebUI.navigateToUrl('www.google.com')
WebUI.waitForPageLoad(5)
Do some other actions here ....
WebUI.switchToWindowIndex(currentWindow)