示例#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));
        }
示例#3
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));
        }
        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);
        }
示例#5
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));
        }
        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()));
        }
示例#7
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));
        }