Question

I'm attempting to use the selenium-webdriver [ruby bindings][1] to access an internal web-site that requires a proxy to be configured, and HTTP Basic Auth.

I currently have:

  require "selenium-webdriver"
  driver = Selenium::WebDriver.for :firefox
  driver.navigate.to "http://my-internal-site.com"

But this fails due to both the proxy and http auth issues. If I add my username and password to the URL (i.e. http://username:password@site.com) I can do basic authentication on another site that doesn't require the proxy, but this doesn't seem like an ideal solution.

Any suggestions?

Was it helpful?

Solution

Unfortunately doing http://username:password@site.com has been the standard way of doing but with more and more browsers blocking this approach. Patrick Lightbody of BrowserMob discussed in the company blog on how they get it to work.

OTHER TIPS

Until there is full support for this across browsers for WebDriver (or Selenium), alternate option is to integrate w/ desktop GUI automation tools, where the desktop GUI tool will automate the HTTP authentication part. You can probably find some examples for this or file downloads, uploads if you google for things like "Selenium AutoIt", etc.

For a cross platform solution, replace AutoIt with Sikuli or something similar.

I tried the approach with AutoIt and it worked fine until Selenium 2.18.0, because they implemented UnhandledAlertException, which will be thrown as soon as the proxy login dialog pops up. if you try to catch it, you end up with an driver=null, you would need to loop the attempt to create a driver and trust into your AutoIt Script to kill the window.

If you're using Google-Chrome, try creating a custom extension and import it through ChromeOptions. It supports http(s) that wasn't supported by browsermob_proxy in Chrome. In-case of redirects testing, this is the only way that will help you as of now...

For details, check this post https://devopsqa.wordpress.com/2018/08/05/handle-basic-authentication-in-selenium-for-chrome-browser/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top