Firefox浏览器扩展未加载:Selenium with Python2.7

2024-09-28 13:15:49 发布

您现在位置:Python中文网/ 问答频道 /正文

使用firefox54、python2.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')

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

配置文件似乎没有正确加载。我找到了要去的指示“关于:支持,然后在配置文件文件夹标题下“打开文件夹”。目录在名称或路径(“C:\Users\Owner\AppData\Local\Temp\tmpp4lzxe”)中与配置文件不匹配

有人知道为什么没有加载配置文件吗?在

加载扩展的代码也是错误的吗?在


Tags: 代码mozilla配置文件seleniumcustomfirefoxprofileprofiles

热门问题