Omega Weapon
unread,Mar 14, 2012, 9:25:33 AM3/14/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Selenium Users
I am currently working on a task where I need to do basic selenium
testing with a site, but kill off all 3rd party javascript. This
simplest way I am aware of to do this is to install the NoScript addon
in the Firefox proflle, and then allow the relevant site:
=================================================================================
# Obtaining a Firefox profile (a profile is created from scratch
by
# default when the WebDriver is used to control Firefox)
profile = webdriver.FirefoxProfile()
# Installing NoScript addon - 3rd party javascript is not supposed
to interfere with
# these tests
profile.add_extension('C:\\Python27\\Lib\\site-packages\\selenium\
\webdriver\\firefox\\noscript-2.3.4.xpi')
# Disabling startup redirect to NoScript site
profile.set_preference('noscript.firstRunRedirection', False)
# Allowing site - this key is not accessible via
# about:config, you need to get to an example profile's 'prefs.js'
- I
# have copied and appended the domain here
profile.set_preference('capability.policy.maonoscript.sites',
'<many many sites here with relevant one appended>')
# Launching firefox instance with the relevant profile
driver = webdriver.Firefox(profile)
=================================================================================
The whitelisting of the domain like this is a bit brute force
(obtaining a copy of all whitelisted sites in a string then appending
mine, so obviously will go out of date soon etc) - does anyone know of
a better way to programmatically tell NoScript to whitelist a domain?
Thanks for any help.