我正在使用 selenium,并且想要为 3 个不同的脚本使用单独的 Firefox 配置文件。这可能吗?
不确定您如何执行脚本,但是当您实例化您的脚本时webdriver
对象,您可以指定一个FirefoxProfile
as the 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
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)