Can';t使用Selenium关闭Javascript
我试图在使用Selenium打开时通过配置文件关闭javascript。这在以前是可行的,但是现在我更新了Selenium/Firfox,我无法让它工作Can';t使用Selenium关闭Javascript,javascript,python,firefox,selenium,Javascript,Python,Firefox,Selenium,我试图在使用Selenium打开时通过配置文件关闭javascript。这在以前是可行的,但是现在我更新了Selenium/Firfox,我无法让它工作 profile = webdriver.FirefoxProfile() profile.set_preference('javascript.enabled', False) driver = webdriver.Firefox(profile) driver.implicitly_wait(30) d
profile = webdriver.FirefoxProfile()
profile.set_preference('javascript.enabled', False)
driver = webdriver.Firefox(profile)
driver.implicitly_wait(30)
driver.get("http://www.enable-javascript.com/")
在使用其他选项上的profile.set_preference()时,所有其他设置似乎都会更改,javascript.enabled
存在,并且在查看Firefox关于:config的设置时设置为True。是否可能在加载配置文件或其他内容后将Javascript设置为True
FF版本43.0.3
Selenium版本2.48.0
有没有关于为什么会发生这种情况的建议
更新
添加
profile.add_扩展(“path/to/noscript_security_suite-2.9.xpi”)使用@alecxe建议的下载扩展名对上述代码进行编码>,修复了此问题。此问题影响selenium
从2.46.0开始,javascript。已启用的
将被忽略:
作为解决方法,加载noscript
加载项,请参阅:
如果您还没有弄明白,一个好的解决方法是创建一个已禁用javascript的概要文件。