Issue
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
Solution
- 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 seleniumv4.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.
Answered By - Shawn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.