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.58k stars 1.14k forks source link

Headless Mode in v111 (3.4.5) Error #1141

Open Baseult opened 1 year ago

Baseult commented 1 year ago

I try to start the Browser this way: options = uc.ChromeOptions() options.headless = True options.add_argument('--headless') driver = uc.Chrome(options=options) driver.get("https://login.leagueoflegends.com/?redirect_uri=https://lolesports.com/&lang=en")

But it crashes saying:

Traceback (most recent call last): File "C:\Users\Baseult\Documents\undetected-chromedriver-master\example\example - Kopie.py", line 80, in main(a) File "C:\Users\Baseult\Documents\undetected-chromedriver-master\example\example - Kopie.py", line 29, in main driver = uc.Chrome(options=options) File "C:\Users\Baseult\Documents\undetected-chromedriver-master\undetected_chromedriver__init.py", line 374, in init__ if self.patcher.version_main < 108: TypeError: '<' not supported between instances of 'NoneType' and 'int'

Fixed it with this:

line 374 in init.py

    if headless or options.headless:
        version=self.patcher.version_main
        if version and version < 108:
            options.add_argument("--headless=chrome")
        else:
            options.add_argument("--headless=new")
ultrafunkamsterdam commented 1 year ago

Just remove --headless from your options Or better also from your options. Just launch driver = Chrome(options=options,headless=True)

EsauM10 commented 1 year ago

I'm facing the same error on: driver = chromedriver.Chrome(headless=True)

Traceback: File "C:\Users\Projects\scrapper\venv\lib\site-packages\undetected_chromedriver__init.py", line 374, in init__ if self.patcher.version_main < 108: TypeError: '<' not supported between instances of 'NoneType' and 'int'

I fixed it with the @Baseult's solution

apolloid commented 1 year ago

you can try --headless=new as shown below

options=webdriver.ChromeOptions() options.add_argument("--headless=new") driver = uc.Chrome(options=options)

OpsecGuy commented 1 year ago

Thats a fix for other people having problems with running in Headless mode

https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1149#issuecomment-1506363691

aotol commented 1 year ago

Thats a fix for other people having problems with running in Headless mode

#1149 (comment)

Are you sure it is the fix? I did the following and I still get the error

    options.version_main = 113
    options.driver_executable_path='C:\Program Files\Google\Chrome\Application\chrome.exe'
    options.headless=True

Error message: Error: Traceback (most recent call last): File "c:\Users\pinsher\Documents\Projects\python\headless.py", line 19, in driver = uc.Chrome(options=options) File "C:\Python\Python310\lib\site-packages\undetected_chromedriver__init.py", line 374, in init__ if self.patcher.version_main < 108:TypeError: '<' not supported between instances of 'NoneType' and 'int'

Update: It seems you have to update undetected_chromedriver's source code. in my case, the source code is located at: C:\Python\Python310\lib\site-packages\undetected_chromedriver__init__.py When you open the code, go to line 374 and put condition check for the version.

if headless or options.headless:
    version=self.patcher.version_main
    if version and version < 108:
        options.add_argument("--headless=chrome")
    else:
        options.add_argument("--headless=new")
OpsecGuy commented 1 year ago

Thats a fix for other people having problems with running in Headless mode

#1149 (comment)

Are you sure it is the fix?

I did the following and I still get the error


    options.version_main = 113

    options.driver_executable_path='C:\Program Files\Google\Chrome\Application\chrome.exe'

    options.headless=True

Error message:

Error: Traceback (most recent call last): File "c:\Users\pinsher\Documents\Projects\python\headless.py", line 19, in driver = uc.Chrome(options=options) File "C:\Python\Python310\lib\site-packages\undetected_chromedriver__init.py", line 374, in init__ if self.patcher.version_main < 108:TypeError: '<' not supported between instances of 'NoneType' and 'int'

Update:

It seems you have to update undetected_chromedriver's source code. in my case, the source code is located at:

C:\Python\Python310\lib\site-packages\undetected_chromedriver__init__.py

When you open the code, go to line 374 and put condition check for the version.


if headless or options.headless:

    version=self.patcher.version_main

    if version and version < 108:

        options.add_argument("--headless=chrome")

    else:

        options.add_argument("--headless=new")

Hey bruh, You ask me if I'm sure so "I'm sure that solution worked and still works for me".

It's quite easy to update source code to get rid of that issue so if you would ever need help I can help you make necessary changes in code for free (not really, for the follow of my GitHub profile hahahaha). Once again, solution I mentioned worked in my case and also I don't have any issues with passing any JavaScript challenge/ captchas using 3.4.5 update. It's sad that project doesn't get updated more often, however it's great base for the people who have even a little knowledge of selenium and web automation.

If you need help add me on discord:

Opsec#3709