in Testing by (20.8k points)
Explain how you will log in into any site if it is showing any authentication popup for username and password?

1 Answer

0 votes
by (31.6k points)
If there is a pop up for logging in, we need to use the explicit command and verify if the alert is actually present. The below code helps you understand the use of explicit wait command.

1

2

3

WebDriverWait wait = new WebDriverWait(driver, 10);

Alert alert = wait.until(ExpectedConditions.alertIsPresent());

alert.authenticateUsing(new UserAndPassword(**username**, **password**));

Related questions

0 votes
asked Mar 28, 2021 in Testing by rajeshsharma (23.9k points)
0 votes
asked Mar 27, 2021 in Testing by rajeshsharma (23.9k points)
0 votes
asked May 26, 2019 in Testing by rajeshsharma (23.9k points)
...