I just started using selenium with Python and I keep getting the following error code:
TypeError: WebDriver.__init__() got an unexpected keyword argument 'executable_path'
Here's the code for the context:
from selenium.webdriver import Firefox
from selenium.webdriver.common.keys import Keys
url = 'https://example'
driver_path = r"D:\path\to\geckodriver.exe"
browser = Firefox(executable_path=driver_path)
browser.get(url)
Thanks in advance!
I checked the path, the version of the selenium package and made sure that I have the right geckodriver.exe but still get the error.
As mentioned in my earlier solution, https://stackoverflow.com/a/76550727/7058266, this is due to changes in selenium 4.10.0:
https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e

Note that executable_path was removed.
If you want to pass in an executable_path, you'll have to use the service arg now.
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
service = Service(executable_path="PATH_TO_GECKODRIVER")
options = webdriver.FirefoxOptions()
driver = webdriver.Firefox(service=service, options=options)
# ...
driver.quit()
But you no longer need to specify an executable_path due to a fully operational Selenium Manager in 4.10.0, so this is all you need:
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
service = Service()
options = webdriver.FirefoxOptions()
driver = webdriver.Firefox(service=service, options=options)
# ...
driver.quit()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With