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
10.02k stars 1.16k forks source link

Headless=True does not work #2030

Open Ambassador-of-programming opened 1 month ago

Ambassador-of-programming commented 1 month ago

Google Chrome version 129.0.6668.71 undetected-chromedriver version 3.5.5

from undetected_chromedriver import By
from fake_useragent import UserAgent
import undetected_chromedriver as uc
from bs4 import BeautifulSoup
import time
import urllib.parse
from parsing.modules.csv import append_to_csv

class Cian:
    def __init__(self):
        self.user_agent = UserAgent().chrome
        self.options_chrome = uc.ChromeOptions()
        self.options_chrome.add_argument(f'user-agent={self.user_agent}')

        self.driver = uc.Chrome(headless=True, use_subprocess=False, 
            options=self.options_chrome, version_main=129,)

the error is this:

(Session info: chrome=129.0.6668.71); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception

Stacktrace: GetHandleVerifier [0x00B86AB3+25587] (No symbol) [0x00B19C54] (No symbol) [0x00A12113] (No symbol) [0x00A56F62] (No symbol) [0x00A571AB] (No symbol) [0x00A97852] (No symbol) [0x00A7ABE4] (No symbol) [0x00A95370] (No symbol) [0x00A7A936] (No symbol) [0x00A4BA73] (No symbol) [0x00A4C4CD] GetHandleVerifier [0x00E64C63+3032483] GetHandleVerifier [0x00EB6B99+3368153] GetHandleVerifier [0x00C18F62+624802] GetHandleVerifier [0x00C207DC+655644] (No symbol) [0x00B2260D] (No symbol) [0x00B1F6D8] (No symbol) [0x00B1F875] (No symbol) [0x00B11CA6] BaseThreadInitThunk [0x76E37BA9+25] RtlInitializeExceptionChain [0x77D7C11B+107] RtlClearBits [0x77D7C09F+191]

Снимок экрана 2024-09-25 152205

MichaelMarcelKZ commented 1 month ago

Same problem here, but this is not a problem in undetected-chromedriver, but in chrome itself, after it has updated to version 129.

I found something about in here: https://issues.chromium.org/issues/367755364#comment2

They said that won't fix (probably not in 129).

Some things you can try:

You can find more information here: https://stackoverflow.com/questions/78996364/chrome-129-headless-shows-blank-window

Maxhem2 commented 1 month ago

https://googlechromelabs.github.io/chrome-for-testing/#beta

        browser_executable_path = './chrome-win64/chrome.exe'

        driver = uc.Chrome(options=options, browser_executable_path=browser_executable_path)
Ambassador-of-programming commented 1 month ago

https://googlechromelabs.github.io/chrome-for-testing/#beta

        browser_executable_path = './chrome-win64/chrome.exe'

        driver = uc.Chrome(options=options, browser_executable_path=browser_executable_path)

I tried installing https://googlechromelabs.github.io/chrome-for-testing/#beta

and set headless=True, but it doesn't work and gives an error, but if I set False, everything works successfully.

class Cian:
    def __init__(self):
        self.user_agent = UserAgent().chrome
        self.options_chrome = uc.ChromeOptions()
        self.options_chrome.add_argument(f'user-agent={self.user_agent}')

        self.driver = uc.Chrome(
            browser_executable_path='chrome/chrome-win64/chrome.exe',
            driver_executable_path='chrome/chromedriver-win64/chromedriver.exe',
            headless=True
            )

I noticed that the site uses a defense. When headless=True is enabled it doesn't give the html page but only when False is disabled it gives the result. How can this problem be solved?

unitoew commented 4 weeks ago

this works for me

options.add_argument("--headless=new")
options.add_argument("--window-position=-2400,-2400")

I think this issue may be related with selenium and chrome 129. Like links below same issues have been uploaded on selenium issues. https://github.com/SeleniumHQ/selenium/issues/14550