How to use --screenshot in headless firefox in Selenium with python How to use --screenshot in headless firefox in Selenium with python selenium selenium

How to use --screenshot in headless firefox in Selenium with python


Nevermind, I found a way. there is a function driver.save_screenshot('test.png'). I kept the line from my question and commented it out.

from selenium import webdriverfrom selenium.webdriver.firefox.options import Optionsimport sysoptions = Options()options.add_argument( "--headless" )# options.add_argument( "--screenshot test.jpg http://google.com/" )driver = webdriver.Firefox( firefox_options=options )driver.get('http://google.com/')driver.save_screenshot('test.png')print driver.titleprint driver.current_urldriver.quit()sys.exit()