//********************************************************************** /// <summary> /// After one case running, write additional info to the scripts file /// </summary> public void writeInfo() { opXls.writeCell(12, 2, Ranorex.Host.Local.RanorexVersion); opXls.writeCell(21, 2, Ranorex.Host.Local.OSEdition + " " + Ranorex.Host.Local.OSVersion); opXls.writeCell(22, 2, Ranorex.Host.Local.RuntimeVersion); NformRepository repo = NformRepository.Instance; //Delay.Milliseconds(2000); if (!repo.NFormApp.NformG2Window.FormMain.HelpInfo.Exists()) { return; } //Delay.Milliseconds(2000); repo.NFormApp.NformG2Window.FormMain.Help.Click(); repo.NFormApp.NformG2Window.FormMain.About_Liebert_Nform.Click(); Ranorex.NativeWindow nativeWnd = repo.NFormApp.Help.FormAbout_LiebertR_Nform.ViewerVerInfo.CreateAdapter <Ranorex.NativeWindow>(false); string viewVer = nativeWnd.WindowText; repo.NFormApp.Help.FormAbout_LiebertR_Nform.TabServer.Click(); nativeWnd = repo.NFormApp.Help.FormAbout_LiebertR_Nform.ServerVerInfo.CreateAdapter <Ranorex.NativeWindow>(false); string severVer = nativeWnd.WindowText; repo.NFormApp.Help.FormAbout_LiebertR_Nform.TabDatabase.Click(); nativeWnd = repo.NFormApp.Help.FormAbout_LiebertR_Nform.DbVersionInfo.CreateAdapter <Ranorex.NativeWindow>(false); string dbVer = nativeWnd.WindowText; nativeWnd = repo.NFormApp.Help.FormAbout_LiebertR_Nform.DbEditionInfo.CreateAdapter <Ranorex.NativeWindow>(false); string dbEdition = nativeWnd.WindowText; repo.NFormApp.Help.FormAbout_LiebertR_Nform.TabLicense.Click(); // nativeWnd = repo.NFormApp.Help.FormAbout_LiebertR_Nform.LicenseDetailInfo.CreateAdapter<Ranorex.NativeWindow>(false); string licenseDetail = repo.NFormApp.Help.FormAbout_LiebertR_Nform.LicenseDetail.TextValue; //nativeWnd.WindowText; repo.NFormApp.Help.FormAbout_LiebertR_Nform.TabRegistration.Click(); nativeWnd = repo.NFormApp.Help.FormAbout_LiebertR_Nform.RegistInfoDscrInfo.CreateAdapter <Ranorex.NativeWindow>(false); string regist = nativeWnd.WindowText; repo.NFormApp.Help.FormAbout_LiebertR_Nform.OK.Click(); opXls.writeCell(13, 2, viewVer); opXls.writeCell(14, 2, severVer); opXls.writeCell(15, 2, dbEdition); opXls.writeCell(16, 2, dbVer); opXls.writeCell(20, 2, regist); }
/// <summary> /// Create excel contains all dependent values for creating select list /// </summary> public void generateFormValDependList(string fileName) { NformRepository repo = NformRepository.Instance; string excelPath = "keywordscripts/" + fileName + ".xlsx"; excelPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), excelPath); LxXlsOper opXls = new LxXlsOper(); // opXls.open("c:/test.xlsx"); opXls.create(excelPath); object oMissing = System.Reflection.Missing.Value; Excel.Workbook xBook = opXls.xBook; Excel.Worksheet xSheet = opXls.xSheet; Excel.Worksheet xSheetComponent = (Excel.Worksheet)xBook.Worksheets[1]; Excel.Worksheet xSheetActions = (Excel.Worksheet)xBook.Worksheets[2]; Type objType = repo.GetType(); int iFormRow = 1; int iComponentRow = 1; int iComponentCol = 2; int iActionsCol = 1; object obj = repo; PropertyInfo pi = objType.GetProperty("NFormApp"); obj = pi.GetValue(repo, null); objType = obj.GetType(); PropertyInfo[] piArrLev1 = objType.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo piLev1 in piArrLev1) { if (piLev1.Name.CompareTo("UseCache") == 0) { continue; } object objLogicGroup = piLev1.GetValue(obj, null); objType = objLogicGroup.GetType(); PropertyInfo[] piArrLev2 = objType.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo piLev2 in piArrLev2) { if (piLev2.Name.Substring(0, 4).CompareTo("Form") != 0) { continue; } opXls.writeCell(iFormRow++, 1, piLev2.Name); // MessageBox.Show(objLogicGroup.ToString()); object objWindows = piLev2.GetValue(objLogicGroup, null); objType = objWindows.GetType(); PropertyInfo[] piArrComp = objType.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo piCom in piArrComp) { object objComponetInfo = null; if (piCom.Name == "Self" || piCom.Name == "SelfInfo" || piCom.Name == "BasePath" || piCom.Name == "ParentFolder" || piCom.Name == "AbsoluteBasePath" || piCom.Name == "SearchTimeout" || piCom.Name == "UseCache") { continue; } if (piCom.Name.Length > 4 && piCom.Name.Substring(piCom.Name.Length - 4, 4) == "Info") { objComponetInfo = piCom.GetValue(objWindows, null); PropertyInfo rxPath = objComponetInfo.GetType().GetProperty("AbsolutePath"); RxPath componentRxPath = (RxPath)rxPath.GetValue(objComponetInfo, null); string strComponentRxPath = componentRxPath.ToString(); string strComponentType = ""; if (strComponentRxPath.LastIndexOf("[") - strComponentRxPath.LastIndexOf("/") > 0) { strComponentType = strComponentRxPath.Substring( strComponentRxPath.LastIndexOf("/") + 1, strComponentRxPath.LastIndexOf("[") - strComponentRxPath.LastIndexOf("/") - 1); } else { strComponentType = strComponentRxPath.Substring(strComponentRxPath.LastIndexOf("/") + 1, strComponentRxPath.Length - strComponentRxPath.LastIndexOf("/") - 1); } string comName = piCom.Name.Substring(0, piCom.Name.Length - 4); if (strComponentType == "button") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "text") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "InputKeys"; xSheetActions.Cells[3, iActionsCol] = "SetTextValue"; xSheetActions.Cells[4, iActionsCol] = "Exists"; xSheetActions.Cells[5, iActionsCol] = "NotExists"; xSheetActions.Cells[6, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[7, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "combobox") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Select"; xSheetActions.Cells[3, iActionsCol] = "SetTextValue"; xSheetActions.Cells[4, iActionsCol] = "Exists"; xSheetActions.Cells[5, iActionsCol] = "NotExists"; xSheetActions.Cells[6, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[7, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "treeitem") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "menuitem") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "tabpage") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "indicator") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "menubar") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "list") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "ClickItem"; xSheetActions.Cells[3, iActionsCol] = "DoubleClickItem"; xSheetActions.Cells[4, iActionsCol] = "MoveTo"; xSheetActions.Cells[5, iActionsCol] = "Exists"; xSheetActions.Cells[6, iActionsCol] = "NotExists"; xSheetActions.Cells[7, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[8, iActionsCol] = "VerifyToolTips"; xSheetActions.Cells[9, iActionsCol] = "VerifyContains"; xSheetActions.Cells[10, iActionsCol] = "VerifyNotContains"; } else if (strComponentType == "table") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "ClickItem"; xSheetActions.Cells[3, iActionsCol] = "DoubleClickItem"; xSheetActions.Cells[4, iActionsCol] = "ClickCell"; xSheetActions.Cells[5, iActionsCol] = "InputKeys"; xSheetActions.Cells[6, iActionsCol] = "MoveTo"; xSheetActions.Cells[7, iActionsCol] = "Exists"; xSheetActions.Cells[8, iActionsCol] = "NotExists"; xSheetActions.Cells[9, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[10, iActionsCol] = "VerifyToolTips"; xSheetActions.Cells[11, iActionsCol] = "VerifyContains"; xSheetActions.Cells[12, iActionsCol] = "VerifyNotContains"; xSheetActions.Cells[12, iActionsCol] = "InputCell"; } else if (strComponentType == "tree") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "ClickItem"; xSheetActions.Cells[3, iActionsCol] = "DoubleClickItem"; xSheetActions.Cells[4, iActionsCol] = "MoveTo"; xSheetActions.Cells[5, iActionsCol] = "Expand"; xSheetActions.Cells[6, iActionsCol] = "Collapse"; xSheetActions.Cells[7, iActionsCol] = "Exists"; xSheetActions.Cells[8, iActionsCol] = "NotExists"; xSheetActions.Cells[9, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[10, iActionsCol] = "VerifyToolTips"; xSheetActions.Cells[11, iActionsCol] = "VerifyContains"; xSheetActions.Cells[12, iActionsCol] = "VerifyNotContains"; } else if (strComponentType == "listitem") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "DoubleClick"; xSheetActions.Cells[3, iActionsCol] = "Exists"; xSheetActions.Cells[4, iActionsCol] = "NotExists"; xSheetActions.Cells[5, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[6, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "checkbox") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Set"; xSheetActions.Cells[3, iActionsCol] = "Clear"; xSheetActions.Cells[4, iActionsCol] = "Exists"; xSheetActions.Cells[5, iActionsCol] = "NotExists"; xSheetActions.Cells[6, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[7, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "cell") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "DoubleClick"; xSheetActions.Cells[3, iActionsCol] = "InputKeys"; xSheetActions.Cells[4, iActionsCol] = "SetTextValue"; xSheetActions.Cells[5, iActionsCol] = "CellContentClick"; xSheetActions.Cells[6, iActionsCol] = "Exists"; xSheetActions.Cells[7, iActionsCol] = "NotExists"; xSheetActions.Cells[8, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[9, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "datetime") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "InputKeys"; xSheetActions.Cells[3, iActionsCol] = "Exists"; xSheetActions.Cells[4, iActionsCol] = "NotExists"; xSheetActions.Cells[5, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[6, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "radiobutton") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "row") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "picture") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "slider") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "link") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "Exists"; xSheetActions.Cells[3, iActionsCol] = "NotExists"; xSheetActions.Cells[4, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[5, iActionsCol] = "VerifyToolTips"; } else if (strComponentType == "container") { xSheetActions.Cells[1, iActionsCol] = "Click"; xSheetActions.Cells[2, iActionsCol] = "RightClick"; xSheetActions.Cells[3, iActionsCol] = "Exists"; xSheetActions.Cells[4, iActionsCol] = "NotExists"; xSheetActions.Cells[5, iActionsCol] = "VerifyProperty"; xSheetActions.Cells[6, iActionsCol] = "VerifyToolTips"; } else { MessageBox.Show(comName.ToString() + " " + strComponentType); } Excel.Range rmgForAction = (Excel.Range)xSheetActions.Cells[1, iActionsCol]; rmgForAction.EntireColumn.Name = piLev2.Name + comName; iActionsCol++; // MessageBox.Show(comName.ToString() + " " + strComponentType); } else { opXls.writeCell(iComponentRow++, iComponentCol, piCom.Name); } } if (piLev2.Name == "FormManaged_Devices") { opXls.writeCell(iComponentRow++, iComponentCol, "Add_Device"); opXls.writeCell(iComponentRow++, iComponentCol, "Del_Device"); } iComponentRow = 1; iComponentCol++; } } opXls.writeCell(iFormRow++, 1, "Pause"); for (int iPuaseNum = 1; iPuaseNum <= 60; iPuaseNum++) { opXls.writeCell(iComponentRow++, iComponentCol, iPuaseNum.ToString()); } opXls.writeCell(iFormRow++, 1, "VerifyTxtfileValues"); opXls.writeCell(iFormRow++, 1, "VerifyExcelfileValues"); opXls.writeCell(iFormRow++, 1, "SendCommandToSimulator"); xSheet.Name = "Form DataValDepend"; xSheetActions.Name = "Action DataValDepend"; //Excel.Range rmg = (Excel.Range)xSheet.Cells[1,1]; //rmg.EntireColumn.Name = "Forms"; Excel.Range rmg = xSheetComponent.get_Range(xSheetComponent.Cells[1, 1], xSheetComponent.Cells[iFormRow, 1]); rmg.Name = "Forms"; int countRows = 1; string formName = opXls.readCell(countRows, 1); while (formName != "") { rmg = (Excel.Range)xSheet.Cells[1, countRows + 1]; rmg.Name = formName; rmg.EntireColumn.Name = formName + "Col"; formName = opXls.readCell(++countRows, 1); } Excel.Worksheet myScriptsSheet = (Excel.Worksheet)xBook.Sheets.Add(oMissing, oMissing, oMissing, oMissing); myScriptsSheet.Name = "Scripts"; Excel.Worksheet extraSheet = (Excel.Worksheet)xBook.Worksheets["Sheet3"]; extraSheet.Delete(); opXls.close(); }
//********************************************************************** /// <summary> /// Before excute, verify pre-condition. /// </summary> public void VerifyCondition() { //b_License=true, license is necessary;b_License=false, license is unnecessary; //b_Register=true, Register is necessary;b_Register=false, Register is unnecessary; //b_Device=true, many more devices are necessary;b_Device=false, many more devices are unnecessary; //b_Alarm=true, Alarm is necessary;b_Alarm=false, Alarm is unnecessary; bool b_License = getLicenseCP(); bool b_Register = getRegisterCP(); bool b_Device = getDeviceCP(); bool b_Alarm = getAlarmCP(); //Login NformRepository repo = NformRepository.Instance; repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Username.PressKeys(m_strUserName); repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Password.PressKeys(m_stPassword); repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.ServerCombo.PressKeys(m_strServerName); repo.NFormApp.LogintoLiebertNformWindow.FormLogin_to_LiebertR_Nform.Login.Click(); Delay.Milliseconds(3000); if (repo.NFormApp.LicensesWindow.FormReminder.NoInfo.Exists()) { repo.NFormApp.LicensesWindow.FormReminder.No.Click("53;10"); } if (repo.NFormApp.LogintoLiebertNformWindow.FormEvaluation_Period_Expiration.OKInfo.Exists()) { repo.NFormApp.LogintoLiebertNformWindow.FormEvaluation_Period_Expiration.OK.Click(); } //Verify the license status repo.NFormApp.NformG2Window.FormMain.Configure.Click(); repo.NFormApp.NformG2Window.FormMain.Licenses.Click(); int license_count = repo.NFormApp.LicensesWindow.FormLicenses.LicenseList.Items.Count; try { if (license_count != 0) { Validate.AreEqual(true, b_License); } else { Validate.AreEqual(false, b_License); } } catch (Exception ex) { LxLog.Info("LicenseNotReady", ex.StackTrace.ToString()); } repo.NFormApp.LicensesWindow.FormLicenses.Close.Click(); Delay.Milliseconds(1000); //Verify the Register status repo.NFormApp.NformG2Window.FormMain.Help.Click(); repo.NFormApp.NformG2Window.FormMain.About_Liebert_Nform.Click(); repo.NFormApp.Help.FormAbout_LiebertR_Nform.TabRegistration.Click(); bool unregister_flag = repo.NFormApp.Help.FormAbout_LiebertR_Nform.RegistrationDscr.TextValue.Equals("Software assurance: Unregistered"); try { if (unregister_flag == true) { Validate.AreEqual(false, b_Register); } else { Validate.AreEqual(true, b_Register); } } catch (Exception ex) { LxLog.Info("RegisterNotReady", ex.StackTrace.ToString()); } repo.NFormApp.Help.FormAbout_LiebertR_Nform.OK.Click(); Delay.Milliseconds(1000); //Verify the Device status repo.NFormApp.NformG2Window.FormMain.Configure.Click(); repo.NFormApp.NformG2Window.FormMain.Devices.Click(); int device_count = repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Managed_device_table.Rows.Count; try { if (device_count > 1) { Validate.AreEqual(true, b_Device); } else { Validate.AreEqual(false, b_Device); } } catch (Exception ex) { LxLog.Info("DeviceNotReady", ex.StackTrace.ToString()); } repo.NFormApp.ManagedDevicesWindow.FormManaged_Devices.Close.Click(); Delay.Milliseconds(1000); //Verify the Alarm status repo.NFormApp.NformG2Window.FormMain.Navigate.Click(); repo.NFormApp.NformG2Window.FormMain.Alarms.Click(); int alarm_count = repo.NFormApp.NformG2Window.FormMain.All_alarms_table.Rows.Count; try { if (alarm_count != 0) { Validate.AreEqual(true, b_Alarm); } else { Validate.AreEqual(false, b_Alarm); } } catch (Exception ex) { LxLog.Info("AlarmNotReady", ex.StackTrace.ToString()); } Delay.Milliseconds(1000); //Set Visual alert in oder to avoid input missing. repo.NFormApp.NformG2Window.FormMain.Configure.Click(); repo.NFormApp.NformG2Window.FormMain.User_Options.Click(); repo.NFormApp.UserOptionsWindow.FormUser_Options.Visual_alerts.Click(); repo.NFormApp.UserOptionsWindow.FormUser_Options.Bring_app_to_foreground.Uncheck(); repo.NFormApp.UserOptionsWindow.FormUser_Options.Bring_app_to_foreground.Check(); repo.NFormApp.UserOptionsWindow.FormUser_Options.Bring_app_to_foreground.Uncheck(); repo.NFormApp.UserOptionsWindow.FormUser_Options.OK.Click(); repo.NFormApp.NformG2Window.FormMain.Application.Click(); repo.NFormApp.NformG2Window.FormMain.Login_As.Click(); Delay.Milliseconds(1000); }