I am trying to open a new tab and hitting a URL during my test executions. I know Katalon has these three commands to deal with window switching.
[WebUI] Switch To Window Index
[WebUI] Switch To Window Title
[WebUI] Switch To Window Url
But all of these involve the scenario where a new tab is opened on clicking some link. But in my scenario, I first need to open a new tab, switch to it and then hit a URL by WebUI.navigateToUrl()
I have been using the following for a few weeks:
WebUI.executeJavaScript('window.open();', [])
currentWindow = WebUI.getWindowIndex()
WebUI.switchToWindowIndex(currentWindow + 1)
WebUI.navigateToUrl(myURL)
WebUI.switchToWindowIndex(currentWindow)
This has been working perfectly fine for me, but recently my tests started throwing the following error on the first line of the above code
Caused by: org.openqa.selenium.JavascriptException: javascript error: Cannot read properties of undefined (reading 'match')
Does someone know why the above code would stop working and whether there’s a better way to open a new tab?