i want to use selenium to test a website with HTTP basic authentication. This seems to be non-trivial. What I came up with is the following: I use firefox with a custom profile which has the credentials for the website stored and uses the AutoAuth plugin to send these (with no popup intervention). To make selenose use this profile, I patched configs.py as below. Dunno whether you'd consider including this (or a more portable variant) in selenose.
--- lib/python2.6/site-packages/selenose/configs.orig.py 2012-02-07 10:58:58.159132873 +0100
+++ lib/python2.6/site-packages/selenose/configs.py 2012-02-07 11:32:46.499126015 +0100
@@ -173,6 +173,22 @@
# If defined return the integer value, else return nothing
return self.getint('timeout')
+ def get_profile(self):
+ '''
+ Get the firefox profile
+ '''
+ from os.path import expanduser, join
+ from selenium.webdriver import FirefoxProfile
+
+ if self.has('profile'):
+ firefox_cfg = join(expanduser('~'), '.mozilla', 'firefox')
+ profiles = RawConfigParser()
+ profiles.read(join(firefox_cfg, 'profiles.ini'))
+ for section in filter(lambda s: s.startswith('Profile'), profiles.sections()):
+ if profiles.get(section, 'Name') == self.get('profile'):
+ return FirefoxProfile(join(firefox_cfg, profiles.get(section, 'Path')))
+
+
def get_desired_capabilities(self):
'''
Get the desired capabilities.
@@ -241,6 +257,7 @@
'''
return Firefox(**filternone(
timeout=self.get_timeout(),
+ firefox_profile=self.get_profile(),
))
class IeEnv(BaseEnv):
i want to use selenium to test a website with HTTP basic authentication. This seems to be non-trivial. What I came up with is the following: I use firefox with a custom profile which has the credentials for the website stored and uses the AutoAuth plugin to send these (with no popup intervention). To make selenose use this profile, I patched configs.py as below. Dunno whether you'd consider including this (or a more portable variant) in selenose.