[Python] Trying to access the cr-toggle element, Python Selenium

Discussão em 'Python' iniciado por Stack, Janeiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I am creating a program to set up new profiles with a custom name, and I am trying to access the cr-toggle element but can't see this when i am using selenium.

    def setup_profile(profile_name):
    enter code here`profiles_dir = os.path.join(os.getcwd(), "profiles")
    os.makedirs(profiles_dir, exist_ok=True)
    user_data_dir = os.path.join(profiles_dir, profile_name)

    options = Options()
    options.binary_location = chromium_path
    options.add_argument(f"--user-data-dir={user_data_dir}")
    options.add_argument(f"--profile-directory={profile_name}")
    options.add_argument("--disable-web-security")
    options.add_argument("--allow-running-insecure-content")
    options.add_argument("--no-sandbox")
    options.add_argument("--enable-chrome-browser-cloud-management")
    options.add_argument("--force-dev-mode-highlighting")
    options.headless = False
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)
    driver = webdriver.Chrome(service=Service(ChromeDriverManager(chrome_type="chromium").install()), options=options)


    enter image description here enter image description here

    Continue reading...

Compartilhe esta Página