The Alert Method, authenticateUsing() lets us skip the Basic Http Authentication box.
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword(username, password));
You can probably think of using the Alert method, authenticateUsing(). This lets you skip authentication box. Try this:
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword(username, password));
I hope this helps!
Enroll for the Selenium Course to learn more about the Selenium Webdriver.
Thanks!