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

Опубликовано: 28 Сентябрь 2024
на канале: Chhaileng Tim
7,065
34

I apologize for the confusion. The error you're encountering indicates that the `executable_path` argument is not recognized, which is unusual for the Chrome WebDriver. It seems you might be using an incompatible WebDriver or an older version of Selenium.

To resolve this issue, make sure you are using the correct WebDriver executable for Brave and the latest version of Selenium. Here's an updated example:

```python
from selenium import webdriver

Set the path to the Brave WebDriver executable
brave_driver_path = 'path/to/your/brave/driver'

Create a Brave browser instance
options = webdriver.ChromeOptions()
options.binary_location = 'path/to/brave/browser' # Path to Brave executable
options.add_argument('--start-maximized') # Maximize the browser window

Initialize the browser with the Brave WebDriver
browser = webdriver.Chrome(executable_path=brave_driver_path, options=options)

Open YouTube
youtube_url = 'https://www.youtube.com'
browser.get(youtube_url)

Close the browser
browser.quit()
```

Ensure that you download the correct WebDriver for your Brave browser version from the official Brave website. Also, make sure you have the latest version of Selenium installed using `pip install selenium`.

If you continue to encounter issues, please verify your WebDriver and Selenium versions and ensure they are compatible with each other and your Brave browser.