2

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");
         }
4

1 回答 1

1

好吧,您只是将其声明为另一种测试方法,因此这当然行不通。

您需要为 MSTest 提供更多关于何时调用您的方法的线索,因此将其替换为ClassCleanup以告诉 MSTest 在所有测试完成后调用此方法。

于 2013-12-03T22:06:46.620 回答