private bool FindProcessWindowTitle(Process p, string waitForWindowTilte)//no need to get all windows. { TreeWalker walker = TreeWalker.ControlViewWalker; AutomationElement window = walker.GetFirstChild(AutomationElement.RootElement); UIAComWrapperHelper uiHelper = new UIAComWrapperHelper(); while (window != null) { if (window.Current.ProcessId == p.Id) { String WindowTitle = ""; WindowTitle = uiHelper.GetWindowInfo(window); if (!string.IsNullOrEmpty(WindowTitle)) { if (WindowTitle.ToLower().Contains(waitForWindowTilte.ToLower())) { return(true); } } } try { window = walker.GetNextSibling(window); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Exception in FindProcessWindowTitle", ex); } } return(false); }
AutomationElement GetWindow(string LocValCal) //******* { UIAComWrapperHelper UIA = new UIAComWrapperHelper(); List <object> AppWindows = UIA.GetListOfWindows(); foreach (AutomationElement window in AppWindows) { string WindowTitle = UIA.GetWindowInfo(window); if (WindowTitle == null) { WindowTitle = ""; } Reporter.ToLog(eLogLevel.DEBUG, $"Method - {MethodBase.GetCurrentMethod().Name}, WindowTitle - {WindowTitle}"); switch (LocateBy) { case eLocateBy.ByTitle: if (WindowTitle.Contains(LocValCal)) { return(window); } break; case eLocateBy.ByClassName: if (window.Current.ClassName.Equals(LocValCal)) { return(window); } break; } } return(null); }
public override void StartDriver() { switch (LibraryType) { case eUIALibraryType.ComWrapper: mUIAutomationHelper = new UIAComWrapperHelper(); ((UIAComWrapperHelper)mUIAutomationHelper).WindowExplorer = this; ((UIAComWrapperHelper)mUIAutomationHelper).BusinessFlow = BusinessFlow; ((UIAComWrapperHelper)mUIAutomationHelper).mPlatform = UIAComWrapperHelper.ePlatform.PowerBuilder; break; } }
public override void StartDriver() { switch (LibraryType) { case eUIALibraryType.ComWrapper: mUIAutomationHelper = new UIAComWrapperHelper(); ((UIAComWrapperHelper)mUIAutomationHelper).WindowExplorer = this; ((UIAComWrapperHelper)mUIAutomationHelper).BusinessFlow = BusinessFlow; ((UIAComWrapperHelper)mUIAutomationHelper).mPlatform = UIAComWrapperHelper.ePlatform.Windows; break; case eUIALibraryType.FlaUI: //mUIAutomationHelper= new FlaUIHelper(); //((FlaUIHelper)mUIAutomationHelper).WindowExplorer = this; //((FlaUIHelper)mUIAutomationHelper).BusinessFlow = BusinessFlow; //((FlaUIHelper)mUIAutomationHelper).mPlatform = UIAutomationHelperBase.ePlatform.Windows; break; } }
void RefreshActiveProcessesTitles() { UIAComWrapperHelper uiHelper = new UIAComWrapperHelper(); uiHelper.mPlatform = GingerCoreNET.SolutionRepositoryLib.RepositoryObjectsLib.PlatformsLib.ePlatformType.Windows; List <object> lstAppWindow = uiHelper.GetListOfWindows(); ActiveProcessWindowsList.Clear(); lstWindows.Clear(); foreach (AutomationElement process in lstAppWindow) { // If the process appears on the Taskbar (if has a title) // print the information of the process if (!String.IsNullOrEmpty(process.Current.Name)) { ActiveProcessWindowsList.Add(process.Current.Name); lstWindows.Add(process); } } }
public void TestInitialize() { mGR = new GingerRunner(); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF UIAAutomationTest"; Platform p = new Platform(); p.PlatformType = ePlatformType.Windows; mBF.Platforms = new ObservableList <Platform>(); mBF.Platforms.Add(p); mBF.TargetApplications.Add(new TargetApplication() { AppName = "PBTestAPP" }); Activity activity = new Activity(); activity.TargetApplication = "PBTestApp"; mBF.Activities.Add(activity); mBF.CurrentActivity = activity; mDriver = new WindowsDriver(mBF); mDriver.StartDriver(); UIA = (UIAComWrapperHelper)mDriver.mUIAutomationHelper; mXPathHelper = ((IXPath)UIA).GetXPathHelper(); //TODO: launch Win Forms Test App uiaForm.Show(); List <object> list = UIA.GetListOfWindows(); UIA.SwitchToWindow("FormEmbeddedBrowser"); AppWindow = (AutomationElement)UIA.GetCurrentWindow(); }