Window Index problem when using multiple browsers

Hi,
i’m trying to run a test in which i’ve created two Chrome WebDriver istances, but i got a problem while using WebUI methods when i have more tabs opened in the browsers.
In order, i run this code:

WebUI.openBrowser('')
WebUI.maximizeWindow()
WebUI.navigateToUrl("www.example.it")
WebDriver regularChromeDriver = DriverFactory.getWebDriver()
CustomKeywords.'utility.CommonUtilities.setRegularDriver'(regularChromeDriver)
CustomKeywords.'utility.CommonUtilities.minimizeBrowser'(CustomKeywords.'utility.CommonUtilities.getRegularDriver'())
ChromeOptions options = new ChromeOptions()
options.addArguments('--incognito')
WebDriver incognitoDriver = new ChromeDriver(options)
DriverFactory.changeWebDriver(incognitoDriver)
CustomKeywords.'utility.CommonUtilities.setIncognitoDriver'(incognitoDriver)
WebUI.maximizeWindow()
WebUI.navigateToUrl("www.example2.it")
CustomKeywords.'utility.CommonUtilities.minimizeBrowser'(CustomKeywords.'utility.CommonUtilities.getIncognitoDriver'())
DriverFactory.changeWebDriver(regularChromeDriver)
WebUI.maximizeWindow()

where CustomKeywords.'utility.CommonUtilities contains two static variables referred to the web drivers and the method minimizeBrowser(WebDriver driver) that simply executes this line

driver.manage().window().setPosition(new Point(-2000, 0));

Now, after running the code written above, the test continues interacting with the elements in the first browser and then in the same Chrome instance another tab is opened, so the test executes the following code:

WebUI.switchToWindowIndex(WebUI.getWindowIndex() + 1)
WebUI.waitForElementVisible(WebElement, 10, FailureHandling.STOP_ON_FAILURE)
WebUI.setText(WebElement, variable)
WebUI.delay(4)
WebUI.click(WebElement)

The problem is: everything is ok when switching the windows - the windows index is 1 ( because of the second tab in the browser ) - but when the waitForElementVisible (or waitForElementPresent, or also many other methods like switchToDefaultContent) is executing the window index becomes 0 and the browser switches to the first tab. If i click manually the other tab during WaitFor method, it continues to switch to the first tab.

I am using Katalon Studio Enterprise 9.7.2.

1 Like

Hi there, and thanks for posting in the Katalon community! :hugs:

To help you faster, please review our guide on Custom Keyword here: Introduction to custom keywords in Katalon Studio | Katalon Docs. Double-checking the steps and configurations might resolve the issue.

If the doc doesn’t help, feel free to provide more details, and a community member will assist you soon. Thanks for being a part of our community!

Best,
Albert Le

@albert.vu You should have a developer take a look. What @esibilio.wk is describing sounds like a bug. The problem I have (or anyone else on the outside) is setting up enough code and data to replicate/test the issue.

2 Likes

Thank you @Russ_Thomas and @esibilio.wk for sharing about this issue with us. I’m going to loop in @xuan.tran from our Studio team here so that she can take a look.

Thanks,
Albert


Oh, and as @esibilio.wk is using KSE, you’ll be able to get faster support from our Product Support team by submitting a ticket via the link below:

https://katalon-inc.my.site.com/katalonhelpcenter/s/

How did you know that the window index becomes 0 ? Could you show us any evidence of your finding? Any error log the waitForElementVisible emitted? Does the message clearly tells that “the window index becomes 0”?

You saw waitForElementVisible failed; OK, I understand it. So you infered the cause was the window index being 0 — I have a doubt about it, because you haven’t shown us any evidence.