Vanatomas
Vanatomas

Reputation: 153

A "Basic Authentication" popup appears several times using Selenium

I am using Selenium with Ruby. I have to switch between pages that require authentication. Initially I push username and password with the url.

http://username:[email protected]/page

However, after couple steps, when I am redirected to another page, there is still authentication popup again.

How would I pass username/password again?

Upvotes: 1

Views: 1028

Answers (1)

djangofan
djangofan

Reputation: 29669

The authenticateUsing() method is still currently in beta but I think it will be part of Selenium 3.0, when its finally released. From Prashanth Sams's answer:

The Alert Method, authenticateUsing() lets you skip the Http Basic Authentication box.

WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword("USERNAME", "PASSWORD"));

Upvotes: 4

Related Questions