//internal Window FindChildWindow(string v1) //{ // int iCount = 0; // while (iCount < 100) // { // WinTree winTree = GetWindowTree(); // IntPtr hWnd = winTree.Find(v1); // if (hWnd != IntPtr.Zero) // { // Window findWindow = (Window)Activator.CreateInstance(typeof(Window), hWnd, v1); // Log.INFO(string.Format("Finded chid Window:[{0},{1}], in process:[{2}]", findWindow._name, findWindow._hWnd.ToString("X8"), _process.Id)); // return findWindow; // } // iCount++; // Thread.Sleep(200); // } // throw new ArgumentException(string.Format("can not find child window:[{0}], in process:[{1}]", v1, _process.Id)); //} internal void FindChildWindow(string v1, Action <Window> actionNomarl, string v2, Action <Window> actionException) { int iCount = 0; while (iCount < 100) { WinTree winTree = GetWindowTree(); IntPtr hWnd = winTree.Find(v2); if (hWnd != IntPtr.Zero && WinAPI.IsWindowEnabled(hWnd)) { Window findWindow = (Window)Activator.CreateInstance(typeof(Window), hWnd, v2); Log.INFO(string.Format("Finded chid Window:[{0},{1}], in process:[{2}]", findWindow._name, findWindow._hWnd.ToString("X8"), _process.Id)); actionException(findWindow); return; } hWnd = winTree.Find(v1); if (hWnd != IntPtr.Zero && WinAPI.IsWindowEnabled(hWnd)) { Window findWindow = (Window)Activator.CreateInstance(typeof(Window), hWnd, v1); Log.INFO(string.Format("Finded chid Window:[{0},{1}], in process:[{2}]", findWindow._name, findWindow._hWnd.ToString("X8"), _process.Id)); actionNomarl(findWindow); return; } iCount++; Thread.Sleep(200); } throw new ArgumentException(string.Format("can not find child window:[{0}], in process:[{1}]", v1 + "," + v2, _process.Id)); }
private static WinTree GetWinTree(string uiTitle, string uiType) { var htmlcontrolWin = new WinTree(Window.Locate(uiTitle, uiType)); var htmlControlWin = htmlcontrolWin; htmlControlWin.TechnologyName = TechnologyNameWin; return(htmlControlWin); }
/// <summary> /// Tells if a TreeView is empty or not. /// </summary> /// <exception cref="ArgumentNullException">tree</exception> public static bool IsEmpty(this WinTree tree) { if (tree == null) { throw new ArgumentNullException("tree"); } return(tree.Nodes.Count == 0); }
public Window FindWindow(Selector selector, int waitsecond = 90) { try { Window findWindow = null; WaitUntil((String findName) => { WinTree tree = GetWindowTree(); IntPtr exceptHwnd = tree.Find((IntPtr currhwnd) => { string str = WinAPI.GetWindowText(currhwnd); if (str.ToLower().Contains("fail") || str.ToLower().Contains("warn") || str.ToLower().Contains("not able")) { if (selector.IsTrue(currhwnd)) { return(false); } return(true); } return(false); }); if (exceptHwnd != IntPtr.Zero) { throw new Exception("get error report: " + WinAPI.GetWindowText(exceptHwnd)); } IntPtr hwnd = tree.Find((IntPtr currhwnd) => { return(selector.IsTrue(currhwnd)); }); if (hwnd == IntPtr.Zero) { return(false); } findWindow = (Window)Activator.CreateInstance(typeof(Window), hwnd, WinAPI.GetWindowText(hwnd)); return(true); }, "", waitsecond); Log.INFO(string.Format("Finded Winow:[{0},{1}], in PID:[{2}]", findWindow._name, findWindow.hwnd.ToString("X8"), _process.Id.ToString("X8"))); return(findWindow); } catch (TimeoutException e) { throw new ArgumentException(string.Format(" can not find window:[{0}] in PID:[{1}]", selector.desc(), _process.Id.ToString("X8"))); } }
/// <summary> /// FocusConfigurationManager /// </summary> public void FocusConfigurationManager() { #region Variable Declarations WinTreeItem uIEncoderTreeItem = this.UISmartViewConfiguratiWindow.UIItemWindow.UIItemTree.UILineTreeItem.UIStationTreeItem.UIEncoderTreeItem; WinTree uIItemTree = this.UISmartViewConfiguratiWindow.UIItemWindow.UIItemTree; WinClient uIWorkspaceClient = this.UISmartViewConfiguratiWindow.UIItemWindow1.UIWorkspaceClient; #endregion // Click 'Line' -> 'Station' -> 'Encoder' tree item Mouse.Click(uIEncoderTreeItem, new Point(135, 14)); // Click 'Unknown Name' tree Mouse.Click(uIItemTree, new Point(229, 435)); // Click 'Workspace' client Mouse.Click(uIWorkspaceClient, new Point(411, 465)); }
public WinTree Find(IntPtr hWnd) { if (this.hWnd == hWnd) { return(this); } foreach (WinTree tree in subWin) { WinTree find = tree.Find(hWnd); if (find != null) { return(find); } } return(null); }
public void CheckFeaturesExpectedResult() { this.treeName = "tVFeatures"; #region Variable Declarations WinComboBox uICBConversationsComboBox = this.UIONVIFClientTestToolWindow.UICBConversationsWindow.UICBConversationsComboBox; WinEdit uITBOutputEdit = this.UIONVIFClientTestToolWindow.UITBOutputWindow.UITBOutputEdit; WinTree uITVTestCasesTree = this.UIONVIFClientTestToolWindow.UITVTestCasesWindow.UITVTestCasesTree; WinTabPage uIFeaturesTabPage = this.UIONVIFClientTestToolWindow.UITCModesWindow.UIFeaturesTabPage; WinList uILVStepsList = this.UIONVIFClientTestToolWindow.UILVStepsWindow.UILVStepsList; #endregion if (test.featuresExpectedResult != null) { // Щелкните "Features" вкладка uIFeaturesTabPage.WaitForControlReady(); Mouse.Click(uIFeaturesTabPage); foreach (var featureExpectedResult in test.featuresExpectedResult) { mTree0 = featureExpectedResult.Key; this.mTreeItem = this.UIONVIFClientTestToolWindow.UITVTestCasesWindow.UIProfileSTestCasesTreeItem; //this.mTreeItem.(); mTreeItem.WaitForControlReady(); Mouse.Click(this.mTreeItem, new Point(0, 0)); Mouse.Hover(this.mTreeItem, new Point(this.mTreeItem.Width / 2, this.mTreeItem.Height / 2)); LogData logDataFeature = new LogData(); logDataFeature.testPath = testPath; logDataFeature.currentResult = featureExpectedResult.Key + " " + this.mTreeItem.ToolTipText; logDataFeature.expectedResult = featureExpectedResult.Key + " " + featureExpectedResult.Value; if (logDataFeature.currentResult == logDataFeature.expectedResult) { logDataFeature.result = "PASSED"; } else { logDataFeature.result = "FAILED"; } this.logDataFeatures.Add(logDataFeature); } } }
public WinTree GetWindowTree() { List <IntPtr> listWinHwnd = new List <IntPtr>(); WinAPI.EnumWindows(new WinAPI.EnumWindowsProc((hWnd, lParam) => { uint pid = 0; WinAPI.GetWindowThreadProcessId(hWnd, out pid); if (pid == _process.Id) { listWinHwnd.Add(hWnd); } return(true); }), (IntPtr)0); WinTree root = new WinTree(IntPtr.Zero); foreach (IntPtr hWnd in listWinHwnd) { root.subWin.Add(new WinTree(hWnd)); WinAPI.EnumChildWindows(hWnd, new WinAPI.EnumWindowsProc((hChildWnd, lParam) => { IntPtr parenthWind = WinAPI.GetParent(hChildWnd); root.Find(parenthWind).subWin.Add(new WinTree(hChildWnd)); return(true); }), 0); } return(root); }
public WinTree GetTreeView(string List) { WinTree TreeViewToUse = new WinTree(); if (List == "WellGrouping") { WinTree LTreeView = new WinTree(GetItemWellGrouping()); LTreeView.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch); LTreeView.SearchProperties.Add(WinTree.PropertyNames.ClassName, "SysTreeView32"); TreeViewToUse = LTreeView; } else if (List == "WellConditions") { WinTree LTreeView = new WinTree(GetItemWindowWellConditions()); LTreeView.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch); LTreeView.SearchProperties.Add(WinTree.PropertyNames.ClassName, "SysTreeView32"); TreeViewToUse = LTreeView; } return TreeViewToUse; }
public void CheckExpectedResult() { this.treeName = "tVTestCases"; #region Variable Declarations WinComboBox uICBConversationsComboBox = this.UIONVIFClientTestToolWindow.UICBConversationsWindow.UICBConversationsComboBox; WinEdit uITBOutputEdit = this.UIONVIFClientTestToolWindow.UITBOutputWindow.UITBOutputEdit; WinTree uITVTestCasesTree = this.UIONVIFClientTestToolWindow.UITVTestCasesWindow.UITVTestCasesTree; WinTabPage uITestDetailsTabPage = this.UIONVIFClientTestToolWindow.UITCLogWindow.UITestDetailsTabPage; WinList uILVStepsList = this.UIONVIFClientTestToolWindow.UILVStepsWindow.UILVStepsList; #endregion if (test.expectedResults != null) { // Щелкните "Test Details" вкладка uITestDetailsTabPage.WaitForControlReady(); Mouse.Click(uITestDetailsTabPage); foreach (DeviceExpectedResult device in test.expectedResults) { this.mac = device.deviceMAC; foreach (ExpectedResult result in device.expectedResults) { foreach (string s in result.expectedResult.Keys) { mTree0 = result.parentNode0; mTree1 = result.parentNode1; mTree2 = s; this.mTreeItem = this.UIONVIFClientTestToolWindow.UITVTestCasesWindow.UIProfileSTestCasesTreeItem.UIMediaProfileConfigurTreeItem.UIMEDIAPROFILECONFIGURTreeItem1; bool currentResultNotStarted = false; // Щелкните по элементу дерева this.mTreeItem.WaitForControlExist(); Mouse.Click(this.mTreeItem); LogData logData = new LogData(); if (uICBConversationsComboBox.Items.Count != 0) { // выбрать элемент в списке устройств uICBConversationsComboBox.SelectedItem = this.macAndDevice["deviceName"] + " - " + this.macAndDevice[this.mac]; foreach (WinListItem item in uILVStepsList.Items) { TestStep testStep = new TestStep(); testStep.results = item.AccessibleDescription; logData.testSteps.Add(testStep); } } else { currentResultNotStarted = true; } if (currentResultNotStarted) { logData.currentResult = s + " NOT STARTED"; } else { if (logData.testSteps.Count == 0) { logData.currentResult = s + " NOT DETECTED"; } else { if (logData.testSteps.FindAll(C => C.results.Contains("NOT DETECTED")).Count != 0) { logData.currentResult = s + " NOT DETECTED"; } else { if (logData.testSteps.FindAll(C => C.results.Contains("FAILED")).Count != 0) { logData.currentResult = s + " FAILED"; } else { logData.currentResult = s + " PASSED"; } } } } logData.expectedResult = s + " " + result.expectedResult[s]; if (logData.currentResult == logData.expectedResult) { logData.result = "PASSED"; } else { logData.result = "FAILED"; } logData.testPath = this.testPath; logData.deviceMAC = this.mac; this.logData.Add(logData); } } } } }