public void authenticateOnNextAlert ( String username , String password ) { Credentials credentials = new UserAndPassword ( username , password ) ; Alert alert = driver . switchTo ( ) . alert ( ) ; alert . authenticateUsing ( credentials ) ; }
Authenticates the user using the given username and password . This will work only if the credentials are requested through an alert window .