Cent OS webdriver http authentication

In one of the projects we had to have an https authentication to be able to get to the home page for security reasons. We were looking at various options to get through the authentication during the web driver tests. These were the few options we came across :

  • Remove the authentication itself ! Not a good idea, because we were having client specific information public, on the internet.
  • Another option is this , where they inspect each driver’s methods and call its version of HTTP basic as needed. For us it dint work either.
  • Another option is to use this URL : https://<username&gt;:<password>@<actual_url> and it generally bypasses the authentication. The only problem we had was, in nginx, you usually hit a blank “Site Content” page after which you are actually redirected to your site. But in this case, the redirection was not happening. Also with this method you would be exposing username and password in codebase if done in a simple way.
  • Next was to use the AutoAuth plugin of firefox.

This is plugin is simple. If there is a saved username and password in your profile , it directly fills in the data and takes you to the home page of the site. But here you have the task of entering the credentials the very first time and save it.

Typically centOS doesn’t have a GUI. We need to install the xvfb and start firefox in a display with it. After a huge setup process we were able to finally see firefox run with a GUI using VNC viewer. Finally we tried opening our site in that firefox but we weren’t able to enter the credentials. It might be because of some limitations on firefox running on CentOS. But only if we could enter the credentials the very first time and save it ,we could be able to run the tests without entering the credentials.

After few google searches we tried using Saved Password Editor plugin for firefox. With the CentOS GUI we were able to at least open this plugin and enter the credentials by clicking add new. All details are straight forward, except you would be specifying “Restricted” in “Annotation” when its a java script popup (which is the case here and other web server level authentications ).

After entering the credentials in the saved password manager, when you open the site autoauth automatically authenticates you in to the web page. After this the web driver ran like a breeze !

Leave a comment