Message:Unable to obtain chromedriver using Selenium Manager
Asked Answered
T

3

4

I've tried writing this code on my jupyter notebook, and it shows me the error. My objective is to carry out web scrapping.

driver = webdriver.Chrome(ChromeDriverManager().install())

enter image description here

I've also installed selenium using pip and webdriver-manager using pip as well.

Treadwell answered 26/6, 2023 at 5:44 Comment(1)
could you please show more code?Fertility
I
6

The output of ChromeDriverManager().install() is an executable_path to the driver, but executable_path was removed in selenium 4.10.0. That's why you're seeing the error after passing the value into webdriver.Chrome(). Here are the changes: https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e

Changes_in_selenium_4_10_0

Note that executable_path was removed. If you want to pass in an executable_path, you'll have to use the service arg now. (service=Service(executable_path='./chromedriver')) But Selenium Manager is now fully included with selenium 4.10.0, so this is all you need:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service()
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
# ...
driver.quit()

If the driver isn't found on your system PATH, Selenium Manager will automatically download it for you.

Invertase answered 26/6, 2023 at 13:17 Comment(0)
V
2

Selenium Manager

Selenium Manager is the new tool that helps to get the required browser drivers to run Selenium out of the box. Beta 1 of Selenium Manager configures the browser drivers for Chrome, Firefox, and Edge if they are not present on the PATH. So To run a Selenium test with Selenium 4.6 and onwards you just need to have , or installed. If you already have browser drivers installed, this feature will be ignored completely.


Current Status

Selenium Manager tool is still in beta phase and Selenium is gradually adding support for this feature. The current implementation is a fall-back option, which means it should only get used if the code execution would otherwise fail. So long as you specify the location of the driver in the appropriate Service class (or using System Properties in Java), the Selenium Manager will not be used.


Solution

There are 2 different approaches as follows:

  • You can totally avoid webdriver-manager and your effective code block will be:

    driver = webdriver.Chrome()
    
  • To keep using the webdriver-manager you have to use the Service class and your effective code block will be:

    driver = webdriver.Chrome(service=ChromeDriverManager().install())
    
Vlissingen answered 26/6, 2023 at 9:12 Comment(0)
Y
1

Can you try by removing the ChromeDriverManager, you don't need it if your selenium version is v4.6.0 or above.

Change below:

driver = webdriver.Chrome(ChromeDriverManager().install())

To:

driver = webdriver.Chrome()

Introducing Selenium Manager

Yogh answered 26/6, 2023 at 8:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.