Set up and Run Selenium C# Tests in Visual Studio Code on macOS

How to use VSCode on macOS to run C# Selenium tests

Courtney Zhan

--

Readers of my and my father’s blog know that we love to use Ruby to script automated tests. Some might wonder, “Is your view on the best language for test automation changed? Also, C# on macOS?”. This is just a curious exercise for a request. My love for the wonderful Ruby language is the same, probably even more so after this exercise.

Install Visual Studio Code first. The version I used is v1.76 on macOS 12.6.

Table of Contents:
1. Install .NET SDK (7.0)
2. Install C# and Nuget package manager extensions into VS Code
3. Create a MSTest Project Folder
4. Open the newly created test project folder in VS Code
5. Add the Selenium WebDriver package to the Test Project
6. First Selenium C# test

1. Install .NET SDK (7.0)

Download from https://dotnet.microsoft.com/en-us/download/dotnet/7.0. I chose the “macOS X64”. Run the installer.

Start a new terminal window and enter the command below to verify installation:

$ dotnet --version
7.0.202

2. Install C# and Nuget package manager extensions into VS Code

Press “Cmd+Shift+X” in VS Code and search for “C#” in the Extension Marketplace.

This is to add support C# in VS Code. Install it.

Repeat the same process for the “NuGet Package Manager”, which helps to add libraries, such as Selenium WebDriver, to test projects.

--

--