How to run multiple test cases without closing the browser object | Selenium Webdriver Tutorial with c# |Selenium C# training

Selenium C# Training Forum

How to run multiple test cases without closing the browser object

S
Simanchal Sahu Post on 01/02/2019

Please help how to run the test cases with out closing the browser.

 

[TestFixture]
public class Startofpage

{
public IWebDriver driver;

[SetUp]

public void StartTest()
{

driver= new OpenQA.Selenium.IE.InternetExplorerDriver();
driver.Manage().Cookies.DeleteAllCookies();
}

[Test]
public void Incident1()
{

\\Test1
}

[Test]
public void Incident2()
{
\\Test2
}

}

I need hlep on how to run the test cases one by one without closing the browser opened in the test fixure.

Please help urgently

Simanchal sahu

sahusiman99@gmail.com

G

Instructor

gunjan Reply on 01/02/2019

Write driver.quit() command in the [TearDown] annotation in the class which will close the browser once after the execution of all the [Test] methods.

S
Simanchal Sahu Reply on 01/02/2019

Hello Mam,

My Porblem is I donot want to close the current browser untial i finish running all the test cases. Currently the default behaviour of the test initialize method is to run each time before all the test. Which i donot want. I want the initialize method to be run only once till my all test methods finish run. Please help on this. The brower should open only once and run all the test method (Test1,Test2,Test3....Test N) then the driver.quit mehtod should only run. Please help i need it urgently in my office. A request.

Thanks in Adv,

Simanchal..

 

 

G

Instructor

gunjan Reply on 05/02/2019

If you want to open browser only once, then you keep the code to open the browser in the [SetUp] annotation and the respective tests in the [Test] annotation and then the quit command in the [TearDown] annotation.