Skip to content

Message: session not created: Chrome failed to start: exited normally.(session not created: DevToolsActivePort file doesn't exist)(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) #2247

Closed
@STARKILLER-1

Description

@STARKILLER-1

I'm sorry for may be being stupid, but..

Bug only on ubuntu 22.04. On Windows 11 no issues!

I have been struggling with this problem for several days:

THIS CODE WORKS ON UBUNTU 22.04:

from selenium import webdriver
from selenium_stealth import stealth
import seleniumbase as sb
def initialize_driver():
    try:
        options = webdriver.ChromeOptions()
        options.add_argument("start-maximized")
        options.add_argument("--headless") 
        driver = sb.Driver(browser='chrome', headless=True, uc=True)
        wait = webdriver.Chrome.implicitly_wait(driver,500.00)
        stealth(driver,
                languages=["en-EN", "en"],
                vendor="Google Inc.",
                platform="Win64",
                webgl_vendor="Intel Inc.",
                renderer="Intel Iris OpenGL Engine",
                fix_hairline=True,
                wait=wait
                )
        time.sleep(3)
        return driver
    except:
        return None

THIS CODE ALWAYS FAILS ON UBUNTU 22.04:

def initialize_driver(account_number, cookies_file, url, proxy, attempt=1):
    if attempt > 5: 
        return None
    try:
        driver = sb.Driver(browser='chrome', headless=True, uc=True, proxy=proxy)
        wait = webdriver.Chrome.implicitly_wait(driver,500.00)
        stealth(driver,
                languages=["en-EN", "en"],
                vendor="Google Inc.",
                platform="Win64",
                webgl_vendor="Intel Inc.",
                renderer="Intel Iris OpenGL Engine",
                fix_hairline=True,
                wait=wait
                )
        driver.get(url)
        time.sleep(3)
        with open(cookies_file, 'r') as f:
            cookies = json.load(f)
            current_domain = driver.current_url  
            for cookie in cookies:
                if 'sameSite' in cookie and cookie['sameSite'] not in ['Strict', 'Lax', 'None']:
                    del cookie['sameSite']
                if 'domain' in cookie:
                    if current_domain.find(cookie['domain']) != -1:  # Check if the cookie domain is in the current domain
                        driver.add_cookie(cookie)
        driver.refresh()
        time.sleep(3)
        try:
            wait = WebDriverWait(driver, 2)
            wait.until(EC.presence_of_element_located((By.XPATH, "//*[contains(normalize-space(), 'Enter or registrate')]")))
            driver.quit()
            return initialize_driver(account_number, cookies_file, url, proxy, attempt + 1)
        except Exception as e:
            print(e)
        return driver
    except Exception as e:
        print(e)
        driver.quit()
        return None

I was debugging alot. On Windows 11 no issues!
Only this code can go through Cloudflare on a target site

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    UC Mode / CDP ModeUndetected Chromedriver Mode / CDP Modeinvalid usageYou may need to change what you're doingquestionSomeone is looking for answers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions