我怎样才能按顺序运行selenium C#测试用例?

时间:2017-01-25 10:21:33

标签: c# selenium automated-tests

我使用selenium在c#中有10个测试用例,但它们没有按顺序运行,我如何命令运行测试用例。

这是我的代码。

[Test]
public void AddLeadWithOneTract()
{
    ClickOnAddNewLead(driver);
    EnterLeadInfo(driver, leadDictionary);
    AddTract(driver);
    EnterTractInfo(driver, tractDictionary, "4n", "2e", "22", "NENE", "1000", "1000", "10");
    SaveTract(driver);
    SaveLeadAndExit(driver);
    TryFindElementById(driver, "R2017000000", 2000);

}

[Test]
public void TestTractInfoValidation()
{
    ClickOnAddNewLead(driver);
    AddTract(driver);
    EnterTractInfo(driver, tractDictionary, "4", "2", "22", "NENE", "-1000", "-1000", "-10");
    SaveTract(driver);
    string alertText = CloseAlertAndGetItsText(driver);
    Assert.IsTrue(alertText.Contains("Please enter a valid Township"));
    Assert.IsTrue(alertText.Contains("Please enter a valid Range"));
    Assert.IsTrue(alertText.Contains("Please set valid asked price"));
    Assert.IsTrue(alertText.Contains("Please enter a valid NRI"));
    Assert.IsTrue(alertText.Contains("Please enter a valid NMA"));
}

1 个答案:

答案 0 :(得分:3)

Nunit 3.*order attribute

[Test, Order(1)]
public void AddLeadWithOneTract()
{
}

[Test, Order(2)]
public void TestTractInfoValidation()
{
}