How to use selenium alert.authenticateUsing in Katalon?

My web platform throws a sign in browser alert after logging into the application. I searched online and found that the probable solution is to use the following code snippet:

WebDriver driver = DriverFactory.getWebDriver()
Alert alert = driver.switchTo().alert()
alert.authenticateUsing(new UserAndPassword('username','password'))

But I am getting the error:

unable to resolve class UserAndPassword

How can I make this work?

Do you want to use the following class?

Then you need a line

import org.openqa.selenium.UsernameAndPassword

before you call “new UserAndPassword(…)”

Now the import is not recognized:

unable to resolve class org.openqa.selenium.UsernameAndPassword

Are there any other dependencies or am I doing anything wrong?

UsernameAndPassword class seems to be a class added at Selenium 4.

Katalon Studio uses a bit old Selenium v3.141.59. This version does not have the UsernameAndPassword class.

So, you can not use the org.openqa.selenium.UsernameAndPassword in Katalon Studio. END.

As shown in selenium-api 3.141.59 javadoc (org.seleniumhq.selenium)

The Alert.authenitcateUsing() method is not available in the Selenium v3.141.59 bundle in Katalon Studio.