jeudi 23 juin 2016

Selenium: Get name of actual test method in initialize

how can I get name of next Test Method in TestInitialize? I need do know name of the next test method, because I want to set a "name" of actual test method in BrowserStack. Here is my code:

        [TestInitialize]
        public void BeforeAll()
        {
            DesiredCapabilities bsCapabilities = new DesiredCapabilities();
            bsCapabilities.SetCapability("name", /*name*/);
            bsCapabilities.SetCapability("os", "Windows");
            bsCapabilities.SetCapability("os_version", "8");
            bsCapabilities.SetCapability("browser", "Firefox");
            bsCapabilities.SetCapability("browser_version", "33.0");
            bsCapabilities.SetCapability("resolution", "1024x768");               
            DataCollection.Driver = new RemoteWebDriver(
                new Uri("http://ift.tt/1eU1sYp"), bsCapabilities
            );            
            DataCollection.Driver.Navigate().GoToUrl(root_site);
            DataCollection.Driver.Manage().Window.Maximize();
        }

        [TestMethod]           
        public void ValidLoginTest()
        {                            
            LoginPage LP = new LoginPage();           
            LP.FillForm("agileway", "testwise");
            Assert.IsTrue(Get.Element(FindBy.Id, "flash_notice").Displayed);
        }

And in initialize I want a first row something like this:

bsCapabilities.SetCapability("name", "ValidLoginTest");

Aucun commentaire:

Enregistrer un commentaire