Assert, Verify and other commands in Selenium WebDriver using C #

I almost searched every forum / site related to Selenium WebDriver, but still could not find a solution on how user statements and checks in Selenium WebDriver using C #.

Here is my code where I just want to put a sample statement in the code below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;


namespace Healthfleet
{
    class Login
    {
        static void Main(string[] args)
        {
            IWebDriver driver = new ChromeDriver(@"D:\Downloads");
            driver.Navigate().GoToUrl("https://test.com/");
            IWebElement username = driver.FindElement(By.Id("username"));
            IWebElement password = driver.FindElement(By.Id("password"));
            username.SendKeys("test@test.test");
            password.SendKeys("test");
            IWebElement loginButton = driver.FindElement(By.Id("Login"));
            loginButton.Click();
        }
    }
}

I need to check if username = test or not using the statement, but I cannot find any class or Assert method.

Am I missing a namespace that contains an Assert class or any other idea?

+5
source share
2 answers

NUnit was required to verify this. And you have to add it dll and then add namespace as

using NUnit.Framework;

+2

, . NUnit - .

, static void Main(string[] args), , [Test]. xUnit- NUnit .

+2

All Articles