public override Window ModalWindow(string title, InitializeOption option)
        {
            WindowFactory desktopWindowsFactory = WindowFactory.Desktop;

            return(desktopWindowsFactory.FindModalWindow(title, Process.GetProcessById(automationElement.Current.ProcessId), option, automationElement,
                                                         WindowSession.ModalWindowSession(option)));
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Window"/> class.
 /// </summary>
 /// <param name="automationElement">
 /// The automation element.
 /// </param>
 /// <param name="initializeOption">
 /// The initialize option.
 /// </param>
 /// <param name="windowSession">
 /// The window session.
 /// </param>
 protected Window(
     AutomationElement automationElement,
     InitializeOption initializeOption,
     WindowSession windowSession)
     : this(automationElement, new NullActionListener(), initializeOption, windowSession)
 {
 }
예제 #3
0
 public UIItemContainer(AutomationElement automationElement, ActionListener actionListener,
                        InitializeOption initializeOption,
                        WindowSession windowSession) : base(automationElement, actionListener)
 {
     WindowSession = windowSession;
     CurrentContainerItemFactory = new CurrentContainerItemFactory(factory, initializeOption, automationElement, ChildrenActionListener);
 }
예제 #4
0
        /// <summary>
        /// Get the MessageBox window launched by this window
        /// </summary>
        /// <param name="title">Title of the messagebox</param>
        /// <returns></returns>
        public virtual Window MessageBox(string title)
        {
            Window window = factory.ModalWindow(title, InitializeOption.NoCache, WindowSession.ModalWindowSession(InitializeOption.NoCache));

            window.actionListener = this;
            return(window);
        }
예제 #5
0
 public SilverlightDocument(AutomationElement automationElement, BrowserWindow actionListener,
                            InitializeOption initializeOption,
                            WindowSession windowSession)
     : base(automationElement, actionListener, initializeOption, windowSession)
 {
     ieWindow = actionListener;
 }
예제 #6
0
        public virtual Window ModalWindow(string title, InitializeOption option, WindowSession windowSession)
        {
            var message            = "Could not find modal window with title: " + title;
            var modalWindowElement = WaitTillFound(() => Finder.FindWindow(title, 0), message);

            return(Create(modalWindowElement, option, windowSession));
        }
예제 #7
0
        public virtual Window ModalWindow(string title, InitializeOption option, WindowSession windowSession)
        {
            var message = "Could not find modal window with title: " + title;

            title = title.Replace("&", string.Empty); // Seems v3 just strips the amperstand out
            var modalWindowElement = WaitTillFound(() => Finder.FindWindow(title, 0), message);

            return(Create(modalWindowElement, option, windowSession));
        }
        /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
        public virtual Window FindModalWindow(string title, Process process, InitializeOption option, AutomationElement parentWindowElement,
                                              WindowSession windowSession)
        {
            var windowFinder       = new AutomationElementFinder(parentWindowElement);
            var message            = "Could not find modal window with title: " + title;
            var modalWindowElement = WaitTillFound(() => FindModalWindowElement(title, process, windowFinder), message);

            return(Create(modalWindowElement, option, windowSession));
        }
예제 #9
0
        private Window ModalWindow(Clock.Do find, InitializeOption option, WindowSession windowSession)
        {
            var clock = new Clock(CoreAppXmlConfiguration.Instance.BusyTimeout);

            Clock.Matched matched           = obj => obj != null;
            Clock.Expired expired           = () => null;
            var           automationElement = (AutomationElement)clock.Perform(find, matched, expired);

            return(automationElement == null ? null: Create(automationElement, option, windowSession));
        }
예제 #10
0
        private void InitializeWindow()
        {
            ActionPerformed();
            Rect bounds = Desktop.Instance.Bounds;

            if (!bounds.Contains(Bounds) && (TitleBar != null && TitleBar.MinimizeButton != null))
            {
                Logger.WarnFormat(
                    @"Window with title: {0} whose dimensions are: {1}, is not contained completely on the desktop {2}. 
UI actions on window needing mouse would not work in area not falling under the desktop",
                    Title, Bounds, bounds);
            }
            WindowSession.Register(this);
        }
예제 #11
0
        /// <summary>
        /// Recursively gets all the descendant windows.
        /// </summary>
        /// <returns></returns>
        public virtual List <Window> ModalWindows()
        {
            var modalWindows = new List <Window>();
            var finder       = new AutomationElementFinder(automationElement);
            var descendants  =
                finder.Descendants(AutomationSearchCondition.ByControlType(ControlType.Window));

            foreach (AutomationElement descendant in descendants)
            {
                modalWindows.Add(ChildWindowFactory.Create(descendant, InitializeOption.NoCache,
                                                           WindowSession.ModalWindowSession(InitializeOption.NoCache)));
            }
            return(modalWindows);
        }
예제 #12
0
        private void InitializeWindow()
        {
            ActionPerformed();
            Rect bounds = Desktop.Instance.Bounds;

            if (!bounds.Contains(Bounds) && (TitleBar != null && TitleBar.MinimizeButton != null))
            {
                Logger.WarnFormat(
                    @"Window with title: {0} whose dimensions are: {1}, is not contained completely on the desktop {2}. 
UI actions on window needing mouse would not work in area not falling under the desktop",
                    Title, Bounds, bounds);
            }
            WindowSession.Register(this);

            var hwnd = new IntPtr(automationElement.Current.NativeWindowHandle);
            int ownerProcessId;

            ownerThreadId = NativeWindow.GetWindowThreadProcessId(hwnd, out ownerProcessId);
            ownerProcess  = Process.GetProcessById(ownerProcessId);
        }
예제 #13
0
        public virtual Window FindModalWindow(string title, Process process, InitializeOption option, AutomationElement parentWindowElement,
                                              WindowSession windowSession)
        {
            var windowFinder = new AutomationElementFinder(parentWindowElement);

            try
            {
                AutomationElement modalWindowElement = WaitTillFound(delegate
                {
                    AutomationElement windowElement = windowFinder.FindWindow(title, process.Id) ??
                                                      Finder.FindWindow(title, process.Id);
                    return(windowElement);
                }, "Could not find modal window with title: " + title);
                return(Create(modalWindowElement, option, windowSession));
            }
            catch (UIActionException e)
            {
                logger.Debug(e.ToString());
                return(null);
            }
        }
        /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
        public virtual Window FindWindow(Process process, Predicate <string> match, InitializeOption initializeOption, WindowSession windowSession)
        {
            string message      = string.Format("Could not find window matching condition. ProcessName: {0}, ProcessId: {1}, MatchingConditionMethod: {2}, MatchingConditionTarget: {3}", process.ProcessName, process.Id, match.Method, match.Target);
            var    foundElement = WaitTillFound(() => FindWindowElement(process, match), message);

            return(Create(foundElement, initializeOption, windowSession));
        }
        /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
        public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession)
        {
            var message = string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage);
            var element = WaitTillFound(() => Finder.FindWindow(searchCriteria, process.Id), message);

            return(Create(element, option, windowSession));
        }
        /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
        public virtual Window CreateWindow(string title, Process process, InitializeOption option, WindowSession windowSession)
        {
            var message = string.Format("Couldn't find window with title {0} in process {1}{2}", title, process.Id, ", after waiting for 30 seconds");
            var element = WaitTillFound(() => Finder.FindWindow(title, process.Id), message);

            return(Create(element, option, windowSession));
        }
        /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
        public virtual Window FindModalWindow(SearchCriteria searchCriteria, InitializeOption option, AutomationElement parentWindowElement, WindowSession windowSession)
        {
            var windowFinder       = new AutomationElementFinder(parentWindowElement);
            var message            = "Could not find modal window with SearchCriteria: " + searchCriteria;
            var modalWindowElement = WaitTillFound(() => FindModalWindowElement(searchCriteria, windowFinder), message);

            return(Create(modalWindowElement, option, windowSession));
        }
예제 #18
0
 public Firefox(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession)
     : base(automationElement, windowFactory, option, windowSession)
 {
 }
예제 #19
0
        public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession)
        {
            var message            = "Could not find modal window with SearchCriteria: " + searchCriteria;
            var modalWindowElement = WaitTillFound(() => Finder.FindWindow(searchCriteria), message);

            return(Create(modalWindowElement, option, windowSession));
        }
예제 #20
0
 public override Window ModalWindow(string title, InitializeOption option)
 {
     return(factory.ModalWindow(title, option, WindowSession.ModalWindowSession(option)));
 }
예제 #21
0
 internal WinFormWindow(AutomationElement automationElement, InitializeOption initializeOption, WindowSession windowSession)
     : base(automationElement, initializeOption, windowSession)
 {
 }
예제 #22
0
 public Firefox(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession) :
     base(automationElement, windowFactory, option, windowSession)
 {
 }
예제 #23
0
        public virtual Window FindModalWindow(SearchCriteria searchCriteria, InitializeOption option, AutomationElement parentWindowElement, WindowSession windowSession)
        {
            var windowFinder = new AutomationElementFinder(parentWindowElement);

            try
            {
                AutomationElement modalWindowElement = WaitTillFound(delegate
                {
                    AutomationElement windowElement = windowFinder.FindWindow(searchCriteria) ??
                                                      Finder.FindWindow(searchCriteria);
                    return(windowElement);
                }, "Could not find modal window with SearchCriteria: " + searchCriteria);
                return(Create(modalWindowElement, option, windowSession));
            }
            catch (UIActionException e)
            {
                logger.Debug(e.ToString());
                return(null);
            }
        }
예제 #24
0
        /// <summary>
        /// Recursively gets all the descendant windows.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="UIItemSearchException">The application type is not supported by White</exception> // from ChildWindowFactory.Create
        public virtual List <Window> ModalWindows()
        {
            var finder      = new AutomationElementFinder(automationElement);
            var descendants = finder.Descendants(AutomationSearchCondition.ByControlType(ControlType.Window));

            return(descendants
                   .Select(descendant => ChildWindowFactory.Create(descendant, InitializeOption.NoCache, WindowSession.ModalWindowSession(InitializeOption.NoCache)))
                   .ToList());
        }
예제 #25
0
 protected Window(AutomationElement automationElement, ActionListener actionListener, InitializeOption initializeOption, WindowSession windowSession)
     : base(automationElement, actionListener, initializeOption, windowSession)
 {
     InitializeWindow();
     minOpenTime = Task.Factory.StartNew(() => Thread.Sleep(500));
 }
예제 #26
0
        //TODO Try and get this working
        //public override List<Window> ModalWindows()
        //{
        //    var automationSearchConditions = new AutomationSearchConditionFactory()
        //        .GetWindowSearchConditions(automationElement.Current.ProcessId)
        //        .ToArray();

        //    var descendants = new AutomationElementFinder(automationElement)
        //        .Children(automationSearchConditions);

        //    return descendants
        //        .Select(descendant => ChildWindowFactory.Create(descendant, InitializeOption.NoCache, WindowSession.ModalWindowSession(InitializeOption.NoCache)))
        //        .ToList();
        //}

        public override Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option)
        {
            return(windowFactory.ModalWindow(searchCriteria, option, WindowSession.ModalWindowSession(option)));
        }
예제 #27
0
 public Win32Window(AutomationElement automationElement, WindowFactory windowFactory, InitializeOption option, WindowSession windowSession)
     : base(automationElement, option, windowSession)
 {
     this.windowFactory = windowFactory;
 }
예제 #28
0
        public override List <Window> ModalWindows()
        {
            var descendants = new AutomationElementFinder(automationElement)
                              .Children(new AutomationSearchConditionFactory().GetWindowSearchConditions(automationElement.Current.ProcessId).ToArray());

            return(descendants
                   .Select(descendant => ChildWindowFactory.Create(descendant, InitializeOption.NoCache, WindowSession.ModalWindowSession(InitializeOption.NoCache)))
                   .ToList());
        }
예제 #29
0
 private Desktop(AutomationElement automationElement, ActionListener actionListener, InitializeOption initializeOption,
                 WindowSession windowSession) : base(automationElement, actionListener, initializeOption, windowSession)
 {
     finder = new AutomationElementFinder(automationElement);
 }
 public virtual Window Create(AutomationElement automationElement, InitializeOption initializeOption, WindowSession session)
 {
     return new Firefox(automationElement, WindowFactory.Desktop, initializeOption, session);
 }
예제 #31
0
        /// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
        internal static Window Create(AutomationElement element, InitializeOption option, WindowSession windowSession)
        {
            ISpecializedWindowFactory specializedWindowFactory = SpecializedWindowFactories.Find(factory => factory.DoesSpecializeInThis(element));

            if (specializedWindowFactory != null)
            {
                return(specializedWindowFactory.Create(element, option, windowSession));
            }

            var windowsFramework = WindowsFrameworkExtensions.FromFrameworkId(element.Properties.FrameworkId);

            if (windowsFramework == WindowsFramework.WinForms)
            {
                return(new WinFormWindow(element, option, windowSession));
            }
            if (windowsFramework == WindowsFramework.Wpf)
            {
                return(new WPFWindow(element, WindowFactory.Desktop, option, windowSession));
            }
            if (windowsFramework == WindowsFramework.Win32)
            {
                return(new Win32Window(element, WindowFactory.Desktop, option, windowSession));
            }
            throw new UIItemSearchException(string.Format("{0} is not supported yet.", windowsFramework));
        }
예제 #32
0
 public virtual IUIItem Find(SearchCriteria searchCriteria, WindowSession windowSession)
 {
     return(windowSession.Get(current, searchCriteria, actionListener));
 }