How to Open Chrome Incognito Mode with Selenium using VBA: A Tech Support Guide

Abstract: Enable Chrome Incognito mode in Selenium VBA scripts by adding the --incognito argument to ChromeOptions.

Created: 2026-08-20 by
You can launch Chrome in Incognito Mode via Selenium and VBA by configuring the ChromeOptions object to include the specific command-line argument for private browsing. This approach allows your automation scripts to run without leaving local history or cookies, which is essential for privacy-focused testing or handling sensitive data. The process involves initializing the WebDriver with these custom options before navigating to any target URL, ensuring that the browser session remains isolated from standard user profiles.

Setting Up Your Environment

Before writing the macro, ensure that you have the necessary components installed on your machine. You need a version of Selenium Basic compatible with your Office environment, as well as the appropriate WebDriver executable for your version of Google Chrome. The WebDriver acts as the bridge between your VBA code and the Chrome browser, translating your commands into actions the browser understands. If you are using the SeleniumBasic library, you can install it via NuGet or download it directly from their GitHub repository. Make sure the path to the chromedriver.exe file is accessible to your script, either by placing it in your system's PATH or by specifying the exact directory in your code.

Configuring Chrome Options

The core of this solution lies in how you configure the browser instance. Standard Selenium initialization creates a normal browser window, but we need to modify this behavior. In VBA, you create an instance of the ChromeOptions class. This object holds various settings that dictate how the browser starts. To enable Incognito mode, you must add a specific argument to the options collection. This argument tells Chrome to start in private browsing mode immediately upon launch. It is important to note that different browsers use different flags; for Chrome, the flag is distinct from Firefox or Edge implementations.

Writing the VBA Code

Below is a complete example of how to structure your VBA module. This code demonstrates the initialization of the driver, the application of the Incognito option, and the navigation to a website. Copy this structure into your Excel VBA editor, ensuring you adjust the driver path if necessary.
Sub OpenChromeIncognito()
    Dim driver As New ChromeDriver
    Dim options As New ChromeOptions
    
    ' Set the path to your chromedriver if not in PATH
    ' driver.SetServicePath "C:\path\to\chromedriver.exe"
    
    ' Add the incognito argument
    options.AddArgument("--incognito")
    
    ' Initialize the driver with the options
    driver.Start "chrome", options
    
    ' Navigate to a test site
    driver.Get "https://www.google.com"
    
    ' Allow time for page load
    driver.Wait 5000
    
    ' Optional: Take a screenshot to verify
    driver.Screenshot.SaveAs "C:\temp\incognito_test.png"
    
    ' Clean up
    driver.Quit
    Set driver = Nothing
    Set options = Nothing
End Sub
In this snippet, the AddArgument method is crucial. It appends the string "--incognito" to the list of startup parameters. When driver.Start is called, Selenium passes these arguments to the Chrome executable. This ensures that no matter what profile settings exist, the new window opens in a temporary, ephemeral state. After the navigation and verification steps, always call driver.Quit to close the browser and release system resources. Failing to do so can lead to orphaned processes consuming memory.

Handling Driver Paths

If you encounter errors related to the WebDriver not being found, check your system environment variables. Alternatively, you can explicitly define the service path within the VBA code. This is particularly useful when deploying macros across different machines where the driver location might vary. By hardcoding the path or using a relative path from the workbook location, you reduce the likelihood of runtime errors. Always ensure the version of the WebDriver matches the major version of your installed Chrome browser. Mismatched versions often result in connection refused errors or unexpected crashes during initialization.

Verifying Incognito Status

To confirm that the mode is active, you can inspect the browser window or check the URL bar. In Incognito mode, Chrome typically displays a dark theme and may show a specific icon indicating private browsing. Additionally, you can verify that no cookies are persisted by closing the window and reopening a standard window to see if previous sessions are restored. This verification step is helpful for debugging if the script fails to behave as expected. It confirms that the arguments were correctly passed and interpreted by the browser engine. For more information on managing browser configurations, you might find Default Browser Keeps Reverting to Chrome After Reboot: A Tech Support Guide useful for understanding broader browser stability issues. If you suspect configuration files are causing issues, Restore Chrome settings and passwords from local files provides steps to reset corrupted profiles.

Frequently Asked Questions

Does Selenium delete all cookies after the session ends?

Yes, because Incognito mode does not persist data to disk, all cookies and cache are cleared automatically when the browser window is closed. This makes it ideal for testing scenarios where you need a clean slate every time the script runs. You do not need to manually clear cookies using Selenium commands in this mode.

Can I use other arguments with Incognito mode?

Absolutely. You can combine the --incognito flag with other arguments like --headless for running without a visible UI or --disable-gpu for certain compatibility fixes. Just ensure each argument is added separately using the AddArgument method. This flexibility allows you to tailor the browser environment to your specific automation needs.

Why does my script fail with a "Connection Refused" error?

This usually indicates a mismatch between your Chrome browser version and the WebDriver version. Check your Chrome version by going to Help > About Google Chrome and download the matching WebDriver. Ensure that the WebDriver executable has the correct permissions to run on your system. Updating both components to the latest stable releases often resolves connectivity issues.

Is it possible to open multiple Incognito windows simultaneously?

Selenium can manage multiple driver instances, but each must be initialized with its own ChromeOptions object. You cannot share a single driver instance across multiple tabs or windows in different modes. Create separate driver objects for each window you wish to open, ensuring they are independent of each other to avoid conflicts.

How do I handle pop-ups in Incognito mode?

Pop-up handling in Incognito mode works similarly to standard mode, but you must ensure your selector strategies account for the different styling or lack of persistent elements. Use explicit waits to wait for the pop-up element to appear before interacting with it. Since Incognito windows do not save preferences, any extensions or settings that normally block pop-ups will not be present, potentially changing the timing of interactions.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More