<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cloud Testing Blog &#187; HTTP Auth</title>
	<atom:link href="http://www.cloudtesting.com/blog/tag/http-auth/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cloudtesting.com/blog</link>
	<description>Automated Functional, Cross Browser and Load Testing for Websites</description>
	<lastBuildDate>Tue, 23 Aug 2011 18:41:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>HOWTO: HTTP Basic Authentication with Selenium and Cloud Testing</title>
		<link>http://www.cloudtesting.com/blog/2009/08/19/howto-http-basic-authentication-with-selenium-and-cloud-testing/</link>
		<comments>http://www.cloudtesting.com/blog/2009/08/19/howto-http-basic-authentication-with-selenium-and-cloud-testing/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 09:12:37 +0000</pubDate>
		<dc:creator>Phil Smith - Cloud Testing</dc:creator>
				<category><![CDATA[Cloud Testing]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[HTTP Auth]]></category>

		<guid isPermaLink="false">http://blog.cloudtesting.com/?p=642</guid>
		<description><![CDATA[If you need to run tests against a web server that has HTTP Basic Authentication (HTTP Auth) on, there is a simple way to make it work with Cloud Testing and Selenium. When you access the server manually you get one of the pop-up dialogs, depending on which browser you are using. If you fail [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to run tests against a web server that has HTTP Basic Authentication (HTTP Auth) on, there is a simple way to make it work with Cloud Testing and Selenium.</p>
<p>When you access the server manually you get one of the pop-up dialogs, depending on which browser you are using.</p>
<div id="attachment_645" class="wp-caption aligncenter" style="width: 366px"><img class="size-full wp-image-645" title="ChromeAuth" src="http://cloudtesting.files.wordpress.com/2009/08/chromeauth.png" alt="ChromeAuth" width="356" height="226" /><p class="wp-caption-text">HTTP Authentication pop-up in Chrome</p></div>
<p style="text-align:center;">
<div id="attachment_650" class="wp-caption aligncenter" style="width: 448px"><img class="size-full wp-image-650" title="SafariAuth" src="http://cloudtesting.files.wordpress.com/2009/08/safariauth.png" alt="HTTP Authentication pop-up in Safari" width="438" height="282" /><p class="wp-caption-text">HTTP Authentication pop-up in Safari</p></div>
<div id="attachment_649" class="wp-caption aligncenter" style="width: 389px"><img class="size-full wp-image-649" title="OperaAuth" src="http://cloudtesting.files.wordpress.com/2009/08/operaauth.png" alt="HTTP Authentication pop-up in Opera" width="379" height="321" /><p class="wp-caption-text">HTTP Authentication pop-up in Opera</p></div>
<div id="attachment_648" class="wp-caption aligncenter" style="width: 346px"><img class="size-full wp-image-648" title="IEAuth" src="http://cloudtesting.files.wordpress.com/2009/08/ieauth.png" alt="HTTP Authentication pop-up in Internet Explorer" width="336" height="358" /><p class="wp-caption-text">HTTP Authentication pop-up in Internet Explorer</p></div>
<div id="attachment_646" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-646" title="FirefoxAuth" src="http://cloudtesting.files.wordpress.com/2009/08/firefoxauth.png" alt="HTTP Authentication pop-up in Firefox" width="600" height="163" /><p class="wp-caption-text">HTTP Authentication pop-up in Firefox</p></div>
<p>If you fail to get the username and password correct after a number of retries (usually three), you will get a 401 Unauthorised HTTP result code from the server.</p>
<div id="attachment_647" class="wp-caption aligncenter" style="width: 610px"><img class="size-full wp-image-647" title="IE401" src="http://cloudtesting.files.wordpress.com/2009/08/ie401.png" alt="HTTP result code 401 - Unauthorized" width="600" height="480" /><p class="wp-caption-text">HTTP result code 401 - Unauthorized</p></div>
<p>So how do we get round this in Selenium? As we have mentioned in our articles, Selenium does not start processing until the onLoad() event has fired. Since no content has yet been delivered by the web server to the browser, this hasn&#8217;t yet happened, so we&#8217;re stuck.</p>
<p>Fortunately, there is a workaround. In <a href="http://www.faqs.org/rfcs/rfc1738.html">RFC 1738</a>, which covers URLs (Uniform Resource Locators), we are able to use a username and password in the URL. The following quote from the RFC explains how a URL is constructed:</p>
<blockquote>
<pre>; URL schemeparts for ip based protocols:

ip-schemepart  = "//" login [ "/" urlpath ]

login          = [ user [ ":" password ] "@" ] hostport
hostport       = host [ ":" port ]
host           = hostname | hostnumber
hostname       = *[ domainlabel "." ] toplabel
domainlabel    = alphadigit | alphadigit *[ alphadigit | "-" ] alphadigit
toplabel       = alpha | alpha *[ alphadigit | "-" ] alphadigit
alphadigit     = alpha | digit
hostnumber     = digits "." digits "." digits "." digits
port           = digits
user           = *[ uchar | ";" | "?" | "&amp;" | "=" ]
password       = *[ uchar | ";" | "?" | "&amp;" | "=" ]
urlpath        = *xchar    ; depends on protocol see section 3.1

; HTTP

httpurl        = "http://" hostport [ "/" hpath [ "?" search ]]
hpath          = hsegment *[ "/" hsegment ]
hsegment       = *[ uchar | ";" | ":" | "@" | "&amp;" | "=" ]
search         = *[ uchar | ";" | ":" | "@" | "&amp;" | "=" ]</pre>
</blockquote>
<p>Or as a simplified version, your URL needs to look like:</p>
<p>http://username:password@www.mydomain.com/secretarea/</p>
<p>Note that this won&#8217;t work on Internet Explorer, since Microsoft has disabled usernames/passwords in URLs as a security measure. If you want to get round this on an installation you have access to, you can add that functionality back in by modifying your registry, as described in the Microsoft Knowledge Base article <a href="http://support.microsoft.com/kb/834489">http://support.microsoft.com/kb/834489</a>.</p>
<blockquote>
<h3 id="tocHeadRef">How to disable the new default behavior for handling user information in  HTTP or HTTPS URLs</h3>
<p>// To disable the new default behavior in Windows Explorer and 		  Internet Explorer, create <strong>iexplore.exe</strong> and <strong>explorer.exe</strong> DWORD values in one of the following registry keys and set their 		  value data to <strong>0</strong>.</p>
<ul>
<li>For all users of the program, set the value in the 				following registry key:
<div>HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE</div>
</li>
<li>For the current user of the program only, set the value in 				the following registry key:
<div>HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE</div>
</li>
</ul>
</blockquote>
<p>If you use Selenium RC (Remote Control), this is done automatically, as of version 0.9.2. As Cloud Testing is built upon Selenium RC, this is taken care of for you already.</p>
<p>For full details of the services and features available from Cloud testing see <a href="http://www.cloudtesting.com/">www.cloudtesting.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cloudtesting.com/blog/2009/08/19/howto-http-basic-authentication-with-selenium-and-cloud-testing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

