I have a test class Navigation and I have derived class LeadExTest that is derived from Navigation class. Both class are of [TestClass] type
Now i have a ordered test file, that has a few tests i need to be executed in the order i have shown below. AdminLogin do some action quit browser
AdminLogin, Navigate to page and quit browser test methods belong to Navigation class and do some action belongs to leadextest class
When i execute this ordered test file, admin login and do some action test cases execute just fine, but quit browser method is not getting hit.
//Base class
public class Navigation
{
protected static IWebDriver driver;
protected WebDriverWait wait;
protected StringBuilder verificationErrors;
private string baseURL;
//private bool acceptNextAlert = true;
protected static string advertiserId = "6570";
protected static Actions builder;
[TestInitialize]
public void SetupTest()
{
if (driver == null)
{
driver = new FirefoxDriver();
driver.Manage().Window.Maximize();
baseURL = ConfigurationManager.AppSettings["base_url"].ToString();
verificationErrors = new StringBuilder();
//string url = @"https://stage.madisonlogic.com/login.aspx";
//driver.Navigate().GoToUrl(url.ToString());
driver.Navigate().GoToUrl(ConfigurationManager.AppSettings["test_url"].ToString());
builder = new Actions(driver);
}
wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
}
[TestMethod]
public void adminLogin()
{
CommonFunctions.Login(driver, "rlodha", "a");
if (IsElementPresent(By.ClassName("TopTitle")))
Assert.AreEqual("Admin Center | Dashboard", driver.FindElement(By.ClassName("TopTitle")).Text.Trim().ToString());
else
Assert.Fail("Timed Out");
}
[TestMethod]
public void browserQuit()
{
CommonFunctions.BrowserQuit(driver);
Assert.IsNull(driver);
}
//derived class
[TestMethod]
public void Nav_Lead_Delivery()
{
builder.MoveToElement(driver.FindElement(By.Id("Content_AdvertiserMenu1_LeadsBtn"))).Perform();
driver.FindElement(By.Id("Content_AdvertiserMenu1_LeadExportBtn")).Click();
Console.Write("Hi");
}
Well you are just declaring it as another test method, so of course this isn't going to work.
You need to give MSTest much more of a clue about when to call your method, so replace it with a ClassCleanup to tell MSTest to call this method when all the tests are done.