How to make Firefox headless programmatically in Selenium with Python?

后端 未结 6 1010
面向向阳花
面向向阳花 2020-11-22 11:37

I am running this code with python, selenium, and firefox but still get \'head\' version of firefox:

binary = FirefoxBinary(\'C:\\\\Program Files (x86)\\\\Mo         


        
6条回答
  •  生来不讨喜
    2020-11-22 12:07

    The first answer does't work anymore.

    This worked for me:

    from selenium.webdriver.firefox.options import Options as FirefoxOptions
    from selenium import webdriver
    
    options = FirefoxOptions()
    options.add_argument("--headless")
    driver = webdriver.Firefox(options=options)
    driver.get("http://google.com")
    

提交回复
热议问题