且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用特定配置文件Selenium Python geckodriver启动Firefox

更新时间:2022-03-12 22:42:11

我认为官方答案位于当前是:

# Custom profile folder to keep the minidump files
profile = tempfile.mkdtemp(".selenium")
print("*** Using profile: {}".format(profile))

# Use the above folder as custom profile
opts = Options()
opts.add_argument("-profile")
opts.add_argument(profile)
opts.binary = "/Applications/Firefox.app/Contents/MacOS/firefox"

driver = webdriver.Firefox(options=opts,
    # hard-code the Marionette port so geckodriver can connect
    service_args=["--marionette-port", "2828"])