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
  • 28,471
  • 61
  • 196
  • 289
Vanatomas
  • 143
  • 1
  • 16

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
  • 50,140
  • 28
  • 121
  • 140
djangofan
  • 28,471
  • 61
  • 196
  • 289
  • 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