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
Release: 2024-12-08 22:33:12
Original
627 people have browsed it

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)
Copy after login

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()
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template