1

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?

1 Answer 1

1

Multiple issues here:

  • the setting is called 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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.