Skip to main content
 首页 » 编程设计

python之防止 Firefox 附加组件第一页显示

2024年10月24日12zhwl

我正在使用 Selenium Webdriver api 编写一个 Python 程序,该程序利用 Firefox 浏览器进行浏览,我需要添加的第一页显示它的版本被禁用,并且在浏览器开始工作时不显示。我的插件是 NoScript。

这是我的 Firefox 配置文件代码:

def fpp(): 
    ffprofile = webdriver.FirefoxProfile() 
    ffprofile.add_extension(extension='NS.xpi') 
    ffprofile.set_preference("extensions.noscript.currentVerison" , "2.6.9.35") 
    ffprofile.update_preferences() 
    return webdriver.Firefox(ffprofile) 
 
def driver(url1): 
   m = fpp() 
   m.get(url1) 

但是,此行不会阻止显示启动窗口:

ffprofile.set_preference("extensions.noscript.currentVerison" , "2.6.9.35") 

问题是什么,我该如何解决?

请您参考如下方法:

noscript 首选项以 noscript 开头(不需要 extensions.)。并且您需要设置 version 而不是 currentVersion。对我有用:

ffprofile.set_preference("noscript.version", "2.6.9.35")