Пример #1
0
        /// <summary>
        /// Gets all top level windows from the application.
        /// </summary>
        public Window[] GetAllTopLevelWindows(AutomationBase automation)
        {
            var desktop       = automation.GetDesktop();
            var foundElements = desktop.FindAllChildren(cf => cf.ByControlType(ControlType.Window).And(cf.ByProcessId(ProcessId)));

            return(foundElements.Select(x => x.AsWindow()).ToArray());
        }
Пример #2
0
        private Window GetMainWindow(AutomationBase automation, TimeSpan?waitTimeout, string pathToConfigFile)
        {
            WaitWhileMainHandleIsMissing(waitTimeout);
            var mainWindowHandle = MainWindowHandle;

            if (mainWindowHandle == IntPtr.Zero)
            {
                return(null);
            }

            SHSpinWait.SpinUntil(() => automation.FromHandle(mainWindowHandle) != null, waitTimeout.HasValue ? waitTimeout.Value : TimeSpan.FromMinutes(5));

            var mainWindow = automation.FromHandle(mainWindowHandle)
                             .AsWindow(_loggingService, pathToConfigFile);

            if (mainWindow != null)
            {
                mainWindow.IsMainWindow = true;
            }
            else
            {
                throw new InvalidOperationException("mainWindow is null");
            }
            return(mainWindow);
        }
Пример #3
0
 /// <summary>
 /// Create a framework automation element with the given <see cref="AutomationBase"/>.
 /// </summary>
 /// <param name="automation">The <see cref="AutomationBase"/>.</param>
 protected FrameworkAutomationElementBase(AutomationBase automation)
 {
     Automation = automation;
 }
Пример #4
0
 /// <summary>
 /// Gets the main window of the application's process.
 /// </summary>
 /// <param name="automation">The automation object to use.</param>
 /// <param name="pathToConfigFile">Path to SHAutomtion.json</param>
 public Window GetMainWindow(AutomationBase automation, string pathToConfigFile)
 {
     return(GetMainWindow(automation, null, pathToConfigFile));
 }
Пример #5
0
 /// <summary>
 /// Gets the main window of the application's process.
 /// </summary>
 /// <param name="automation">The automation object to use.</param>
 /// <param name="waitTimeout">An optional timeout. If null is passed, the timeout is infinite.</param>
 public Window GetMainWindow(AutomationBase automation, TimeSpan?waitTimeout = null)
 {
     return(GetMainWindow(automation, waitTimeout, null));
 }