Skip to main content

Testing web apps in C# using Selenium WebDriver and

This quickstart will show you how to visually test web apps in C# using Selenium WebDriver and Visual testing can help you catch problems that traditional automation struggles to find. You can also leverage Applitools Ultrafast Grid to run your tests across all the major browsers in a fraction of the time as other cross-browser testing platforms. Furthermore, you can run your Selenium WebDriver sessions remotely in Applitools Execution Cloud, which will alleviate your infrastructure burden as well as automatically heal any broken locators.

After preparing your environment, this three-step quickstart should take about 15 minutes to complete.

Need extra help?

If you get stuck on this example, don't suffer in silence! Please reach out to us to get things working. We can also help you get Applitools running in your own project.

Step 1: Preparing your environment

You'll need a few things to run this quickstart:

  1. An Applitools account, which you can register for free.

  2. The .NET 7 SDK for building and running the project.

  3. A good C# editor:

    • Use Microsoft Visual Studio if you want to drive development through a full IDE. Visual Studio comes bundled with the .NET SDK and all the tools you need out of the box. However, you will need to add a .runsettings file or overwrite some variables in the code to run the tests through Visual Studio.
    • Use Visual Studio Code if you want a faster experience driven more by the command line. You will need to install the C# extension and use the dotnet CLI tool from the terminal. You will also need to install the .NET SDK separately. Setting environment variables to run tests will be easier.
  4. An up-to-date version of Google Chrome.

  5. A corresponding version of ChromeDriver.

    Installing ChromeDriver

    The major version numbers of Chrome and ChromeDriver must be the same. Otherwise, Selenium WebDriver may raise an exception when it is initialized. For example, Chrome v101 requires ChromeDriver v101.

    ChromeDriver must be installed into a directory covered by the system PATH variable. Follow the instructions on Selenium's Install browser drivers page. On macOS and Linux, the recommended location for the chromedriver executable is the /usr/local/bin directory.

    You can test that ChromeDriver is working by running the chromedriver -v command to print its version.

Step 2: Getting your example project

Downloading the example project

The example project is located at Clone this repository to your local machine:

git clone
cd example-selenium-csharp-xunit
Don't have Git?

Instead of running git clone, you can download the project as a ZIP file and extract it.

Installing the dependencies

The example project uses NuGet for package management. All dependencies are listed in the project's .csproj file. They should be automatically downloaded whenever the project is built. You can explicitly restore NuGet packages from either Visual Studio or the command line by following this guide: Restore packages with NuGet Package Restore.

Adding Applitools to Another .NET Project?

This example project already has the Applitools Eyes SDK as a dependency. There are two NuGet packages for the Applitools Eyes SDK for different Selenium versions:

Pick the Selenium version you want, and add the appropriate package to your .NET project. To learn how to add NuGet packages to projects, follow the official guides for Visual Studio for Windows, Visual Studio for Mac, or the dotnet CLI.

Deciding how to run tests

The test uses Selenium WebDriver to automate the browser. There are two places to run your Selenium WebDriver session:

  1. On your local machine (which is the default option)
  2. On Applitools Execution Cloud

If you run WebDriver locally, then you need to set it up and manage it yourself. If you use Execution Cloud, then Applitools will manage WebDriver for you. It will also automatically heal broken locators and wait for elements to be ready. If you would like to try Execution Cloud, please request access. The docs for Execution Cloud provide more information.

There are two ways to test the visual snapshots captured by the test:

  1. Using Applitools Ultrafast Grid for cross-browser testing in the cloud
  2. Using Applitools Classic runner on your local machine

If you are not sure which one to pick, read Leveraging the Applitools platform. For most cases, we recommend Applitools Ultrafast Grid. The docs for Ultrafast Grid and Classic runner provide more information.

Walking through the code

Shared setup and cleanup for the Applitools runner and configuration is handled by an collection fixture located at Applitools.Example.Tests/ApplitoolsFixture.cs. This fixture can be used for multiple test classes. The variables at the top control how tests will run:

  • Set UseUltrafastGrid to true to use Ultrafast Grid or false to use the Classic runner.
  • Set UseExecutionCloud to true to use Execution Cloud or false to run WebDriver sessions locally.

Setup varies slightly for these different options.

The project contains one visual test case, which is located at Applitools.Example.Tests/AcmeBankTest.cs. AcmeBankTest is an test class that covers login behavior for the ACME Bank demo web app. It uses the Applitools Eyes SDK to execute the test across multiple browsers in Applitools Ultrafast Grid. With the Ultrafast Grid, you can specify different browser types, viewport sizes, and even mobile devices.

Step 3: Running your tests

Setting Applitools variables

Before running the visual test, you must find your Applitools API key and set it as an environment variable named APPLITOOLS_API_KEY.

If you intend to run your tests from the command line (or Visual Studio Code), then set the environment variable like this:

export APPLITOOLS_API_KEY=<your-api-key>

If you intend to run your tests from Visual Studio's Test Explorer, you will need to add a new .runsettings file to the project and then add APPLITOOLS_API_KEY as an environment variable in the .runsettings file. The example project does not come with a .runsettings file out of the repository.

Having trouble with environment variables?

If you have trouble setting the APPLITOOLS_API_KEY environment variable, you can hard-code your API key like this:

// Change the following line in ApplitoolsFixture.cs:
// ApplitoolsApiKey = Environment.GetEnvironmentVariable("APPLITOOLS_API_KEY");
ApplitoolsApiKey = "<your-api-key>";

However, be warned: hard-coding secrets is poor practice. Do this only temporarily for debugging, and never commit hard-coded secrets to version control.

You may also need to set your Applitools Eyes server. By default, tests will use the public Applitools Eyes server at However, if your team is using a private Applitools Eyes server, you can target it by setting the APPLITOOLS_SERVER_URL environment variable. (If you are using a free Applitools account, then use the public server.)

Launching visual tests

To run tests from the command line (or Visual Studio Code's terminal), run:

dotnet build
dotnet test

To run tests from Visual Studio, build the project and launch the tests from Test Explorer. To run it headlessly, set the HEADLESS environment variable to true.

After your tests run, you should see results in the Eyes Test Manager. You can log into the Test Manager at or at the address for your private Applitools Eyes server.

When you run tests with the Applitools Ultrafast Grid, the tests will run one time on the local machine, and then they will upload snapshots to render on each target configuration in the cloud. The Test Manager will show a separate result for each rendering. When you run tests with the Applitools Classic runner, the Test Manager will show the one snapshot from your local machine.

You can also change the web page to inject visual bugs:

// Driver.Navigate().GoToUrl("");

If you rerun the tests, then they should yield "unresolved" results for you to review. Visual differences will be highlighted in magenta. It's up to you to accept (👍) or reject (👎) the changes. Applitools will remember your decisions for future analysis.

Need extra help?

Again, it's okay. If you get stuck on this example, don't suffer in silence! Please reach out to us to get things working. We can also help you get Applitools running in your own project.

Taking the next steps with Applitools

Congratulations on completing this quickstart! There's still so much to learn about visual testing with Applitools, but you're off to a great start.

Resources for next steps:

  1. 🤖 Learning how visual testing works
  2. ↔️ Setting match levels for visual checkpoints
  3. 💥 Troubleshooting common issues
  4. 🐞 Reporting bugs
  5. 🗺 Detailed overview of visual testing with Applitools

You can also: