gpt4 book ai didi

javascript - Selenium Firefox 与 Python3 FirefoxProfile.set_preference() 被忽略

转载 作者:行者123 更新时间:2023-11-27 23:04:52 25 4
gpt4 key购买 nike

我试图通过 Python 3.4 在 selenium 2.53.1 驱动的 Firefox 45.0.1 上设置不同的首选项值。例如。禁用 JavaScript:

>>> from selenium import webdriver
>>> profile = webdriver.FirefoxProfile()
>>> profile.set_preference('javascript.enabled', False)
>>> driver = webdriver.Firefox(firefox_profile=profile)

但是,这被忽略,about:config 显示

javascript.enabled  true

并且JavaScript代码正常执行。虽然 about:config 确实显示它是用户设置的。缺少什么?

最佳答案

你不能

It can no longer be done globally from the User Interface. There are still a few other alternatives. Depending what you need to block it may be worth considering a script blocker something such as

https://support.mozilla.org/en-US/questions/994809

关于javascript - Selenium Firefox 与 Python3 FirefoxProfile.set_preference() 被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36691749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com