I'm using Selenium's webdriver and GeckoDriverManager to open a website and take a screenshot in Firefox. That part works fine. I wanted to specify where to save this screenshot using selenium.webdriver.set_preference() to specify the download path and saving this under an options variable. If I use firefox_driver=webdriver.Firefox(service=service, options=options) the website no longer launches. This is the code I used to set the option preferences: https://stackoverflow.com/a/69974916
Does anyone have an idea where the problem might be coming from?
def load_driver():
service=Service(GeckoDriverManager().install())
options = Options()
options.set_preference("browser.helperApps.alwaysAsk.force", False)
options.set_preference("browser.download.manager.showWhenStarting", False)
options.set_preference("browser.helperApps.neverAsk.openFile", "image/png")
options.set_preference("browser.helperApps.neverAsk.saveToDisk", "image/png")
options.set_preference("browser.download.folderList", 1)
firefox_driver = webdriver.Firefox(service=service) #stops working if I add options=options parameter here
def getscreenshot():
driver = load_driver()
driver.get(website)
sleep(3)
driver.get_screenshot_as_file("screenshot.png")
driver.quit()
print("end...")