yaqing wang
yaqing wang

Reputation: 21

while using python selenium --headless=new and user-data-dir together, it always pop up a white window

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?

example of the problem

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

Upvotes: 2

Views: 286

Answers (0)

Related Questions