Setting selenium to use custom profile, but it keeps opening with default

后端 未结 3 1986
悲哀的现实
悲哀的现实 2020-12-01 06:20

I am trying to use python and selenium to automate some tasks in firefox. When I download a file, that pop up comes up asking if you want to open or save, and a check box fo

3条回答
  •  温柔的废话
    2020-12-01 07:01

    I did the following:

    Open Profile Directory

    Or:

    Linux: ls -d /home/$USER/.mozilla/firefox/*.default/ to see user profile directories

    Mac: ls -d ~/Library/Application\ Support/Firefox/Profiles/*

    Output:

    /home/jmunsch/.mozilla/firefox/xfoyzfsb.default/
    /home/jmunsch/.mozilla/firefox/yxjwk1py.default/
    

    To load a custom user profile I ran through creating a profile in firefox and then did the following with the python selenium webdriver code:

    def setUp(self):
        self.profile = webdriver.FirefoxProfile('/home/jmunsch/.mozilla/firefox/yxjwk1py.default')
        self.driver = webdriver.Firefox(self.profile)
    

    System Info:

    Python 2.7.3 (default, Sep 26 2013, 20:08:41) 
    [GCC 4.6.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import pkg_resources;pkg_resources.get_distribution("selenium").version
    
    jmunsch@NE-522:~/Desktop/work$ firefox --version
    Mozilla Firefox 26.0
    

    also note

    @Corey's answer to manually set a profile

    All of the configurables can be found under about:config:

    profile.set_preference('browser.download.folderList', 2)

提交回复
热议问题