Reputation: 333
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...
Upvotes: 0
Views: 1210
Reputation: 5113
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:
Upvotes: 1
Reputation: 42518
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:[email protected]/basic_auth")
Upvotes: 1
Reputation: 3927
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
Upvotes: 1