Testing web applications on macOS with C# and .NET Core

Micro Focus Expert
Micro Focus Expert
1 2 3,577

.NET Core brings the power of C# and VB.NET to macOS and Linux. Thanks to the hard work by the teams at Microsoft and the efforts of the Selenium Community, it is now even possible to run WebDriver tests in C# or VB.NET directly on your Mac! In this blog post we will show you how.


First, download and install the latest version of the .NET Core SDK from https://www.microsoft.com/net/download/macos on your Mac. As an IDE for C# and VB.NET on macOS, you can use Visual Studio Code, which you can download from https://code.visualstudio.com/download. To make Selenium testing easier, you can use Silk WebDriver to record your tests. You can download Silk WebDriver - also for macOS - directly from here: https://build.microfocuscloud.com/download?product=silkwebdriver.

Test project setup

After you have installed .NET Core, Visual Studio Code, and Silk WebDriver, it is time to set up your first .NET Core testing project. Create a new folder, for example on the desktop, and open that folder with Visual Studio Code. Open the Integrated Terminal by selecting View > Integrated Terminal and use the following command to actually create the project:

$ dotnet new mstest

This will create a .csproj file as well as an empty unit test which you can run with the following command:

$ dotnet test

If everything is set up correctly, .NET Core should compile and run the empty test:

Even more convenient is that you can run the test directly from Visual Studio Code. If you are prompted to install additional components for Visual Studio Code to enable this feature, do so.


Now it is time to record a Selenium test which you can later run in the context of your test project. Start Silk WebDriver, click Record, select the browser of your choice, and specify the URL of the application that you want to test:

Use the intuitive point-and-click recorder to record actions against your web app. You can also replay the recorded actions during recording to make sure that you have correctly captured the desired workflow.

When you are done with recording, select C# Unit Testing from the list of available export languages in Silk WebDriver:

Click Export… in the Silk WebDriver menu and specify a file name. Make sure that you export the file into the folder with the .NET Core project that you have previously created.

You can now close Silk WebDriver and switch back to Visual Studio Code.

Selenium dependencies

Back in Visual Studio Code you should see that the project with the two unit test files now has some unresolved compile errors:

This is because you have not specified yet that you require the Selenium libraries for your project. Open the integrated terminal again and use the following commands to add those references:

$ dotnet add package Selenium.WebDriver
$ dotnet add package Selenium.Support

After that, Visual Studio Code might prompt you to restore its package context - confirm this and the errors should be gone:

Running the test

Now it is time to actually run the Selenium test. You can again use either the dotnet test in the terminal or the run test link in Visual Studio Code to run the test:


Both on Windows and on the Mac, the combination of Visual Studio Code, C#/VB.NET, .NET Code, Selenium, and of course Silk WebDriver, has you covered when it comes to browser testing!

vijaysubramanian Absent Member.
Absent Member.

Is there any issue or challenge in running Selenium tests in Visual Studio Community edition instead of Visual studio code?

Micro Focus Contributor
Micro Focus Contributor

[mention:8f2858b668654b85a7c8d53ec0a3e716:e9ed411860ed4f2ba0265705b8793d05] there should not be any issue running Selenium tests in Visual Studio Community Edition instead of VS Code

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.