Running Selenium without a GUI

Running Selenium without a GUI is known as running it in “headless” mode. In this mode, the browser doesn’t display a user interface, which is particularly useful for automated tests that run on servers or other environments where a graphical display is not available.

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace MySeleniumApp
    class Program
        static void Main(string[] args)
            // Initialize ChromeDriver options
            ChromeOptions options = new ChromeOptions();
            options.AddArgument("--headless");  // Run headless
            // Initialize the Chrome Driver with options
            using (IWebDriver driver = new ChromeDriver(options))
                // Navigate to Google

                // Optionally, capture the page title to verify
                Console.WriteLine("Page title is: " + driver.Title);

                // Close the driver

Chrome will run in headless mode, performing all the actions but without displaying the browser GUI. You should see the page title printed in the console if everything works correctly.

The ability to run tests in headless mode can be particularly useful in an automated testing environment or a CI/CD pipeline.