hcjohn463 / JableTVDownload

下載 jable好幫手
Apache License 2.0
665 stars 149 forks source link

How to fix "TypeError: WebDriver.__init__() got an unexpected keyword argument 'executable_path'" #136

Open kptung opened 6 months ago

kptung commented 6 months ago

after selenium 4.6.0,it removed the executable_path in its parameter configuration. 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() ////////////// or ////////////// from selenium import webdriver from selenium.webdriver.chrome.service import Service as ChromeService from webdriver_manager.chrome import ChromeDriverManager

options = webdriver.ChromeOptions() driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options) //////////////