1
如何獲取TestInitialize中下一個測試方法的名稱?我需要知道下一個測試方法的名稱,因爲我想在BrowserStack中設置實際測試方法的「名稱」。 這裏是我的代碼:Selenium:初始化時獲取實際測試方法的名稱
[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://hub.browserstack.com/wd/hub/"), 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);
}
而在初始化我想第一行是這樣的:
bsCapabilities.SetCapability("name", "ValidLoginTest");