0

I am using Selenium with C# and MS test framework for automation in my project. I used ordered tests...added some tests in ordered tests and executed that but it's failing because it's unable to open the browser.

I have put my browser opening and URL opening code in one class in [TestInitialize] attribute but not in [Test Method] attribute, so I can't add those browser initialization methods in ordered tests.

how to solve this problem and give priority to automation tests in Selenium with C#.

I would like to give priority to different methods from different.cs classes.

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
S.S.N
  • 29
  • 1
  • 10

1 Answers1

0

Currently there are no fine solution except ordered test.

If you do not like ordered test, you could create a batch file which have the tests run in order with command mstest.exe

https://social.msdn.microsoft.com/Forums/en-US/7439a822-3363-4451-81bb-a93257bf2401/how-can-i-execute-all-test-cases-in-specified-priority-order?forum=vststest

OR

Merge your tests into one giant test will work. To make the test method more readable

OR

You can Use Playlist

Right click on the test method -> Add to playlist -> New playlist

the execution order will be as you add them to the playlist but if you want to change it you have the file

Source :-

Controlling execution order of unit tests in Visual Studio

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125