Firefox浏览器扩展未加载:Selenium with Python 2.7

时间:2018-03-18 09:59:31

标签: python selenium firefox

使用Firefox 54,Python 2.7和Selenium 3.8.1我尝试使用Firefox配置文件加载某些扩展,但Selenium无法加载它们。但是,浏览器会加载此代码:

from selenium import webdriver

def setup_firefox_profile():

    firefox_custom_profile = webdriver.FirefoxProfile(
    r'C:\Users\Owner\AppData\Roaming\Mozilla\Firefox\Profiles\1hmz9w1k.GenericFootprintHardened2')

    firefox_custom_profile.add_extension(r'C:\Users\Owner\AppData\Roaming\Mozilla\Firefox\Profiles\1hmz9w1k.GenericFootprintHardened2\extensions\bestproxyswitcher@bestproxyswitcher.com.xpi')
    # C:\Users\Owner\AppData\Roaming\Mozilla\Firefox\Profiles\<profile folder>

    # Adblock, Best Proxy Switcher, //BetterPrivacy, Clear Flash Cookies, Canvas Fingerprint Blocker, Cookie Quick Manager, Disable WebRTC, Ghostery, Privacy Badger,

    firefox_custom_profile.set_preference("extensions.bestproxyswitcher.currentVersion", "5.4.2")
    firefox_settings = webdriver.Firefox(firefox_profile=firefox_custom_profile)
    return firefox_settings

driver = setup_firefox_profile()

driver.get('http://duckduckgo.com')

尝试使用手动会话加载配置文件我可以看到扩展加载。

看起来配置文件无法正确加载。我找到了关于&#34; about:support&#34;然后&#34;打开文件夹&#34;在“配置文件夹”标题下。该目录与名称或路径中的配置文件不匹配(&#34; C:\ Users \ Owner \ AppData \ Local \ Temp \ tmpp4lzxe&#34;)

有人可以看到为什么没有加载个人资料吗?

加载扩展程序的代码是否也错了?

0 个答案:

没有答案