0

I am using Jupyter Notebook My chrome version = 116.0.5845.141 (Official Build) (64-bit) my downloaded chromedrive = https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/win64/chromedriver-win64.zip

and i saved the chromedrive .exe in C:\Program File (x86), but when I tired the below codes, the codes are not working

!pipe install selenium
from selenium import webdriver
PATH = "C:\Program File (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("www.google.com")

Error = 'str' object has no attribute 'capabilities'

!pipe install selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

# Create a WebDriver instance
driver = webdriver.Chrome("./chromedriver")

# Open a website
driver.get("https://www.google.com")

Error = 'str' object has no attribute 'capabilities'

What can I do?

I expected that my targeted website will be opened by the chromedrive

pyt
  • 5
  • 1

1 Answers1

0
  • If you are using selenium v4.6.0 or above, your code can be as simple as below:
from selenium import webdriver

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

No need to worry about downloading and setting the chromedriver.exe path. Refer below link for more details:

https://stackoverflow.com/a/76463081/7598774

  • For some specific reason if you want to set the chromedriver.exe path, then starting selenium v4.10.0 this is how you need to set it:
from selenium.webdriver.chrome.service import Service
from selenium import webdriver

service = Service(executable_path='<full path/chromedriver.exe')
driver = webdriver.Chrome(service=service)
driver.get("https://www.google.com")

You need to pass the driver via Service Class as shown above.

Shawn
  • 4,064
  • 2
  • 11
  • 23