0

I get Error: Message: session not created: cannot connect to chrome at 127.0.0.1:55046 when running:

import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec


    options = uc.ChromeOptions()

    from pathlib import Path
    user_data_dir = Path("/Users/.../Google/Chrome").resolve()
    user_data_path = str(user_data_dir)

    user_agent = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
                  "AppleWebKit/537.36 (KHTML, like Gecko) "
                  "Chrome/114.0.0.0 Safari/537.36")

    options.add_argument(f'user-agent={user_agent}')

    options.add_argument("--disable-blink-features=AutomationControlled")
    options.add_argument(f"--user-data-dir={user_data_path}")

    options.add_argument("--no-sandbox")
    options.add_argument("--disable-dev-shm-usage")
    options.add_argument("--disable-infobars")
    options.add_argument("--disable-extensions")
    options.add_argument("--disable-gpu")

    driver = uc.Chrome(options=options)

tried with chrome 138 and latest undetected-chromedriver and also with chrome 137 and undetected-chromedriver 3.5.3.

1 Answer 1

0
import os
import shutil
import undetected_chromedriver as uc

ORIGINAL_PROFILE = "/Users/YourPerfile/Library/Application Support/Google/Chrome/Profile 9"
AUTOMATION_PROFILE = "/Users/Yourperfile/.chrome_automation_profile/Profile 9"#choose your perfile 

if not os.path.exists(AUTOMATION_PROFILE):
    os.makedirs(os.path.dirname(AUTOMATION_PROFILE), exist_ok=True)
    shutil.copytree(ORIGINAL_PROFILE, AUTOMATION_PROFILE)
    print("Perfil clonado para automatización.")
else:
    print("clonado Perfectamente")

options = uc.ChromeOptions()
options.add_argument(f"--user-data-dir=/Users/You perfile/.chrome_automation_profile")
options.add_argument("--profile-directory=Profile 9")
options.add_argument("--start-maximized")

driver = uc.Chrome(version_main=140, options=options)
driver.get("https://www.google.com")

I solved it, enjoy it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.