Home > Blockchain >  TypeError: WebDriver.__init__() got an unexpected keyword argument 'firefox_options' error
TypeError: WebDriver.__init__() got an unexpected keyword argument 'firefox_options' error

Time:12-13

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/')

CodePudding user response:

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')
  • Related