I am testing an application that requires a two step authentication. Manually, it goes like this:
-
First: an authentication popup appears where you have to insert some credentials for the system
-
Second: the login page appears where you insert the user email and password. The credentials are not the same as above.
When we run the automated test scripts, the first difference is the second step happens first. That is, first we need to login and only then the authentication popup appears. The login has no problems, the problem is the authentication popup.
Currently we’re able to run tests by using the following method:
//Gets the index of the current tab before opening a new one
int currentTab = WebUI.getWindowIndex()//Opens a new tab
WebDriver driver = DriverFactory.getWebDriver()
JavascriptExecutor js = ((driver) as JavascriptExecutor)
js.executeScript(‘window.open();’)//Switches to the new tab where the authentication popup will appear
WebUI.switchToWindowIndex(currentTab + 1)
WebUI.waitForPageLoad(10)WebUI.navigateToUrl(URL)
The URL has the user and password, like so:
http:\\username:password@url
We also tried a different variation in which we do not open a new window, instead we just do
WebUI.navigateToUrl(URL)
Both have the same result: the popup disappears however, during the test run it randomly appears in steps which makes the test fail because the driver can’t interact with the page. This does not happen when we’re navigating the website outside WebDriver control.
When the popup appears, we’re unable to get the IDs of it either manually or using WebSpy, we’re pretty much unable to interact with the page at all, can’t even open the inspect tools. If we close it manually or go there insert the credentials, it keeps reappearing (again, this does not happen when the browser is not controlled by the web driver)
We read the following topics and pages:
- Cannot access Browser Login prompt/dialog - #12 by mgrandillo - Web Testing - Katalon Community
- Desired Capabilities - The Missing Manual - Tips & Tricks - Katalon Community
- Browser popups handling - Web Testing - Katalon Community
- https://docs.katalon.com/docs/legacy/katalon-studio-enterprise/test-execution/advanced-guides/web-testing/solving-pop-up-dialog-issue-with-katalon-studio
And tried several methods:
-
User WebUI.authenticate method → the method fails
-
Use the Robot method mentioned in one of those pages → does not work because the popup keeps appearing. Furthermore, the method there mentions using the Keyevent to press ENTER and in this case, we’d need to be able to send text to the fields of the popup and even though the OP asked in that topic if that was possible, nobody replied. We read the documentation for the Robot and KeyEvent classes (Robot (Java SE 10 & JDK 10 ) and KeyEvent (Java SE 10 & JDK 10 )) and were not able to find any method to send text either. But as mentioned, even if we were able to do so, the popup would just keep appearing, like it happens when we insert the credentials manually
-
Change the desired capabilities: we followed one of those pages and found two capabilities that could be related with the issue:
- First one: we just inserted in the project Settings the capability extensions.alerts.initialized and set to false → it did not work
- Second one: based on this page, we tried to set silent notifications Chromium Blog: Introducing quieter permission UI for notifications → it didn’t work
- First one: we just inserted in the project Settings the capability extensions.alerts.initialized and set to false → it did not work
So at this point we’re out of ideas. The method of sending the credentials in the URL works so we can run tests, but the goal here is to avoid the situation in which the test fails because the popup decides to randomly appear during some test executions.
Can someone help here?
Thank you.
PS → the screenshots were manipulated to hide identifying information due to security reasons, but I hope you get the idea




