首页 > 解决方案 > AttributeError: 'FirefoxProfile' 对象没有属性 'update' 错误使用 FirefoxProfile 通过 Selenium 和 Python

问题描述

大家好,我的代码有问题。

from selenium import webdriver
import time

profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy_type',1)
profile.set_preference('network.proxy.http',"91.xx.xxx.xx")
profile.set_preference('network.proxy.http_port',xxxx)
# profile.update_preference()  ---> this code letter giving the error.
driver = webdriver.Firefox(firefox_profile=profile)
driver.get('http://whatismyipaddress.com')
time.sleep(3)
driver.close()

这是我得到的错误:

AttributeError: 'FirefoxProfile' object has no attribute 'update'

我无法弄清楚我只想保存配置文件设置以供使用的问题。

标签: pythonseleniumselenium-webdriverfirefoxfirefox-profile

解决方案


我认为你需要改变这个

profile.update_preference()

有了这个:

profile.update_preferences()

推荐阅读