SeanSparx
SeanSparx

Reputation: 21

Undetected chromedriver not working with selenium 4.10

Just upgraded to selenium 4.10 and got: TypeError: init() got an unexpected keyword argument 'executable_path'

I read that executable path not needed in latest version and the fix is:

from selenium.webdriver.chrome.service import Service
service = Service("C:\\Users\\user1\\documents\\selenium\\chromedriver.exe")
self.driver = webdriver.Chrome(service=service)

This works fine but when I try the same using undetected chromedriver I get the original error

from selenium.webdriver.chrome.service import Service
service = Service("C:\\Users\\user1\\documents\\selenium\\chromedriver.exe")
self.driver = uc.Chrome(service=service, use_subprocess=True)

File "C:\python38\lib\site-packages\undetected_chromedriver\__init__.py", line 453, in __init__
super(Chrome, self).__init__(
TypeError: __init__() got an unexpected keyword argument 'executable_path'`

Upvotes: 2

Views: 4009

Answers (3)

riad devid
riad devid

Reputation: 1

In Selenium 4.10, Here's an example of how to use it:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
driver_path = 'C:\\Driver\\chromedriver.exe'
options = webdriver.ChromeOptions()
service = ChromeService(executable_path=driver_path)
driver = webdriver.Chrome(service=service, options=options)

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

Upvotes: 0

hammad rauf
hammad rauf

Reputation: 91

from selenium.webdriver.chrome.service import Service as ChromeService
    
path = os.path.join(os.path.abspath(os.getcwd()),'chromedriver.exe')
service = ChromeService(executable_path=path)
    
driver = webdriver.Chrome(options=options,service=service)

ChromeService will have executable_path now. service will be passed in Chrome object.

Upvotes: 0

Siarhei Lebedzeu
Siarhei Lebedzeu

Reputation: 21

i have the same issue for python. Looks like there is an issue with selnium 4.10. please use selenium 4.9.

Upvotes: 2

Related Questions