> For the complete documentation index, see [llms.txt](https://docs.cloudbeat.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloudbeat.io/supported-testing-frameworks/dotnet-mstest.md).

# .NET MSTest

## Installation

We need to include the MSTest kit by using:

```
dotnet add package CloudBeat.Kit.MSTest
```

### Install a specific version of a package <a href="#install-a-specific-version-of-a-package" id="install-a-specific-version-of-a-package"></a>

```
dotnet add package CloudBeat.Kit.MSTest --version 4.7.0
```

## Initialization

import:

```
using CloudBeat.Kit.MSTest;
```

Inherit the CbTest class and wrap the webdriver:

```
namespace CbExamples.MSTest.Infra
{
    [TestClass]
    public abstract class WebDriverTest : CbTest
    {
        private IWebDriver _driver = null;

        public EventFiringWebDriver Driver { get; private set; }

        [TestInitialize]
        public void SetUpWebDriver()
        {
            ChromeOptions options = new ChromeOptions();
            _driver = new ChromeDriver(options);
            Driver = new EventFiringWebDriver(_driver);
            CbMSTest.WrapWebDriver(Driver);
        }
    }
}
```

## Applying CBStep Attribute in your test cases

Import:

```
using CloudBeat.Kit.MSTest.Attributes;
```

Use attribute **\[CBStep]** to describe your test case:

```
[CbStep("Open \"Login\" page")]
public void Open()
{
    driver.Navigate().GoToUrl(baseUrl ?? DEFAULT_BASE_URL);
}
```

You can also use variables in the step description, to do that we'll put **username** in curly braces:

```
[CbStep("Type \"{username}\" in \"Username\" field")]
public void EnterUsername(string username)
{
	var usernameFld = UsernameField;
	if (usernameFld == null)
	   Assert.Fail("Username field not found");
	usernameFld.Click();
	usernameFld.SendKeys(username);
}
```

## Create Binaries

Before uploading our project to CloudBeat, we have to create a binaries zip folder, in your project folder open cmd and run the following command:

```
dotnet build
```

<figure><img src="/files/ywWH3OuKkPTjnpTqCP8Y" alt=""><figcaption></figcaption></figure>

a bin folder should be created, now go to bin -> debug and create a zip from net.6.0&#x20;

<figure><img src="/files/cmXzYogepneh9o5RzpWF" alt=""><figcaption></figcaption></figure>

## Creating MSTest project in Cloudbeat

Go to projects tab and create a new project and choose **MSTest - Binaries**

{% content-ref url="/pages/-Luhc-7l\_JV43u6esfU6" %}
[Projects](/references/projects.md)
{% endcontent-ref %}

<figure><img src="/files/cb4vQawzck6QeLqgc59X" alt=""><figcaption></figcaption></figure>

Decide who will have accessibility to this project

<figure><img src="/files/7Lpvvmzk5WWwSozYDFk7" alt=""><figcaption></figcaption></figure>

Upload the binaries as a zip

<figure><img src="/files/1seI1BHvvMUs16LT3MKJ" alt=""><figcaption></figcaption></figure>

Add assembly names and finish

<figure><img src="/files/KhpbcHN6uOFfIBGiBDxM" alt=""><figcaption></figcaption></figure>

And that's how you have a new MSTest project&#x20;

<figure><img src="/files/rJpBfAjpiySD17sr0Nbg" alt=""><figcaption></figcaption></figure>

## Running Test  Cases

Go to Cases under Testing tab, there you will see all your test cases

{% content-ref url="/pages/-LuhLvlMu9fDYoHu0rJI" %}
[Running Tests Cases](/fundamentals/executing-tests.md)
{% endcontent-ref %}

<figure><img src="/files/zOWXyusp7TwbeIeCctsm" alt=""><figcaption></figcaption></figure>

Select a browser to run your test on, save changes and run

<figure><img src="/files/TxLPqnW9zyItJE1KjVge" alt=""><figcaption></figcaption></figure>

You will see the results based on the **\[CbSteps]** that were added in your project

<figure><img src="/files/ruWtSh5VRTwPpsjAsj8m" alt=""><figcaption></figcaption></figure>
