这是我的两种测试方法:
[Test]
public void Test00NewCustomerRegistrationPrePaidHo()
{
HomePage homePage = new HomePage(driver, Reporter);
homePage.ExpandMenu("Registration")
.SelectMenuItem("Customer Application");
applicationnumber = RandomString(RandomStringType.Numeric, 10);
NewCustomerRegistrationPagePrePaidHo newCustomerRegistrationPagePrePaidHo = new NewCustomerRegistrationPagePrePaidHo(driver, Reporter);
newCustomerRegistrationPagePrePaidHo.ClickNewCustomerApplicationData()
.ValidateApplicationNumber(applicationnumber)
.EnterEntityName("Automation")
.EnterCustomerName(RandomString(RandomStringType.Alpha, 10),
RandomString(RandomStringType.Alpha, 10),
RandomString(RandomStringType.Alpha, 10))
.EnterOtherCustomerDetails("", "", dHandler.GetAppData(TcfaDataKeys.DATEOFBIRTH), RandomString(RandomStringType.Alpha, 5) +
RandomString(RandomStringType.Numeric, 4) +
RandomString(RandomStringType.Alpha, 1))
.EnterAddressInfo(dHandler.GetAppData(TcfaDataKeys.COUNTRY),
dHandler.GetAppData(TcfaDataKeys.STATE),
dHandler.GetAppData(TcfaDataKeys.DISTRICT),
dHandler.GetAppData(TcfaDataKeys.CITY))
.EnterContactInformation(RandomString(RandomStringType.Numeric, 2),
RandomString(RandomStringType.Numeric, 10),
RandomString(RandomStringType.Numeric, 10))
.EnterAccountInformation(dHandler.GetAppData(TcfaDataKeys.BANKACTYPE),
dHandler.GetAppData(TcfaDataKeys.NAMEOFBANK))
.SubmitNewCustomerInformation();
Thread.Sleep(5000);
}
[Test]
public void Test01PendingCustomerRegistrationPrePaidHo()
{
String number = applicationnumber;
HomePage homePage = new HomePage(driver, Reporter);
homePage.ExpandMenu("Registration")
.SelectMenuItem("Customer Registration");
PendingCustomerRegistrationHo pendingCustomerRegistrationHo = new PendingCustomerRegistrationHo(driver, Reporter);
pendingCustomerRegistrationHo.ClickListofPendingcustomerApplication()
.ClickPending(number)
.ClickSaveAndNext()
.ClickSaveAndNext()
.EnterCardEnrollmentInformation("1", "2")
.ClickSaveAndNext()
.ClickSaveAndNext()
.ClickSaveAndNext()
.AddVehicleDetails(2)
.ClickSaveAndNext()
.EnterEnrollementDetails(RandomString(RandomStringType.Alpha, 10))
.EnterDispatchDetails("000001 RCPHO TCOPS");
Thread.Sleep(5000);
}
在最终测试结束时有一种拆卸方法。
每次运行脚本时,测试都会执行,关闭浏览器,再次重新打开浏览器并运行第二次测试。
我想要一个测试,我可以在不关闭浏览器的情况下运行这些脚本。
答案 0 :(得分:0)
这可能会解决您的问题。我已经用Nunit映射了TestNG。并为Nunit编写了代码:
[SetUpFixture]
public void setUpClass(){
// Marks a class with one-time setup or teardown methods for all the test fixtures in a namespace.
// instantiate your driver object here //
}
[SetUp]
public void setUpMethod(){
// Indicates a method of a TestFixture called just before each test method.
// your login or before method activity(which would be running before every test method)
}
[Test]
public void testMethod1(){
// Marks a method of a TestFixture that represents a test.
// Your Test Method.
}
[Test]
public void testMethod2(){
// Marks a method of a TestFixture that represents a test.
// Your Test Method.
}
[TearDown]
public void tearDownMethod(){
// Indicates a method of a TestFixture called just after each test method.
// your log out or after method activity(which would be running after every test method)
}
}
如需更多参考,请点击以下链接:https://github.com/nunit/docs/wiki/Attributes
如果您对此有任何疑虑,请与我们联系。