4

How do I perform basic authentication for FirefoxDriver, ChromeDriver, and the I...

 2 years ago
source link: https://www.codesd.com/item/how-do-i-perform-basic-authentication-for-firefoxdriver-chromedriver-and-the-ie-driver-in-selenium-webdriver.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How do I perform basic authentication for FirefoxDriver, ChromeDriver, and the IE driver in Selenium WebDriver?

advertisements

I am using the Selenium-Firefox-driver and Selenium-Chrome-Driver version 2.0a5 (Web Driver API), and I am trying to test a web app that has BASIC authentication (there is a popup that come up to authenticate the user when I hit whatever page, the popup is not part of the HTML).

Now, I need to a strategy to authenticate the user in Firefox, Chrome and IE (I'm going to import the IE Driver soon).

I was reading in few articles that I can set a Firefox profile for instance..something like:

FirefoxProfile ffProfile = new FirefoxProfile();
ffProfile.setPreference("network.http.phishy-userpass-length", 255);
WebDriver driver = new FirefoxDriver(ffProfile);
driver.get("http://username:password@hostname");

but it doesn't seem to work for me. Does anyone have a working solution for those browsers?


I got it to work with Firefox webdriver by the following:

profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "google.com");
driver = new FirefoxDriver(profile);

driver.Navigate().GoToUrl("http://user:[email protected]");


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK