Assert in Selenium C#

后端 未结 8 760
[愿得一人]
[愿得一人] 2021-01-07 11:45

Is there a Assert class present in Selenium C# just like we have in Coded UI test.

Or I should use the Microsoft.VisualStudio.TestTools.UnitTesting.Asser

8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-07 12:12

    Selenium C# is not offering an assert class. You have to borrow it from somewhere or write your own implementation.

    Writing your own implementation will give you more freedom to manage assertions, as Peter said.

    Here is the basic idea. Just create a static class having assert methods like this:

    public static class MyAssertClass
    {
        public static void MyAreEqualMethod(string string1, string string2)
        {
            if (string1 != string2)
            {
              // Throw an exception
            }
        }
    }
    

提交回复
热议问题