小编pri*_*701的帖子

无法在 python selenium 中加载 firefox 插件

我想在 selenium webdriver 运行时加载 Zenmate Firefox 插件,当我在没有加载任何插件(扩展)的情况下运行但在添加任何插件时遇到问题时它运行良好。这是我的代码:

def __init__(self):   

        self.main_catag_driver = []
        self.declare_xpaths()
        self.main_web_url = "Some_website_url"
        self.path_fire_fox_file = "~/.mozilla/firefox/7rl1aw4c.default/extensions/firefox@zenmate.com.xpi"
        self.driver = webdriver.Firefox()
        self.driver.add_extension(extension=self.path_fire_fox_file)
        time.sleep(5)
        self.driver.get(self.main_web_url)
Run Code Online (Sandbox Code Playgroud)

加载 Bar 时出错:

Traceback (most recent call last):
  File "scrap.py", line 73, in <module>
    obj = carandclassic()
  File "scrap.py", line 28, in __init__
    self.driver.add_extension(extension=self.path_fire_fox_file)
AttributeError: 'WebDriver' object has no attribute 'add_extension'
Run Code Online (Sandbox Code Playgroud)

python firefox selenium firefox-addon

4
推荐指数
1
解决办法
5172
查看次数

标签 统计

firefox ×1

firefox-addon ×1

python ×1

selenium ×1