facing this issue–
I am trying to click on a link , verify the URL, close it and go back to original window.
From last two versions of Katalon , I am seeing Chrome CDi mapper extenstion window coming up because of which the below code is not working.
I tried debugging and trying to switching to each window and closing it – it closing the entire browser with error . (Mar 04, 2025 9:47:04 AM org.openqa.selenium.remote.http.WebSocket$Listener onError
WARNING: Connection reset
java.net.SocketException: Connection reset)
Below one is simple code which I had earlier and now with detailed code to debug which is not working either.
One more observation :
I tried to print the Title and Current URL when its switched to that window.
The Title of the Link which is opened and the chrome (CDi mapper) is interchanged
Your help is appreciated
@Keyword
def public static clickAndVerifyLinkContains(String testObjectId, String expectedURL) {
//code to click on the hyperlink
WebUI.click(findTestObject(testObjectId))
WebUI.switchToWindowIndex(1)
WebUI.waitForPageLoad(10) // Wait for up to 10 seconds for the page to load
assert WebUI.getUrl().contains(expectedURL)
WebUI.closeWindowIndex(1)
WebUI.switchToWindowIndex(0)
}
@Keyword
def public static clickAndVerifyLink(String testObjectId, String expectedURL) {
WebUI.click(findTestObject(testObjectId))
WebUI.waitForPageLoad(10) // Wait for up to 10 seconds for the page to load
WebDriver driver = DriverFactory.getWebDriver()
String originalWindow = driver.getWindowHandle()
WebUI.delay(2)
Set<String> allWindows = driver.getWindowHandles()
String newWindow = null
// Log the names of all open tabs/windows
allWindows.each { window ->
driver.switchTo().window(window)
WebUI.delay(2)
String currentUrl = driver.getCurrentUrl()
println("Window Title: " + driver.getTitle() + ", URL: " + currentUrl)
}
for (String window : allWindows) {
if (!window.equals(originalWindow)) {
driver.switchTo().window(window)
String currentUrl = driver.getCurrentUrl()
if (currentUrl.contains(expectedURL)) { // && !currentUrl.contains("chrome-extension://")) {
newWindow = window
break
}
}
}
assertNotNull("New window with expected URL not found.", newWindow)
driver.switchTo().window(newWindow)
println("Window Title: " + driver.getTitle() + ", URL: " + driver.getCurrentUrl())
driver.close()
driver.switchTo().window(originalWindow)
}
assertNotNull("New window with expected URL not found.", newWindow)
driver.switchTo().window(newWindow)
println("Window Title: " + driver.getTitle() + ", URL: " + driver.getCurrentUrl())
driver.close()
driver.switchTo().window(originalWindow)
}