Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

selenium has no attribute

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

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

When I try to run this code, I get an error like this:

AttributeError: 'str' object has no attribute 'capabilities' in  "driver = webdriver.Chrome(ChromeDriverManager().install())"

I was try open google with selenium but I cant open I cant fix it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to use Service Class in the latest selenium versions to pass the driver executable path or ChromeDriverManager setup. See code below.

Change your code as below:

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

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

driver.get("https://www.google.com")

driver.quit()

SUGGESTION: If you are using latest selenium version, there is a more easy way to handle browser drivers. You don’t need third party libraries like ChromeDriverManager. Selenium’s built-in tool Selenium Manager can do what ChromeDriverManager used to do.

Code can be as simple as:

from selenium import webdriver

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading