selenium代码中加载firefox的默认配置文件
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
profile_path = r'C:\Users\Administrator\AppData\Roaming\Mozilla\Firefox\Profiles\y1uqp5mi.default'
default_profile = FirefoxProfile(profile_path)
driver = webdriver.Firefox(service=service, options=options, firefox_profile=default_profile)
但是,运行代码会出现了一个弃用警告:firefox_profile has been deprecated, please pass in an Options object
解决办法:
options=Options()
options.add_argument("-profile")
options.add_argument("/path/to/profile")
或者文章来源:https://www.toymoban.com/news/detail-542626.html
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
profile_path = r'C:\Users\Administrator\AppData\Roaming\Mozilla\Firefox\Profiles\y1uqp5mi.default'
options=Options()
options.set_preference('profile', profile_path)
第二种可能失效。文章来源地址https://www.toymoban.com/news/detail-542626.html
到了这里,关于firefox_profile has been deprecated, please use an Options object的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!