Posts

Showing posts from March, 2016

How To Access Basic Auth with Selenium

The Problem Sometimes you'll work with applications that are secured behind  Basic HTTP Authentication  ( Basic Auth). In order to access them you'll need to pass credentials to the site when requesting a page. Otherwise you'll get a system level pop-up prompting you for a username and password -- rendering Selenium helpless. Before Selenium 2 we were able to accomplish this by injecting credentials into a custom header. But now the cool kid way to do it it was something like  BrowserMob Proxy . Some people are solving this with browser specific configurations too. But all of this feels heavy. Instead, let's look at a simple approach that is browser agnostic and quick to setup. A Solution By specifying the username and password  in the URL  when visiting a page with Selenium, we can a side-step the system level dialog box from Basic Auth and avoid the need to set up a proxy server. This approach will work for both HTTP or HTTPS pages. Let's take a look