ChromeDriver Path Unavailable Error Resolved Using WebDriverManager
Many users encounter the error message " WebDriverException: Message: 'chromedriver' executable needs to be available in the path" when using Selenium with Python. Despite setting the executable path in the Environment Variable "Path," the issue persists.
The traditional method of resolving this error involved manual download and path configuration of the ChromeDriver binary. However, a simpler solution is available through WebDriverManager.
Installing WebDriverManager
Run the following command to install WebDriverManager:
pip install webdriver-manager
Using WebDriverManager with Selenium
With WebDriverManager installed, you can modify the Selenium code as follows:
from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(ChromeDriverManager().install())
WebDriverManager automatically downloads and sets the appropriate ChromeDriver binary for your operating system, eliminating the need for manual management. This approach also extends to other web drivers such as Firefox, Edge, and IE.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3