Search code examples
python-3.xseleniumselenium-webdriverfirefox

How to preserve the Firefox "Allow Windows single sign-on for Microsoft, work, and school accounts" with Python Selenium?


Is it possible to make sure that Allow Windows sigle sign-on for Microsoft, work, and school accounts is checked when using the browser driver for Firefox in Selenium?

Everytime I re-run Selenium I end up with it unchecked.

Mozilla Firefox settings, Logins and Passwords Allow Windows single sign-on for Microsoft work, and school accounts checked


Solution

  • Something like this should work:

    opts = FirefoxOptions()
    ...
    prof = webdriver.FirefoxProfile()
    prof.set_preference('network.http.windows-sso.enabled', True)
    ...
    executable_path = ...
    service = FirefoxService(executable_path=executable_path, firefox_profile=prof)
    driver = webdriver.Firefox(service=service, options=opts)