0

Good day to all.

I'm use Selenium WebDriver to automatically test execute. But on development site using HTTP base autentification. I found AutoAuth addon for Firefox. It save login/password and don't need type credentional each time.

But this plugin don't save credentions. I'm reinstall addon and firefox, delete cookie, but nothing. On this machine in other user plugin work successfylly. Maybe, anybody have and resolve this problem?

To author of addon I wrote already.

Way:https://login:passwd@host don't help too...

Kosmos
  • 335
  • 1
  • 4
  • 15

3 Answers3

1

Do you mean plugin not working on invoking with webdriver? simple way to create profile and call that provide in webdriver.

Here is the way to create firefox profile. Install that add-in and save credentials.

Call above saved profile in webdriver

   ProfilesIni allProfiles = new ProfilesIni();
   FirefoxProfile profile = allProfiles.getProfile("selenium");
   WebDriver driver = FirefoxDriver(profile);

Thank You, Murali

murali selenium
  • 3,637
  • 2
  • 9
  • 18
1

If it's a HTTP Basic Authentication, then you can set the credentials in the URL. Note that it requires to set the "network.http.phishy-userpass-length" preference to enable it.

Here is a working example with Selenium / Firefox / Python:

from selenium import webdriver

profile = webdriver.FirefoxProfile()
profile.set_preference("network.http.phishy-userpass-length", 255)

driver = webdriver.Firefox(profile)

driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth")
Florent B.
  • 37,063
  • 6
  • 68
  • 92
1

The approach I've used very successfully is to set up an embedded Browsermob proxy server (in Java code) and register a RequestInterceptor to intercept all incoming requests (that match the host / URL pattern in question).

When you have a request that would otherwise need Basic auth, add an Authorization HTTP header with the credentials required ('Basic ' + the Base64-encoded 'user:pass' string. So for 'foo:bar' you'd set the value Basic Zm9vOmJhcg==)

Start the server, set it as a web proxy for Selenium traffic, and when a request is made that requires authentication, the proxy will add the header, the browser will see it, verify the credentials, and not need to pop up the dialog.

You won't need to deal with the dialog at all.

Other benefits:

  • It's a pure HTTP solution, it works the same across all browsers and operating systems.
  • No need for any hard-to-automate add-ons and plugins, any manual intervention.
  • No need for custom profiles, custom preferences etc.
  • You control credentials in your test code, and don't store them elsewhere.
Community
  • 1
  • 1
Andrew Regan
  • 4,887
  • 6
  • 35
  • 67