Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Chrome 118 #1605

Open
ggnetoo opened this issue Oct 12, 2023 · 6 comments
Open

Error Chrome 118 #1605

ggnetoo opened this issue Oct 12, 2023 · 6 comments

Comments

@ggnetoo
Copy link

ggnetoo commented Oct 12, 2023

Tried update Webdriver + Selenium too, but the error persists after update Chrome to version 118.

Patch Chrome: /root/.wdm/drivers/chromedriver/linux64/118.0.5993.70/chromedriver-linux64/chromedriver

driver = webdriver.Chrome(driver_executable_path=ChromeDriverManager().install(), options=chrome_options, enable_cdp_events=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/undetected_chromedriver/__init__.py", line 469, in __init__
    super(Chrome, self).__init__(
  File "/usr/local/lib/python3.11/dist-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/usr/local/lib/python3.11/dist-packages/selenium/webdriver/chromium/webdriver.py", line 56, in __init__
    super().__init__(
  File "/usr/local/lib/python3.11/dist-packages/selenium/webdriver/remote/webdriver.py", line 205, in __init__
    self.start_session(capabilities)
  File "/usr/local/lib/python3.11/dist-packages/undetected_chromedriver/__init__.py", line 727, in start_session
    super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
  File "/usr/local/lib/python3.11/dist-packages/selenium/webdriver/remote/webdriver.py", line 289, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/selenium/webdriver/remote/webdriver.py", line 344, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.11/dist-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:53893
from chrome not reachable
Stacktrace:
#0 0x559bca97ffb3 <unknown>
#1 0x559bca6532f6 <unknown>
#2 0x559bca63effa <unknown>
#3 0x559bca68aa3c <unknown>
#4 0x559bca6822a9 <unknown>
#5 0x559bca6c5ac6 <unknown>
#6 0x559bca6bc713 <unknown>
#7 0x559bca68f18b <unknown>
#8 0x559bca68ff7e <unknown>
#9 0x559bca9458d8 <unknown>
#10 0x559bca949800 <unknown>
#11 0x559bca953cfc <unknown>
#12 0x559bca94a418 <unknown>
#13 0x559bca91742f <unknown>
#14 0x559bca96e4e8 <unknown>
#15 0x559bca96e6b4 <unknown>
#16 0x559bca97f143 <unknown>
#17 0x7fb40aa94ac3 <unknown>
@yangex
Copy link

yangex commented Oct 13, 2023

It seems that version 118 is not yet supported, perhaps you need to go back to version 117

@gutsintheshell
Copy link

gutsintheshell commented Oct 14, 2023

Fixed on mac by switching to beta release on OSX.

Change browser binary path in candidates.update method call line 879 inside undected_chromedriver init.py file to "/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta".

Hope it work for you too 🤟

@faizanalhassan
Copy link

faizanalhassan commented Oct 28, 2023

I also had this issue. After debugging I found if there is chromedriver binary available in patcher.data_path location, it will always pick that even though you set driver_executable_path=ChromeDriverManager().install().

@pistachiomatt
Copy link

@faizanalhassan Can you explain your fix in more words?

@faizanalhassan
Copy link

faizanalhassan commented Oct 29, 2023

So, recently in a project I was using undetected-chromedriver and it was giving me an error that chromedriver.exe version is 114. I rechecked my chromedriver.exe was 118 and I was passing its path correctly through driver_executable_path parameter. So, I debugged the library code to review where the executable_path is updated.

During debugging, I noticed that these lines are causing the problem:

p = pathlib.Path(self.data_path)
if self.user_multi_procs:
with Lock():
files = list(p.rglob("*chromedriver*"))
most_recent = max(files, key=lambda f: f.stat().st_mtime)
files.remove(most_recent)
list(map(lambda f: f.unlink(), files))
if self.is_binary_patched(most_recent):
self.executable_path = str(most_recent)
return True

So, even user has given a custom chromedriver path, it will always first check patcher.data_path directory. And if found chromedriver binary it will set that as executable path (self.executable_path = str(most_recent)).

I removed all chromedriver binaries from that path and then my custom path was correctly used and no error was raised.

I think the solution is to move the below lines to the top of this method.

if self._custom_exe_path:
ispatched = self.is_binary_patched(self.executable_path)
if not ispatched:
return self.patch_exe()
else:
return

@faizanalhassan
Copy link

Created a PR #1638 to fix this. Please check if works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants