13

the popup window is only happening if I use the Fire Fox browser otherwise, is there a way to fix this problem? I have to enter userid/password every time the i use FF as my browser.

currently, I am entering every time i run my test which is very painful but looking to make it more automated....

I have goggled and found two links here and here but no avail

enter image description here

6
  • i tried something like this - Use the approach where you send username and password in URL Request: http://username:[email protected] - but did not work either... still asking the username/password Commented Aug 28, 2012 at 2:26
  • Which browser is this? case the URL format is not supported by all browsers. If it does not work with webdriver than it should also not work for you manually. Commented Aug 28, 2012 at 5:48
  • I had the same issue (with FF too). It works if you enter the URL manually, but not if you use the webdriver. I haven't found a solution though :( Commented Aug 28, 2012 at 9:27
  • stackoverflow.com/questions/10395462/…> This might help you Commented Aug 28, 2012 at 11:37
  • @Ashwin: I am using IE and its happening only with FireFox Commented Aug 28, 2012 at 13:44

5 Answers 5

7
http://username:[email protected] 

This worked for me (xyz.com being the site name)

Sign up to request clarification or add additional context in comments.

1 Comment

This only works for basic auth, doesnt work for NTLM
5

After spending hours reading I finally found the solution which works pretty well and I hope this will help others too. - Enjoy!!

First - follow this steps:

1) Open the FireFox browser
2) Type the following `about:config`
3) Look for `network.http.phishy-userpass-length` if you don't find then create a new Integer key 
Create a new Integer key (right-click->New->Integer): `network.http.phishy-userpass-length` with value `255`

Second: You need to create a Firefox driver with the following:

FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.http.phishy-userpass-length", 255);
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "YOUR HOST ADDRESS HERE");
_driver = new FirefoxDriver(profile);

let me know if you have any questions.

2 Comments

not working for me. I am using proxy. If I do this, I am not able to use proxy.
This solution worked for me in addition to doing username:[email protected]. Note that username and password should be URL encoded if it has special characters.
5

If this is a windows user account & password, then you need to enable the integrated windows login by setting

network.negotiate-auth.delegation-uris: MyIISServer.domain.com
network.automatic-ntlm-auth.trusted-uris: MyIISServer.domain.com
network.automatic-ntlm-auth.allow-proxies: True
network.negotiate-auth.allow-proxies: True

in the Firefox profile that WebDriver starts. Once you have the profile created and saved (run "Firefox -P" when no other instances are running to select a profile), you can do this in the code:

File profileDir = new File("C:/wherever/SeleniumFirefoxProfile");
FirefoxProfile profile = new FirefoxProfile(profileDir);
profile.setEnableNativeEvents(true);
driver = new FirefoxDriver(profile);

8 Comments

i have enable the integrated windows login in firefox but when i run my test using firefox it prompts me to enter userid/password, any idea?
Can you normally get to the site with no login dialog presented? If so, can you do that manually using a Firefox session that WebDriver launched? If not, then you need to make sure that the profile you created is the one being loaded by WebDriver. By default it loads FireFox with the default empty profile. You need to use the profile manager (the -p option) to create and start a profile, then set the windows pass-through auth. Once that's done, move the profile to a folder and point webDriver at it with the code above. I also installed Firebug in that profile, so I could debug the page.
let me tell you what i have done so far, i folled the link you in your reply which is enable the itnegrated windows login and i have added the site name that i am trying to write test scripts for. answer to your question: we have internal web site that requires windows authentication so if I clear out all my cache and password from my machine and try to login then FireFox did propmet me to enter the userid/password and once i enter my credential and login to the site and will never ask me again unless if i chagne the password. so when i am testing the same site with firefox.
regardless, how many times i enter the credential it always ask me....can you show me the steps how to acheive what you have just said about?
link to a similar discussion here.
|
0

I have had to handle these a few times, but my approach is using a script outside Selenium. Are you working on Windows?

Basically what you do is this:

1) Prior to loading the page, clicking the URL, etc that causes that dialog to appear:

-- Launch an asynchronous script to handle the login

2) Then load the page, click the link, etc

-- Selenium will block until your asynch script completes

The async script:

-- Sleep for a few seconds
-- Activate the dialog
-- Send the username
-- Send a TAB
-- Send the password
-- Send a TAB
-- Send the Enter Key

If you are working on windows, I can post sample scripts to handle this. I've done it with Java and C#, but I would guess that basically the same thing would work regardless of how you are writing your tests (unless you are strictly using the FF plugin, in which case this won't work).

Let me know if you'd like more details.

1 Comment

I would be very interested in the sample C# script if you've still got it available.
0

You can use a FF plugin "autoauth". Download this plugin and create Firefox instance by the following way:

FirefoxProfile firefoxProfile = new ProfilesIni().getProfile("default");
File pluginAutoAuth = new File("D:\\autoauth-2.1-fx+fn.xpi");
firefoxProfile.addExtension(pluginAutoAuth);
driver = new FirefoxDriver(firefoxProfile);

I used "autoauth-2.1-fx+fn.xpi"

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.