Reputation: 1915
I want to set a custom profile for Firefox using Selenium module. Here is my code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class oo1():
def __init__(self, url):
self.url = url
def fps(self):
print 'running fp'
self.profile = webdriver.FirefoxProfile()
self.profile.set_preference('network.proxy.type', '1')
self.profile.set_preference('network.proxy.socks_remote_dns', 'true')
self.profile.set_preference('network.cookie.cookieBehaviour', '2')
self.profile.set_preference('javascript.enabled', 'False')
self.profile.update_preferences()
def driverr(self):
print 'running'
self.web = webdriver.Firefox(firefox_profile=self.profile)
self.web.get(self.url)
s = oo1('127.0.0.1')
s.fps()
s.driverr()
When I run the above code, Firefox runs properly but none of the settings that I wrote above are applied to the Firefox.
What is the problem and How do I fix that?
Upvotes: 1
Views: 236
Reputation: 473763
Multiple issues here:
network.cookie.cookieBehavior
(no u
there)javascript.enabled
is a frozen preference and cannot be changed Fixed version:
self.profile = webdriver.FirefoxProfile()
self.profile.set_preference('network.proxy.type', 1)
self.profile.set_preference('network.proxy.socks_remote_dns', True)
self.profile.set_preference('network.cookie.cookieBehavior', 2)
self.profile.set_preference('javascript.enabled', False)
self.profile.update_preferences()
Upvotes: 1