/// <summary> /// The is function opened. /// </summary> /// <param name="functionName"> /// The function name. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static Text IsFunctionOpened(string functionName) { Log.Enter(typeof(DeviceCareModuleFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; IList <Text> tabPageTextList; tabPageTextList = Host.Local.Find <Text>(repo.ApplicationArea.ModuleSelection.ModuleTabPagesTextInfo.AbsolutePath); if (tabPageTextList != null) { if (tabPageTextList.Count > 0) { foreach (var text in tabPageTextList) { if (text.TextValue.Equals(functionName)) { return(text); } } } return(null); } return(null); }
/// <summary> /// The wait until status message becomes available. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool WaitUntilStatusMessageBecomesAvailable() { Logging.Enter(typeof(ProgressIndicator), MethodBase.GetCurrentMethod().Name); try { DeviceCareApplication repo = DeviceCareApplication.Instance; repo.StatusArea.ProgressIndicatorInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); Reporting.Debug("Progress Indicator is available."); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (stopwatch.ElapsedMilliseconds < Common.DefaultValues.GeneralTimeout) { if (IsStatusMessageAvailable()) { repo.StatusArea.ProgressIndicator.MoveTo(); Reporting.Debug("Status Message is available."); return(true); } } Reporting.Error(string.Format("Status Message is not available after {0} miliseconds.", Common.DefaultValues.GeneralTimeout)); return(false); } catch (Exception exception) { Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The get number of open tab pages. /// </summary> /// <returns> /// The <see cref="int"/>. /// </returns> public static bool CheckIfOpenCloseModuleHelperIsNeccessary() { Container container; DeviceCareApplication repo = DeviceCareApplication.Instance; RepoItemInfo repoItemInfo = repo.ApplicationArea.ModuleTabPagesInfo; Host.Local.TryFindSingle(repoItemInfo.AbsolutePath, out container); if (container != null) { if (container.Children.Count == 1) { if (container.Children[0].Children.Count == 0) { Report.Info("Open another module as work around to ensure closing of module."); return(true); } return(false); } return(false); } Report.Failure("There is no open module available."); return(false); }
/// <summary> /// The open program functions. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenMenu() { Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; MenuItem menuItem; bool result; Host.Local.TryFindSingle(repo.MenuArea.MainMenu.DTMFunctionsInfo.AbsolutePath, out menuItem); if (menuItem != null && menuItem.Visible) { menuItem.Click(); Reporting.Debug("Menu item DTM Functions found and clicked."); if (Validation.DtmFunctions.IsMenuItemAvailable()) { result = true; } else { result = false; } } else { Reporting.Error("Could not access menu DTM Functions."); result = false; } return(result); }
/// <summary> /// The device report. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenMenuDeviceReport() { DeviceCareApplication repo = DeviceCareApplication.Instance; RepoItemInfo repoItemInfo = repo.MenuArea.MainMenu.DeviceReportInfo; return(OpenMenuItem(GetMenuItem(repoItemInfo))); }
/// <summary> /// The open program functions. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenMenuProgramFunctions() { DeviceCareApplication repo = DeviceCareApplication.Instance; RepoItemInfo repoItemInfo = repo.MenuArea.MainMenu.ProgramFunctionsInfo; return(OpenMenuItem(GetMenuItem(repoItemInfo))); }
/// <summary> /// The open submenu online parameterize. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenSubmenuOnlineParameterize() { if (OpenMenuDtmFunctions()) { DeviceCareApplication repo = DeviceCareApplication.Instance; RepoItemInfo repoItemInfo = repo.MenuArea.MainMenu.DTMFunctionMenuItems.OnlineParameterizationInfo; return(OpenMenuItem(GetMenuItem(repoItemInfo))); } return(false); }
/// <summary> /// The open submenu write to device. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenSubmenuWriteToDevice() { if (OpenMenuProgramFunctions()) { DeviceCareApplication repo = DeviceCareApplication.Instance; RepoItemInfo repoItemInfo = repo.MenuArea.MainMenu.ProgramFunctionsMenuItems.WriteToDeviceInfo; return(OpenMenuItem(GetMenuItem(repoItemInfo))); } return(false); }
/// <summary> /// The is progress indicator visible. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> private static bool IsProgressIndicatorVisible() { Logging.Enter(typeof(ProgressIndicator), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; if (repo.StatusArea.ProgressIndicator.Visible) { return(true); } return(false); }
/// <summary> /// The show progress. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static string OpenShowProgress() { Logging.Enter(typeof(ProgramFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; if (RunAdditionalFunctions()) { repo.MenuArea.MainMenu.ProgramFunctionsMenuItems.ShowProgressInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); MenuItem showProgress; Host.Local.TryFindSingle(repo.MenuArea.MainMenu.ProgramFunctionsMenuItems.ShowProgressInfo.AbsolutePath, out showProgress); IList <TabPage> tabPagesBefore = Host.Local.Find <TabPage>(repo.ApplicationArea.ModuleSelection.ModuleTabPagesInfo.AbsolutePath); if (showProgress != null && showProgress.Visible) { showProgress.Click(); Reporting.Debug("Menu item Show Progress found and clicked."); IList <TabPage> tabPagesAfter = Host.Local.Find <TabPage>(repo.ApplicationArea.ModuleSelection.ModuleTabPagesInfo.AbsolutePath); foreach (var tabPageAfter in tabPagesAfter) { Text textAfter = tabPageAfter.FindSingle("text"); if (textAfter != null) { string textValueAfter = textAfter.Element.GetAttributeValueText("caption"); if (textValueAfter != null) { foreach (var tabPageBefore in tabPagesBefore) { Text textBefore = tabPageBefore.FindSingle("text"); if (textBefore != null) { string textValueBefore = textBefore.Element.GetAttributeValueText("caption"); if (textValueBefore != null) { if (!textValueBefore.Equals(textValueAfter)) { Reporting.Debug(string.Format("Name of currently opened function is {0}", textValueAfter)); return(textValueAfter); } } } } } } } } } Reporting.Error("Could not access menu item Show Progress."); return(string.Empty); }
/// <summary> /// The close module. /// </summary> /// <param name="moduleToClose"> /// The module to close. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool CloseModule(string moduleToClose) { int numberOfOpenModules = GetNumberOfOpenModules(); if (IsModuleOpen(moduleToClose)) { if (CheckIfOpenCloseModuleHelperIsNeccessary()) { if (!OpenCloseHelper()) { Report.Failure("Button to close is not available: ", moduleToClose); return(false); } } DeviceCareApplication repo = DeviceCareApplication.Instance; RepoItemInfo repoItemInfo = repo.ApplicationArea.ModuleCloseButtonInfo; string modifiedPath = repoItemInfo.AbsolutePath.ToString().Replace("MODULENAME", moduleToClose); Button button; if (Host.Local.TryFindSingle(modifiedPath, 5000, out button)) { if (button != null) { button.Click(); Report.Info("Module is going to be closed: ", moduleToClose); var watch = new Stopwatch(); watch.Start(); // Wait until tabpage has decreased by one while (GetNumberOfOpenModules() != numberOfOpenModules - 1) { if (watch.ElapsedMilliseconds <= Common.DefaultValues.GeneralTimeout) { continue; } Report.Failure("Module is not closed within time", moduleToClose + "(" + watch.ElapsedMilliseconds + "/" + Common.DefaultValues.GeneralTimeout + ")"); return(false); } watch.Stop(); Report.Info("Module is closed within time", moduleToClose + "(" + watch.ElapsedMilliseconds + "/" + Common.DefaultValues.GeneralTimeout + ")"); return(true); } } Report.Failure("Button to close is not available: ", moduleToClose); return(false); } Report.Failure("Module is not open and there fore cannot be closed: ", moduleToClose); return(false); }
/// <summary> /// The is device connected. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsDeviceConnected() { Logging.Enter(typeof(Connection), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; if (!repo.StatusArea.ConnectionIndicatorInfo.Exists()) { Reporting.Debug("There is no device connected."); return(false); } Reporting.Debug("A device is connected."); return(true); }
/// <summary> /// The get number of open modules. /// </summary> /// <returns> /// The <see cref="int"/>. /// </returns> private static int GetNumberOfOpenModules() { Container container; DeviceCareApplication repo = DeviceCareApplication.Instance; RepoItemInfo repoItemInfo = repo.ApplicationArea.ModuleTabPagesInfo; Host.Local.TryFindSingle(repoItemInfo.AbsolutePath, out container); if (container != null) { return(container.Children.Count); } Report.Failure("There is no module at a tabpage available"); return(-1); }
/// <summary> /// The create automatically. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool CreateAutomatically() { Log.Enter(typeof(Project), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; if (repo.ApplicationArea.ConnectionSelection.ButtonConnectionAutomaticInfo.Exists()) { Common.Tools.Log.Debug("Create Project automatically."); repo.ApplicationArea.ConnectionSelection.ButtonConnectionAutomatic.Click(); return(true); } Common.Tools.Log.Debug("Create Project automatically failed."); return(false); }
///// <summary> ///// The wait until status message becomes not available. ///// </summary> ///// <returns> ///// The <see cref="bool"/>. ///// </returns> //public static bool WaitUntilStatusMessageBecomesNotAvailable() //{ // Logging.Enter(typeof(ProgressIndicator), MethodBase.GetCurrentMethod().Name); // try // { // Stopwatch stopwatch = new Stopwatch(); // stopwatch.Start(); // Reporting.Debug("Wait until Message becomes not visible."); // while (stopwatch.ElapsedMilliseconds < Common.DefaultValues.GeneralTimeout) // { // if (!IsProgressIndicatorVisible()) // { // Reporting.Debug("Progress Indicator is not visible."); // return true; // } // } // Reporting.Error(string.Format("Progress Indicator is still visible after {0} miliseconds.", Common.DefaultValues.GeneralTimeout)); // return false; // } // catch (Exception exception) // { // Reporting.Error(exception.Message); // return false; // } //} /// <summary> /// The is progress indicator visible. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> private static bool IsStatusMessageAvailable() { Logging.Enter(typeof(ProgressIndicator), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; if (repo.StatusArea.StatusBarTextInfo.Exists()) { if (repo.StatusArea.StatusBarText.ScreenRectangle.Height > 0 && repo.StatusArea.StatusBarText.ScreenRectangle.Width > 0) { return(true); } return(false); } return(false); }
/// <summary> /// The run. /// </summary> /// <param name="moduleToOpen"> /// The module to open. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Run(string moduleToOpen) { DeviceCareApplication deviceCareApplication = DeviceCareApplication.Instance; RepoItemInfo repo = deviceCareApplication.MenuArea.MainMenu.AdditionalFunctionMenuItems.MenuItemInfo; string modifiedPath = repo.AbsolutePath.ToString().Replace("MODULENAME", moduleToOpen); MenuItem menuItem; Host.Local.TryFindSingle((RxPath)modifiedPath, 5000, out menuItem); if (menuItem != null && menuItem.Visible) { menuItem.Click(); return(true); } return(false); }
/// <summary> /// The create automatically. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenEventLog() { Logging.Enter(typeof(EventLog), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = new DeviceCareApplication(); if (!repo.StatusArea.StatusBarInfo.Exists()) { Reporting.Error("Element Status Bar is not available. Event Log cannot be opened."); return(false); } Reporting.Debug("Status Bar is available."); Reporting.Debug("Open Event Log Dialog"); repo.StatusArea.StatusBar.Click(); return(true); }
/// <summary> /// The get number of open modules. /// </summary> /// <returns> /// The <see cref="int"/>. /// </returns> public int GetNumberOfOpenModules() { try { DeviceCareApplication deviceCareApplication = DeviceCareApplication.Instance; RepoItemInfo repo = deviceCareApplication.ApplicationArea.ModuleSelection.TabCloseButtonInfo; System.Collections.Generic.IList <TabPage> tabPages; tabPages = Host.Local.Find <TabPage>(repo.AbsolutePath); return(tabPages.Count); } catch (Exception) { return(0); } }
/// <summary> /// The open program functions. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool CloseHostApplication() { Log.Enter(typeof(HostApplication), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; Button button; Host.Local.TryFindSingle(repo.MenuArea.MainMenu.MainMenuItems.ButtonExitInfo.AbsolutePath, out button); if (button != null && button.Visible) { button.Click(); Common.Tools.Log.Debug("Button found and clicked."); return(true); } return(false); }
/// <summary> /// The create by assistant. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool CloseEventLog() { Logging.Enter(typeof(EventLog), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; if (!repo.Dialog.EventLog.CloseInfo.Exists()) { Reporting.Error("Button Close is not available. Event Log cannot be closed."); return(false); } Reporting.Debug("Button Close is available."); Reporting.Debug("Close Event Log Dialog"); repo.Dialog.EventLog.Close.Click(); return(true); }
/// <summary> /// The is menu item available. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsMenuItemAvailable() { Logging.Enter(typeof(DtmFunctions), MethodBase.GetCurrentMethod().Name); try { DeviceCareApplication repo = DeviceCareApplication.Instance; repo.MenuArea.MainMenu.DTMFunctionMenuItems.OnlineParameterizationInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); Reporting.Debug("Menu Items of menu DTM Function are available."); return(true); } catch (Exception exception) { Reporting.Error("Menu Items of menu DTM Function are not available."); Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The open close helper module. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> private static bool OpenCloseHelper() { const string ModuleNameOnlineParameterize = "Online Paramterize"; const string ModuleNameAbout = "About"; string moduleToOpen; bool isModuleOpen = IsModuleOpen(ModuleNameAbout); if (isModuleOpen) { Report.Info("Open second module as workaround: ", ModuleNameOnlineParameterize); OpenSubmenuOnlineParameterize(); } else { Report.Info("Open second module as workaround: ", ModuleNameAbout); OpenSpecificAdditionalModule(ModuleNameAbout); } DeviceCareApplication repo = DeviceCareApplication.Instance; RepoItemInfo repoItemInfo = repo.ApplicationArea.ModuleCloseButtonInfo; if (isModuleOpen) { moduleToOpen = ModuleNameAbout; } else { moduleToOpen = ModuleNameOnlineParameterize; } string modifiedPath = repoItemInfo.AbsolutePath.ToString().Replace("MODULENAME", moduleToOpen); Button button; if (Host.Local.TryFindSingle(modifiedPath, 5000, out button)) { if (button != null) { button.Click(); return(true); } } return(false); }
/// <summary> /// The create automatically. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsEventLogClosed() { try { Logging.Enter(typeof(EventLog), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = new DeviceCareApplication(); repo.Dialog.EventLog.CloseInfo.WaitForNotExists(Common.DefaultValues.GeneralTimeout); Reporting.Debug("Event Log Dialog is not available."); return(true); } catch (Exception exception) { Reporting.Error("Event Log Dialog is still available."); Reporting.Error(exception.Message); return(false); } }
/// <summary> /// The open program functions. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenMenu() { Log.Enter(typeof(AdditionalFunctions), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; MenuItem menuItem; Host.Local.TryFindSingle(repo.MenuArea.MainMenu.AdditionalFunctionsInfo.AbsolutePath, out menuItem); if (menuItem != null && menuItem.Visible) { menuItem.Click(); Common.Tools.Log.Debug("Menu item Additional Functions found and clicked."); return(true); } Common.Tools.Log.Error("Could not access menu Additional Functions."); return(false); }
/// <summary> /// The run. /// </summary> /// <param name="moduleToOpen"> /// The module to open. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Run(string moduleToOpen) { DeviceCareApplication deviceCareApplication = DeviceCareApplication.Instance; RepoItemInfo repo = deviceCareApplication.ApplicationArea.ModuleSelection.TabCloseButtonInfo; string modifiedPath = repo.AbsolutePath.ToString().Replace("MODULENAME", moduleToOpen); Button button; Host.Local.TryFindSingle(modifiedPath, DefaultValues.GeneralTimeout, out button); if (button != null) { button.Focus(); button.Click(); return(true); } return(false); }
/// <summary> /// The open fdt defined function. /// </summary> /// <param name="moduleToOpen"> /// The module to open. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool OpenFdtDefinedFunction(string moduleToOpen) { DeviceCareApplication repo1 = DeviceCareApplication.Instance; RepoItemInfo repoItemInfo = repo1.MenuArea.MainMenu.DTMFunctionsInfo; if (OpenMenuItem(GetMenuItem(repoItemInfo))) { DeviceCareApplication deviceCareApplication = DeviceCareApplication.Instance; RepoItemInfo repo = deviceCareApplication.MenuArea.MainMenu.AdditionalFunctionMenuItems.MenuItemInfo; string modifiedPath = repo.AbsolutePath.ToString().Replace("MODULENAME", moduleToOpen); Text text; Host.Local.TryFindSingle(modifiedPath, 5000, out text); if (text != null && text.Enabled) { text.Click(); var watch = new Stopwatch(); watch.Start(); // Wait until module is visible at tabpage while (IsModuleOpen(moduleToOpen) == false) { if (watch.ElapsedMilliseconds <= Common.DefaultValues.GeneralTimeout) { continue; } Report.Failure("Module is not opend within time", moduleToOpen + "(" + watch.ElapsedMilliseconds + "/" + Common.DefaultValues.GeneralTimeout + ")"); return(false); } watch.Stop(); Report.Info("Module opened within time", moduleToOpen + "(" + watch.ElapsedMilliseconds + "/" + Common.DefaultValues.GeneralTimeout + ")"); return(true); } Report.Failure("Module entry is not available or enabled", moduleToOpen); return(false); } Report.Failure("Menu entry for module is not available", moduleToOpen); return(false); }
/// <summary> /// The open program functions. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool IsMenuAvailable() { Logging.Enter(typeof(DeviceReport), MethodBase.GetCurrentMethod().Name); DeviceCareApplication repo = DeviceCareApplication.Instance; repo.MenuArea.MainMenu.DeviceReportInfo.WaitForExists(Common.DefaultValues.GeneralTimeout); if (repo.MenuArea.MainMenu.DeviceReportInfo.Exists()) { if (repo.MenuArea.MainMenu.DeviceReport != null && repo.MenuArea.MainMenu.DeviceReport.Visible) { Reporting.Debug("Menu item Device Report is available."); return(true); } } Reporting.Debug("Menu item Device Report is not available."); return(false); }
/// <summary> /// Validates if the desired function tab is displayed /// </summary> /// <param name="moduleName"> /// The module Name. /// </param> /// <returns> /// True if the tab is shown /// </returns> public bool IsTabOpen(string moduleName) { Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Checking if the function tab is open..."); DeviceCareApplication deviceCareApplication = DeviceCareApplication.Instance; RepoItemInfo repo = deviceCareApplication.ApplicationArea.ModuleSelection.TabCloseButtonInfo; string modifiedPath = repo.AbsolutePath.ToString().Replace("MODULENAME", moduleName); Button button; Host.Local.TryFindSingle((RxPath)modifiedPath, DefaultValues.GeneralTimeout, out button); if (button != null) { return(true); } Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "The desired function tab is not open"); return(false); }
/// <summary> /// The get all messages from event log. /// </summary> /// <returns> /// The <see cref="List{T}"/>. /// </returns> public static List <string> GetAllMessagesFromEventLog() { Logging.Enter(typeof(EventLog), MethodBase.GetCurrentMethod().Name); List <string> messages = new List <string>(); DeviceCareApplication repo = new DeviceCareApplication(); if (Validation.EventLog.IsEventLogTableAvailable()) { IList <Ranorex.Row> rows = repo.Dialog.EventLog.Table.Rows; Reporting.Debug("Scan Event Log Table for messages"); foreach (var row in rows) { messages.Add(row.Cells[2].Text); } } return(messages); }
/// <summary> /// The open dtm function. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool SaveDeviceReport() { Logging.Enter(typeof(DeviceReport), MethodBase.GetCurrentMethod().Name); if (OpenMenu()) { DeviceCareApplication repo = DeviceCareApplication.Instance; MenuItem menuItem; Host.Local.TryFindSingle(repo.MenuArea.MainMenu.DeviceReportMenuItems.SaveDeviceReportInfo.AbsolutePath, out menuItem); if (menuItem != null && menuItem.Visible) { menuItem.Click(); Reporting.Debug("Menu item Save Device Report found and clicked."); return(true); } } Reporting.Error("Could not access menu item Save Device Report."); return(false); }