1

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:password@site.com/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?

djangofan
  • 26,842
  • 57
  • 182
  • 275
Vanatomas
  • 143
  • 15

1 Answers1

4

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"));
Bhargav Rao
  • 45,811
  • 27
  • 120
  • 136
djangofan
  • 26,842
  • 57
  • 182
  • 275
  • this one looks like Java to me – Vanatomas May 13 '15 at 15:48
  • I believe a Ruby version of Selenium is available and appears to be up to date with the latest version of Selenium (not Watir) : https://code.google.com/p/selenium/wiki/RubyBindings . The code would be similar to the Java method. – djangofan May 13 '15 at 16:19