如何设置Selenium以使用多个Firefox配置文件?

如何设置Selenium以使用多个Firefox配置文件?,第1张

如何设置Selenium以使用多个Firefox配置文件?

不确定如何执行脚本,但是在实例

webdriver
对象时,可以指定a
FirefoxProfile
作为
firefox_profile
参数。这是通过创建一个
FirefoxProfile
对象(下面的示例)并提供目标配置文件的路径作为参数来完成的:

from selenium import webdriver# ...profile = webdriver.firefox.firefox_profile.FirefoxProfile('/path/to/your/profile')driver = webdriver.Firefox(firefox_profile=profile)

据我所知,您无法

driver
在实例化实例后修改配置文件(尽管我可能是错的-
如果您需要这样做,值得尝试:))。在这种情况下,您将在每个脚本中创建一个配置文件,该配置文件指向要使用的配置文件,然后使用指向由创建的对象
driver
firefox_profile
参数实例化。
profile``FirefoxProfile



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5086515.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-16

发表评论

登录后才能评论

评论列表(0条)

保存