0

I'm getting this error when I try to run Selenium:

AttributeError: 'str' object has no attribute 'capabilities'

My code:

from selenium import webdriver

browser = webdriver.Chrome("chromedriver.exe")

browser.get("https://www.youtube.com/")

I tried to put webdriver in many different locations on my desktop but it is not working:

C:\Program Files (x86)\chromedriver.exe

or

./chromedriver.exe

Any idea? I've installed latest version.

Maxwell
  • 138
  • 1
  • 9

1 Answers1

1
browser = webdriver.Chrome("chromedriver.exe")

Above line of code in incorrect. You have to pass the absolute path(full location path) of the chromedriver.exe. Else, if you are using latest version of selenium, check the solution below.

Assuming you are using latest version of selenium (v4.11.2), code can be simplified as below:

from selenium import webdriver

browser = webdriver.Chrome()
browser.get("https://www.youtube.com/")

Refer this answer for more info: https://stackoverflow.com/a/76463081/7598774

Shawn
  • 4,064
  • 2
  • 11
  • 23