/// <summary> /// Create 'n' number of SMS users(student/instructor) from runtime generated values/Static /// Excel values. /// </summary> /// <param name="userCount">This is number of user.</param> /// <param name="userTypeEnum">This is the type of user.</param> /// <param name="mode">This is the mode of user generation.</param> /// <param name="smsUser">This is the user creating users.</param> public void BulkUserCreation(int userCount, User.UserTypeEnum userTypeEnum, string mode, User.UserTypeEnum smsUser) { // Create 'n' number of SMS users(student/instructor) from runtime generated //values/Static Excel values Logger.LogMethodEntry("Reg1Page", "BulkUserCreation", base.IsTakeScreenShotDuringEntryExit); //Select either generation using dynamic runtime values or static excel values try { switch (mode) { //Create using dynamic runtime values case "BulkRuntime": ExcelReadWrite excelReadAndWrite = new ExcelReadWrite(); AddExcelSheetHeaders(excelReadAndWrite); //Create using dynamic runtime values CreateBulkUserUsingRunTimeValues(userCount, userTypeEnum, mode, smsUser, excelReadAndWrite); //Saving the excel spreadsheet instance as Excel File. excelReadAndWrite.SaveExcelFile("Trial01"); break; //Create using ststic excel values. case "BulkExcel": ExcelReadWrite excelRead = new ExcelReadWrite(); Reg2Page reg2 = new Reg2Page(); //Access the excel file to read the user details to be entered for user creation excelRead.OpenExcelFile(@"D:\AutomationGeneratedExcelFiles\Trial02.xlsx", "Sheet01"); //Create using ststic excel values. CreateBulkUserUsingExcelValues(userCount, userTypeEnum, mode, smsUser, excelRead, reg2); break; } } catch (Exception e) { ExceptionHandler.HandleException(e); } Logger.LogMethodExit("Reg1Page", "BulkUserCreation", base.IsTakeScreenShotDuringEntryExit); }
/// <summary> /// Create using static excel values. /// </summary> /// <param name="userCount">This is the number of users.</param> /// <param name="userTypeEnum">This is type of user.</param> /// <param name="mode">This is the mode of user creation.</param> /// <param name="smsUser">This is the user performing the operation.</param> /// <param name="excelRead">This the excel spreadsheet instance.</param> /// <param name="reg2">this is class Reg2Page instance. </param> private void CreateBulkUserUsingExcelValues(int userCount, User.UserTypeEnum userTypeEnum, string mode, User.UserTypeEnum smsUser, ExcelReadWrite excelRead, Reg2Page reg2) { // Create using static excel values Logger.LogMethodEntry("Reg1Page", "CreateBulkUserUsingExcelValues", base.IsTakeScreenShotDuringEntryExit); //For eachuser perform below action try { for (int i = 1; i <= userCount; i++) { //URL launch step starting from second user //For first user action is handled by Backgroung step if (i > 1) { LaunchSMSRegistrationPage(smsUser); } //Click I Accept Button new ConsentPage().ClickIAcceptButtonBySMSAdmin(); string[] a = new string[12]; a = excelRead.ReadExcelCellDataValues(i, 12); //Select Sms User Account Number this.SelectSmsUserAccountNumber(); // Enter the SMS User Details and Get Password //Pass userName , password , accessCode from excel EnterUserCreationDetails(userTypeEnum, a[1], a[2], a[3], mode); //Pass userFirstName ,getUserLastName ,mailId ,country,school,schoolCity ,securityQuestion,securityAnswer reg2.EnterUserOtherDetails(a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11]); //Verify Confirmation page string confirmationPageTitle = new ConsentPage().GetPageTitle; if (confirmationPageTitle == "Confirmation and Summary") { continue; } } } catch (Exception e) { ExceptionHandler.HandleException(e); } Logger.LogMethodExit("Reg1Page", "CreateBulkUserUsingExcelValues", base.IsTakeScreenShotDuringEntryExit); }