Tuesday, 19 February 2013

How to set proxies with Username and Password in FirefoxDriver


Setting up Custom Firefox Profile to run Selenium Tests on Desktop Firefox

Even though Selenium – WebDriver – FirefoxDriver – Proxy with Basic/Kerberos Authentication didn’t work, you can achieve this with an alternate step that overrides Firefox browser Proxy Authentication.

The alternate step is nothing but allowing WebDriver to run tests on default/custom Firefox profile rather than running from FirefoxDriver.

Note:
In Selenium 2.0 (WebDriver) every popular browsers has its own selenium drivers to run tests.

Let us go with the concept now…


Create Firefox Profile Manager

Important: Before you can start the Profile Manager, Firefox must be completely closed.

1. At the top of the Firefox window, click on the Firefox button and then select Exit
2. Press Win + R (click the Windows Start button and select Run... on Windows XP).
3. In the Run dialog box, type in:
    firefox.exe -p
4. Click OK.



5. Now, create the firefox profile "myProjectProfile".

If the Profile Manager window does not open, Firefox may have been running in the background, even though it was not visible. Close all instances of Firefox or restart the computer and then try again.

Add this New Firefox Profile on your code

ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("myProjectProfile");
WebDriver driver = new FirefoxDriver(myprofile);

Firefox configuration settings

This works fine without prompting any authentication when you do the following settings..

1) Type "about:config" on your FF url
2) Now type "Proxy" in the search field
3) Make sure "signon.autologin.proxy" is set "true" (By default it is "false")

38 comments:

  1. I was looking for a Proxy Prompt solution for some time now. Noone has EVER mentioned the "signon.autologin.proxy" setting!

    This solved my problem. THANK YOU!

    ReplyDelete
    Replies
    1. Most Welcome!! Logan, If you wish to promote this, please upvote me on Stackoverflow for this answer so that I gain more levels to access Stackoverflow for answering questions.

      http://stackoverflow.com/questions/5672407/basic-authentication-in-selenium-2-set-up-for-firefoxdriver-chromedriver-and/16229554#16229554

      If you wish to have any other topics in this blog, please lemme know ;)

      Thank you!
      Prashanth Sams

      Delete
  2. I followed the above instructions carefully but the authentication dialog box still appears and I am required to click the "Ok" button before the test will continue execution using the saved credentials.

    I'm using Firefox 23.0.1

    ReplyDelete
    Replies
    1. use autoauth add on available in https://addons.mozilla.org/en-us/firefox/addon/autoauth/developers

      Delete
    2. This was the only solution that worked for me

      Delete
  3. Did anyone get any solution on this?

    ReplyDelete
  4. These queries seems to be new for me :) May be you would have missed any of those steps.

    ReplyDelete
  5. I also got the same problem.
    On windows authentication, the username and password is typing automatically.
    But its not clicking "OK" button.

    ReplyDelete
  6. I tried using web driver navigate and get..But control is not coming out of both the api to use other webdriver api to click enter key

    ReplyDelete
  7. Hey, is there any update on this?

    ReplyDelete
  8. Same issue i am facing...any solutionplease?

    ReplyDelete
  9. Try to set network.auth.force-generic-ntlm = true in about:config
    Or add required URLs to network.automatic-ntlm-auth.trusted-uris (comma-separated)

    ReplyDelete
  10. I look the site it was a very good and very informative in many aspects thanks for share such a nice work.
    access New Album Releases in UK

    ReplyDelete
  11. I'm really impressed with your writing skills and also with the format on your weblog.
    BitSnoop UK proxy

    ReplyDelete
  12. Thanks for giving me information about my problem. I was searching the NET and here I found. Also if you want more work just click
    Bee MP3 UK proxy

    ReplyDelete
  13. Thanks man. I was with a serious issue here and you solve it!

    ReplyDelete
  14. Your this blog giving us very much information thanks for share this.
    access Mp3Juices in UK

    ReplyDelete
  15. see it herelook what i found Sourcehe has a good point have a peek at these guysi was reading this

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete