예제 #1
0
 public virtual void Handle(Window window)
 {
     window.WaitWhileBusy();
     if (CoreAppXmlConfiguration.Instance.WaitBasedOnHourGlass)
     {
         Clock.Do      @do     = () => Mouse.Instance.Cursor;
         Clock.Matched matched = delegate(object obj)
         {
             var cursor = (MouseCursor)obj;
             if (MouseCursor.WaitCursors.Contains(cursor) && CoreAppXmlConfiguration.Instance.MoveMouseToGetStatusOfHourGlass)
             {
                 Mouse.Instance.MoveOut();
                 return(false);
             }
             return(true);
         };
         Clock.Expired expired =
             delegate { throw new UIActionException(string.Format("Window in still wait mode. Cursor: {0}{1}", Mouse.Instance.Cursor, Constants.BusyMessage)); };
         new Clock(CoreAppXmlConfiguration.Instance.BusyTimeout).Perform(@do, matched, expired);
     }
     CustomWait(window);
     if (types.Contains(ActionType.NewControls))
     {
         window.ReloadIfCached();
     }
 }
        private static SuggestionList WaitTill(ActionListener actionListener, string failureMessage, Clock.Matched matched)
        {
            Clock.Do      getSuggestionList = () => Find(actionListener);
            Clock.Expired onExpiration      = delegate { throw new UIActionException(failureMessage + Constants.BusyMessage); };

            return
                ((SuggestionList) new Clock(CoreAppXmlConfiguration.Instance.SuggestionListTimeout).Perform(getSuggestionList, matched, onExpiration));
        }
        private static object FindUiElement(Func<object> find, int busyTimeOut, Clock.Matched matched, Clock.Expired expired)
        {
            var doSearch = new Clock.Do(() => SwallowAllExceptions(find, null));

            var clock = new Clock(busyTimeOut);

            return clock.Perform(doSearch, matched, expired);
        }
예제 #4
0
        private static AutomationElement WaitTillFound(Clock.Do find, string message)
        {
            var clock = new Clock(CoreAppXmlConfiguration.Instance.BusyTimeout);

            Clock.Matched matched = obj => obj != null;
            Clock.Expired expired = delegate { throw new UIActionException(message + Debug.GetAllWindows()); };
            return((AutomationElement)clock.Perform(find, matched, expired));
        }
예제 #5
0
        public virtual ToolTip GetToolTipOn(UIItem uiItem)
        {
            Mouse.Location = uiItem.Bounds.Center();
            var finder = new AutomationElementFinder(automationElement);

            Clock.Do perform = () => finder.Descendant(AutomationSearchCondition.ByControlType(ControlType.ToolTip));
            return(ToolTipFinder.FindToolTip(perform));
        }
예제 #6
0
        public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession)
        {
            Clock.Do find    = () => finder.FindWindow(searchCriteria, process.Id);
            string   message =
                string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage);
            AutomationElement element = WaitTillFound(find, message);

            return(Create(element, option, windowSession));
        }
        private void WaitTill(Clock.Matched matched)
        {
            window.WaitWhileBusy();
            dashboard.WaitWhileBusy();
            Clock.Do @do   = () => editor.Text.Trim();
            var      clock = new Clock(5000);

            Clock.Expired expired = delegate { throw new Exception(); };
            clock.Perform(@do, matched, expired);
        }
예제 #8
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));
        }
예제 #9
0
        public static ToolTip FindToolTip(Clock.Do perform)
        {
            var clock = new Clock(CoreAppXmlConfiguration.Instance.TooltipWaitTime);

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

            return(automationElement == null ? null : new ToolTip(automationElement, new NullActionListener()));
        }
예제 #10
0
        public virtual Window SplashWindow(Process process)
        {
            AutomationSearchCondition automationSearchCondition = AutomationSearchCondition.ByControlType(ControlType.Pane).WithProcessId(process.Id);

            Clock.Do          find    = () => finder.Child(automationSearchCondition);
            AutomationElement element =
                WaitTillFound(find,
                              "No control found matching the condition " +
                              AutomationSearchCondition.ToString(new[] { automationSearchCondition }) + Constants.BusyMessage);

            return(new SplashWindow(element, InitializeOption.NoCache));
        }
        private bool TryGetPopupMenu(AutomationSearchCondition[] searchConditions, ActionListener actionListener, out PopUpMenu popUpMenu)
        {
            var clock = new Clock(CoreAppXmlConfiguration.Instance.PopupTimeout, 100);

            Clock.Do      @do     = () => finder.Child(searchConditions);
            Clock.Matched matched = obj => obj != null;
            var           element = (AutomationElement)clock.Perform(@do, matched, () => null);

            if (element == null)
            {
                popUpMenu = null;
                return(false);
            }
            popUpMenu = new PopUpMenu(element, actionListener);
            return(true);
        }
예제 #12
0
        private BricksCollection <AutomationElement> FindAllWindowElements(Process process)
        {
            var clock = new Clock(CoreAppXmlConfiguration.Instance.UIAutomationZeroWindowBugTimeout, 200);

            Clock.Do @do = delegate
            {
                var windowElements = new BricksCollection <AutomationElement>();
                FindDescendantWindowElements(finder, process, windowElements);
                if (windowElements.Count == 0)
                {
                    WhiteLogger.Instance.Warn("Could not find any windows for this application.");
                }
                return(windowElements);
            };
            Clock.Matched matched = obj => ((BricksCollection <AutomationElement>)obj).Count > 0;
            Clock.Expired expired = () => new BricksCollection <AutomationElement>();

            return((BricksCollection <AutomationElement>)clock.Perform(@do, matched, expired));
        }
예제 #13
0
 private AutomationElement FindWindowElement(Process process, string title)
 {
     Clock.Do find = () => finder.FindWindow(title, process.Id);
     return(WaitTillFound(find, string.Format("Couldn't find window with title {0} in process {1}{2}", title, process.Id, Constants.BusyMessage)));
 }
예제 #14
0
 public virtual Window ModalWindow(SearchCriteria searchCriteria, InitializeOption option, WindowSession windowSession)
 {
     Clock.Do @do = () => finder.FindWindow(searchCriteria);
     return(ModalWindow(@do, option, windowSession));
 }
예제 #15
0
 public virtual Window ModalWindow(string title, InitializeOption option, WindowSession windowSession)
 {
     Clock.Do @do = () => finder.FindWindow(title, 0);
     return(ModalWindow(@do, option, windowSession));
 }