Authentication popup keeps appearing in Chrome

I am testing an application that requires a two step authentication. Manually, it goes like this:

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:

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:

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

Sorry, I don’t have a solution for you.

2FA and similar does not seem to be supported out of the box. I’ll place a callout here in case I am mistaken. @vu.tran @vu.le @duyluong @Brandon_Hein.

Hi Joana,

Could you try to add this custom keyword to your project and set it before your login step to see if it resolved your issue?

AuthenticateKeyword.groovy (6.4 KB)

Best
Dani

Hello,

Thank you so much for trying to help.

I am sorry for the delayed replied but for some reason I was not notified by email of this answer. I tried the solution, however, unfortunately it does not work. I still get the popup.

Joana