Home >Backend Development >Python Tutorial >Selenium WebDriver Error: Why Can't I Obtain a Driver with Selenium Manager?

Selenium WebDriver Error: Why Can't I Obtain a Driver with Selenium Manager?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-08 22:33:12570browse

Selenium WebDriver Error: Why Can't I Obtain a Driver with Selenium Manager?

Selenium Webdriver Error: Unable to Obtain Driver

When attempting to utilize Selenium Webdriver, a common error encountered is the inability to obtain a driver due to two exceptions:

  1. AttributeError: 'str' object has no attribute 'capabilities'
  2. NoSuchDriverException: Unable to obtain driver using Selenium Manager

Code Snippet:

from selenium import webdriver

chrome_driver_path = <chrome drive .exe path>
driver = webdriver.Chrome(chrome_driver_path)

Cause:

This error typically occurs when using Selenium version 4.6.0 or higher, where Selenium Manager attempts to retrieve the driver. However, in the given code, the driver path is explicitly set, which clashes with Selenium Manager.

Solution:

If Selenium version 4.6.0 or greater is being used, it is no longer necessary to set the driver path manually. Selenium Manager will handle the browser and drivers automatically.

Simplified Code:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://www.google.com/")
driver.quit()

References:

  • Purpose of webdriver manager
  • Introducing Selenium Manager

The above is the detailed content of Selenium WebDriver Error: Why Can't I Obtain a Driver with Selenium Manager?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn