AttributeError: 'FirefoxProfile' object has no attribute 'update' error usingFirefoxProfile through Selenium and Python [closed]

牧云@^-^@ 提交于 2020-01-16 08:35:33

问题


Hello Guys I'm having problem on my code.

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()

Here Is The Error I'm Getting:

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

I cant figure out the problem i just want to save the profile settings to use.


回答1:


I Think You Need To Change This

profile.update_preference()

With This:

profile.update_preferences()



回答2:


update_preferences()

update_preferences() updates the default_preferences with the frozen preferences of the desired FirefoxProfile which is defined as:

def update_preferences(self):
    for key, value in FirefoxProfile.DEFAULT_PREFERENCES['frozen'].items():
        self.default_preferences[key] = value
    self._write_user_prefs(self.default_preferences)

However, you were close. You need to replace update_preference() with update_preferences() i.e. effectively in your code you need to replace:

profile.update_preference()

with

profile.update_preferences()

References

You can find a relevant discussions in:

  • How to connect to Tor browser using Python


来源:https://stackoverflow.com/questions/59087324/attributeerror-firefoxprofile-object-has-no-attribute-update-error-usingfir

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!