ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.53k stars 1.13k forks source link

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:65490 from session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 116.0.5845.97 #1477

Closed mominurr closed 1 year ago

mominurr commented 1 year ago

Traceback (most recent call last): File "D:\Testing_all_project\test.py", line 27, in driver = uc.Chrome(options=options) File "D:\Testing_all_project\env\lib\site-packages\undetected_chromedriver__init.py", line 466, in init super(Chrome, self).init( File "D:\Testing_all_project\env\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 49, in init super().init( File "D:\Testing_all_project\env\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 54, in init
super().
init( File "D:\Testing_all_project\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in init self.start_session(capabilities) File "D:\Testing_all_project\env\lib\site-packages\undetected_chromedriver\init__.py", line 724, in start_session
super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session( File "D:\Testing_all_project\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 291, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"] File "D:\Testing_all_project\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 346, in execute self.error_handler.check_response(response) File "D:\Testing_all_project\env\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, 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:65490 from session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 116.0.5845.97 Stacktrace: Backtrace: GetHandleVerifier [0x00E0A813+48355] (No symbol) [0x00D9C4B1] (No symbol) [0x00CA5358] (No symbol) [0x00CC61AC] (No symbol) [0x00CC06B4] (No symbol) [0x00CC0491] (No symbol) [0x00CF0C55] (No symbol) [0x00CF093C] (No symbol) [0x00CEA536] (No symbol) [0x00CC82DC] (No symbol) [0x00CC93DD] GetHandleVerifier [0x0106AABD+2539405] GetHandleVerifier [0x010AA78F+2800735] GetHandleVerifier [0x010A456C+2775612] GetHandleVerifier [0x00E951E0+616112] (No symbol) [0x00DA5F8C] (No symbol) [0x00DA2328] (No symbol) [0x00DA240B] (No symbol) [0x00D94FF7] BaseThreadInitThunk [0x762600C9+25] RtlGetAppContainerNamedObjectPath [0x77B07B1E+286] RtlGetAppContainerNamedObjectPath [0x77B07AEE+238]

binstc commented 1 year ago

driver = uc.Chrome(driver_executable_path='/usr/local/bin/chromedriver')

Matt10233 commented 1 year ago

Same

mominurr commented 1 year ago

driver = uc.Chrome(driver_executable_path='/usr/local/bin/chromedriver')

chrome open and automatic close. Not working. I am use this code: chromedriver_path = r"D:\Testing_all_project\chromedriver.exe" driver = uc.Chrome(driver_executable_path=chromedriver_path,options=options)

362227 commented 1 year ago

driver = uc.Chrome(driver_executable_path='/usr/local/bin/chromedriver')

chrome open and automatic close. Not working. I am use this code: chromedriver_path = r"D:\Testing_all_project\chromedriver.exe" driver = uc.Chrome(driver_executable_path=chromedriver_path,options=options)

The Same, Not working

jdholtz commented 1 year ago

Would you be able to try the attached PR to see if the fix is working for you?

mominurr commented 1 year ago

Would you be able to try the attached PR to see if the fix is working for you?

what is PR? Please describe?

h656 commented 1 year ago

I am facing the same issue.

jdholtz commented 1 year ago

what is PR? Please describe?

@mominurr #1478, the one right above my comment (unfortunately, it didn't attach to the issue)

h656 commented 1 year ago

How do we use it @jdholtz If I am using 116, then it crashes with 404 not found

h656 commented 1 year ago
    chrome_options1 = ChromeOptions()
    chrome_options1.add_argument("--incognito")
    chrome_options1.add_argument('--disable-popup-blocking')
    chrome_options1.add_argument("--force-device-scale-factor=0.8")
    driver = Chrome(options=chrome_options1, version_main=116)
h656 commented 1 year ago

This is what when i use.

jdholtz commented 1 year ago

@h656 what happens if you don’t specify the version_main? Also, are you sure you are using my changes on the correct branch?

To use my PR, you’ll need to clone my fork and checkout to 115-compatibility. Then, you can import it through the Python terminal or run setup.py to install it (I haven’t used this approach but it should allow you to use my fork instead)

h656 commented 1 year ago

@h656 what happens if you don’t specify the version_main? Also, are you sure you are using my changes on the correct branch?

from session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 116.0.5845.97

h656 commented 1 year ago

This is the error that I face. No, I am actually using the pip undetected chromedriver

stevenbaum18 commented 1 year ago

I'm getting this error using the patcher.py from your PR KeyError: "There is no item named 'chromedriver-win32\\chromedriver.exe' in the archive"

Matt10233 commented 1 year ago

I'm getting this error using the patcher.py from your PR

KeyError: "There is no item named 'chromedriver-win32\\chromedriver.exe' in the archive"

Yeah same

jdholtz commented 1 year ago

@stevenbaum18 thanks for testing. I haven’t tested on Windows yet, so I’ll fix that in a few hours

h656 commented 1 year ago

Easiest Hack or Wordaround That I have right now is Install pip install webdriver_manager

Use from webdriver_manager.chrome import ChromeDriverManager

latestchromedriver = ChromeDriverManager().install()

set options

driver = Chrome(driver_executable_path=latestchromedriver, options=chrome_options1)

h656 commented 1 year ago

This works perfectly.

mominurr commented 1 year ago

Easiest Hack or Wordaround That I have right now is Install pip install webdriver_manager

Use from webdriver_manager.chrome import ChromeDriverManager

latestchromedriver = ChromeDriverManager().install()

set options driver = Chrome(driver_executable_path=latestchromedriver, options=chrome_options1)

I am trying this code but not working.

h656 commented 1 year ago

Easiest Hack or Wordaround That I have right now is Install pip install webdriver_manager Use from webdriver_manager.chrome import ChromeDriverManager latestchromedriver = ChromeDriverManager().install()

set options driver = Chrome(driver_executable_path=latestchromedriver, options=chrome_options1)

I am trying this code but not working.

Whats the error?

stevenbaum18 commented 1 year ago

Easiest Hack or Wordaround That I have right now is Install pip install webdriver_manager

Use from webdriver_manager.chrome import ChromeDriverManager

latestchromedriver = ChromeDriverManager().install()

set options driver = Chrome(driver_executable_path=latestchromedriver, options=chrome_options1)

I got your code working with the following code added

from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager import urllib.request

try: service = Service(ChromeDriverManager().install()) except ValueError: latest_chromedriver_version_url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE" latest_chromedriver_version = urllib.request.urlopen(latest_chromedriver_version_url).read().decode('utf-8') service = Service(ChromeDriverManager(version=latest_chromedriver_version).install()) driver_executable_path = service.path

mominurr commented 1 year ago

Easiest Hack or Wordaround That I have right now is Install pip install webdriver_manager Use from webdriver_manager.chrome import ChromeDriverManager latestchromedriver = ChromeDriverManager().install()

set options driver = Chrome(driver_executable_path=latestchromedriver, options=chrome_options1)

I am trying this code but not working.

Whats the error?

driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)

Traceback (most recent call last): File "D:\Testing_all_project\test.py", line 50, in driver = selenium_chromedriver() File "D:\Testing_all_project\test.py", line 44, in selenium_chromedriver
driver = webdriver.Chrome(ChromeDriverManager().install(), options=options) TypeError: WebDriver.init() got multiple values for argument 'options'

stevenbaum18 commented 1 year ago

try this with my code above driver = webdriver.Chrome(options=chrome_options, driver_executable_path=driver_executable_path)

mominurr commented 1 year ago

try this with my code above driver = webdriver.Chrome(options=chrome_options, driver_executable_path=driver_executable_path)

can you please provide full code?

stevenbaum18 commented 1 year ago
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import urllib.request

try:
        service = Service(ChromeDriverManager().install())
except ValueError:
        latest_chromedriver_version_url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE"
        latest_chromedriver_version = urllib.request.urlopen(latest_chromedriver_version_url).read().decode('utf-8')
        service = Service(ChromeDriverManager(version=latest_chromedriver_version).install())
driver = webdriver.Chrome(options=chrome_options, driver_executable_path=driver_executable_path)
driver_executable_path = service.path
mominurr commented 1 year ago
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import urllib.request

try:
        service = Service(ChromeDriverManager().install())
except ValueError:
        latest_chromedriver_version_url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE"
        latest_chromedriver_version = urllib.request.urlopen(latest_chromedriver_version_url).read().decode('utf-8')
        service = Service(ChromeDriverManager(version=latest_chromedriver_version).install())
driver = webdriver.Chrome(options=chrome_options, driver_executable_path=driver_executable_path)
driver_executable_path = service.path

try: service = Service(ChromeDriverManager().install()) except ValueError: latest_chromedriver_version_url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE" latest_chromedriver_version = urllib.request.urlopen(latest_chromedriver_version_url).read().decode('utf-8') service = Service(ChromeDriverManager(version=latest_chromedriver_version).install())

Configure Chrome options

options = webdriver.ChromeOptions() options.add_argument("--enable-automation") options.add_argument("--enable-logging") options.add_argument('--incognito') driver_executable_path = service.path driver = webdriver.Chrome(options=options, driver_executable_path=driver_executable_path)

Traceback (most recent call last): File "D:\Testing_all_project\test.py", line 69, in driver = webdriver.Chrome(options=options, driver_executable_path=driver_executable_path) TypeError: WebDriver.init() got an unexpected keyword argument 'driver_executable_path'

h656 commented 1 year ago

Bro, in the driver executable path =

ChromeDriverManager().install()

Put this. It should work.

Also put options after this.

On Wed, 16 Aug 2023 at 8:51 PM, Mominur Rahman @.***> wrote:

from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager import urllib.request

try: service = Service(ChromeDriverManager().install()) except ValueError: latest_chromedriver_version_url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE" latest_chromedriver_version = urllib.request.urlopen(latest_chromedriver_version_url).read().decode('utf-8') service = Service(ChromeDriverManager(version=latest_chromedriver_version).install()) driver = webdriver.Chrome(options=chrome_options, driver_executable_path=driver_executable_path) driver_executable_path = service.path

try: service = Service(ChromeDriverManager().install()) except ValueError: latest_chromedriver_version_url = " https://chromedriver.storage.googleapis.com/LATEST_RELEASE" latest_chromedriver_version = urllib.request.urlopen(latest_chromedriver_version_url).read().decode('utf-8') service = Service(ChromeDriverManager(version=latest_chromedriver_version).install()) Configure Chrome options

options = webdriver.ChromeOptions() options.add_argument("--enable-automation") options.add_argument("--enable-logging") options.add_argument('--incognito') driver_executable_path = service.path driver = webdriver.Chrome(options=options, driver_executable_path=driver_executable_path)

Traceback (most recent call last): File "D:\Testing_all_project\test.py", line 69, in driver = webdriver.Chrome(options=options, driver_executable_path=driver_executable_path) TypeError: WebDriver.init() got an unexpected keyword argument 'driver_executable_path'

— Reply to this email directly, view it on GitHub https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1477#issuecomment-1680817388, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFX53E5DFZTXFESZEIJH4DXVTQPJANCNFSM6AAAAAA3SNLDEU . You are receiving this because you were mentioned.Message ID: @.*** com>

mdmintz commented 1 year ago

Until the fix is available here, you can use SeleniumBase's UC Mode as an alternative, which has a slightly modified version of undetected-chromedriver.

First pip install seleniumbase, and then run the following script with python:

from seleniumbase import Driver
import time

driver = Driver(uc=True)
driver.get("https://nowsecure.nl/#relax")
time.sleep(6)
driver.quit()

SeleniumBase also has other formats with its own API:

from seleniumbase import SB

with SB(uc=True) as sb:
    sb.open("https://nowsecure.nl/#relax")
    sb.sleep(3)
    if not sb.is_text_visible("OH YEAH, you passed!", "h1"):
        sb.get_new_driver(undetectable=True)
        sb.open("https://nowsecure.nl/#relax")
        sb.sleep(3)
    sb.assert_text("OH YEAH, you passed!", "h1", timeout=3)

One of the main reasons I get fixes out earlier in SeleniumBase (my repo), is because I'm also a maintainer of Selenium, (https://github.com/SeleniumHQ/selenium/pulls?q=is%3Apr+author%3Amdmintz+is%3Aclosed+), and so I hear about breaking changes before most maintainers of projects that use Selenium do. The issue from this ticket was actually initiated by the Chromium Team when they restructured driver downloads for the new Chrome-for-Testing, (see https://googlechromelabs.github.io/chrome-for-testing/).

jdholtz commented 1 year ago

@stevenbaum18 and @Matt10233, I published a fix for Windows (and tested it myself) so it should work now.

h656 commented 1 year ago

We can use it directly from pip install undetected chrome driver?

On Wed, 16 Aug 2023 at 9:38 PM, Joey Holtzman @.***> wrote:

@stevenbaum18 https://github.com/stevenbaum18 and @Matt10233 https://github.com/Matt10233, I published a fix for Windows (and tested it myself) so it should work now.

— Reply to this email directly, view it on GitHub https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1477#issuecomment-1680892412, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFX53CAOSFILWWPO6TJLVDXVTV75ANCNFSM6AAAAAA3SNLDEU . You are receiving this because you were mentioned.Message ID: @.*** com>

hkrcs96 commented 1 year ago

undetected chrome driver is having problems, does ChromeDriverManager().install() work on undetected chrome driver?

jdholtz commented 1 year ago

@mdmintz, that looks like a great project! I’ll definitely be checking that out

h656 commented 1 year ago

Yes it is.

On Wed, 16 Aug 2023 at 9:58 PM, hkrcs96 @.***> wrote:

undetected chrome driver is having problems, does ChromeDriverManager().install() work on undetected chrome driver?

— Reply to this email directly, view it on GitHub https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1477#issuecomment-1680919598, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFX53AFJ7KW4ZOOX7VAZZDXVTYI7ANCNFSM6AAAAAA3SNLDEU . You are receiving this because you were mentioned.Message ID: @.*** com>

Arikelly commented 1 year ago

@jdholtz We can use it directly from pip install undetected-chromedriver?

jdholtz commented 1 year ago

@Arikelly, since it is a fork, you can install it with the following command:

pip install -e git+https://github.com/jdholtz/undetected-chromedriver.git@f91b7d86bc257d4cb9bfc848266e82509868e2c6#egg=undetected_chromedriver
vyanezz commented 1 year ago

@jdholtz Thank you, its working but Cloudfare is detecting since yesterday… any help?

jdholtz commented 1 year ago

@jdholtz Thank you, its working but Cloudfare is detecting since yesterday… any help?

Without my fork, does it get detected when you use Chrome 114 or below? If so, I'm not sure how to help with that as I don't have enough knowledge about anti-bot algorithms. You can check SeleniumBase though, which appears to stay undetected (see this comment by the maintainer)

h656 commented 1 year ago

Its working seamless and undetected. On Wed, 16 Aug 2023 at 11:05 PM, Joey Holtzman @.***> wrote:

@jdholtz https://github.com/jdholtz Thank you, its working but Cloudfare is detecting since yesterday… any help?

Without my fork, does it get detected when you use Chrome 114 or below? If so, I'm not sure how to help with that as I don't have enough knowledge about anti-bot algorithms. You can check SeleniumBase though, which appears to stay undetected (see this comment https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1477#issuecomment-1680867979 by the maintainer)

— Reply to this email directly, view it on GitHub https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1477#issuecomment-1681019710, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFX53HGD5IFYEC7NXPC6X3XVUAHLANCNFSM6AAAAAA3SNLDEU . You are receiving this because you were mentioned.Message ID: @.*** com>

Matt10233 commented 1 year ago

@stevenbaum18 and @Matt10233, I published a fix for Windows (and tested it myself) so it should work now.

It's working for me thanks :)

jdholtz commented 1 year ago

Its working seamless and undetected.

Is this with or without my changes? Or both?

h656 commented 1 year ago

Haven’t tried your changes. Just did my own workaround.

On Wed, 16 Aug 2023 at 11:55 PM, Joey Holtzman @.***> wrote:

Its working seamless and undetected.

Is this with or without my changes? Or both?

— Reply to this email directly, view it on GitHub https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1477#issuecomment-1681083890, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFX53ELG4AN3WINB5HE64TXVUGBFANCNFSM6AAAAAA3SNLDEU . You are receiving this because you were mentioned.Message ID: @.*** com>

seowlizhi commented 1 year ago

Easiest Hack or Wordaround That I have right now is Install pip install webdriver_manager

Use from webdriver_manager.chrome import ChromeDriverManager

latestchromedriver = ChromeDriverManager().install()

set options driver = Chrome(driver_executable_path=latestchromedriver, options=chrome_options1)

Does that mean you need to install everytime u run the script? or is this jupyter?

MarvinMitterlehner commented 1 year ago

Glad i found this issue. Been trying a couple things, but this worked for me:

from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import urllib.request
import undetected_chromedriver as uc

try:
    service = Service(ChromeDriverManager().install())
except ValueError:
    latest_chromedriver_version_url = "https://chromedriver.storage.googleapis.com/LATEST_RELEASE"
    latest_chromedriver_version = urllib.request.urlopen(latest_chromedriver_version_url).read().decode('utf-8')
    service = Service(ChromeDriverManager(version=latest_chromedriver_version).install())
driver_executable_path = service.path

options = uc.ChromeOptions()

And then start it:

chrome = uc.Chrome(driver_executable_path=driver_executable_path, options=options)

Thanks @stevenbaum18

Oussama-Maati commented 1 year ago

@MarvinMitterlehner i still get the issue with the code you provided from session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 116.0.5845.96

davidal381 commented 1 year ago

I'm still getting the issue with windows, java and webDriverManager with error of: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 116.0.5845.97 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe The code is: ChromeOptions options = new ChromeOptions(); options.addArguments("--headless"); options.addArguments("window-size=1920x1080"); options.addArguments( "--no-sandbox"); options.addArguments("--remote-allow-origins=*"); ThreadLocal driverThreadLocal = new ThreadLocal<>(); // for using parallel tests WebDriverManager.chromedriver().setup(); driverThreadLocal.set(new ChromeDriver(options)); Any workaround? Thanks

h656 commented 1 year ago

Download the latest chromedriver and use that in the path,that should work.

On Thu, 17 Aug 2023 at 15:16, davidal381 @.***> wrote:

I'm still getting the issue with java and webdrivermanager with error of: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: This version of ChromeDriver only supports Chrome version 114 Current browser version is 116.0.5845.97 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe Any workaround? Thanks

— Reply to this email directly, view it on GitHub https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1477#issuecomment-1681974890, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFX53FDHWJQ2PCLABYGRNTXVXR5VANCNFSM6AAAAAA3SNLDEU . You are receiving this because you were mentioned.Message ID: @.*** com>

davidal381 commented 1 year ago

Thanks for the response, but still browser crash after a second with an error: SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed. (chrome not reachable) The browser version is 116 and chromedriver version 116.0.5845.96. code: System.setProperty("webdriver.chrome.driver", "C://Users//...//tmp//chromedriver.exe"); WebDriver driver = new ChromeDriver(); Thanks

Oussama-Maati commented 1 year ago

i found something hope it work for you ( I use python ) :

davidal381 commented 1 year ago

Thanks,

Thanks again