Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: WebDriver.__init__() got an unexpected keyword argument 'firefox_options' error using firefox_options as arguments in Selenium Python

I'm trying to create a script which downloads a file from a website and for this I want to change the download filepath. When I try to do this with the Firefox options it gives me this error:

TypeError: WebDriver.__init__() got an unexpected keyword argument 'firefox_options'

Code:

from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.keys import Keys
import time

options = Options()

options.add_argument("download.default_directory=C:\\Music")
browser = webdriver.Firefox(firefox_options=options, executable_path=r'C:\\selenium\\geckodriver.exe')
browser.get('https://duckduckgo.com/')
like image 718
jonathangilbert Avatar asked Jan 28 '26 14:01

jonathangilbert


1 Answers

The browser option parameter firefox_options was deprecated in Selenium 3.8.0

  • Browser option parameters are now standardized across drivers as options. firefox_options, chrome_options, and ie_options are now deprecated

Instead you have to use options as follows:

from selenium.webdriver.firefox.options import Options

options = Options()
options.add_argument("download.default_directory=C:\\Music")
browser = webdriver.Firefox(options=options, executable_path=r'C:\\selenium\\geckodriver.exe')
like image 86
undetected Selenium Avatar answered Jan 30 '26 03:01

undetected Selenium



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!