undetected-chromedriver
undetected-chromedriver copied to clipboard
Headless Mode in v111 (3.4.5) Error
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
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")
Just remove --headless from your options
Or better also from your options. Just launch driver = Chrome(options=options,headless=True)
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
you can try --headless=new as shown below
options=webdriver.ChromeOptions() options.add_argument("--headless=new") driver = uc.Chrome(options=options)
Thats a fix for other people having problems with running in Headless mode
https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/1149#issuecomment-1506363691
Thats a fix for other people having problems with running in Headless mode
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
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")
Thats a fix for other people having problems with running in Headless mode
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