[Python] while using python selenium --headless=new and user-data-dir together, it always pop...

Discussão em 'Python' iniciado por Stack, Setembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    I have following scipt:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    chrome_driver_path = r"C:\Program Files\chromedriver-win64\chromedriver.exe" # Update this path
    # Set up ChromeDriver service
    service = Service(chrome_driver_path)

    # Set up Chrome options to use the existing profile
    chrome_options = Options()
    chrome_options.add_argument("--headless=new")
    chrome_options.add_argument(r"user-data-dir=c:\Users\...\Default") # Path to your Chrome profile


    # Initialize Selenium WebDriver with the same profile
    driver = webdriver.Chrome(service=service, options=chrome_options)



    The script will use the profile defined in user-data-dir and execute in headless mode, it works well except it will pop up a white window, how to hide that?

    [​IMG]

    The entire screen except the Windows taskbar will go white. To clear the white screen I need to alt-tab twice.

    Continue reading...

Compartilhe esta Página