Esempio n. 1
0
        public static MessageBoxProxy WaitMessageBoxChild(this AutomationElement element, int?timeOut = null)
        {
            var parentWin = WindowProxy.Normalize(element);

            var win = parentWin.WaitChild(a => a.Current.ControlType == ControlType.Window && a.Current.ClassName == "#32770", timeOut);

            return(new MessageBoxProxy(win));
        }
Esempio n. 2
0
        public static MessageBoxProxy TryMessageBoxChild(this AutomationElement element)
        {
            var parentWin = WindowProxy.Normalize(element);

            var win = parentWin.TryChild(a => a.Current.ControlType == ControlType.Window && a.Current.ClassName == "#32770");

            if (win != null)
            {
                return(new MessageBoxProxy(win));
            }

            return(null);
        }
Esempio n. 3
0
        public void AddColumn(string token, string displayName)
        {
            SelectToken(token);

            var win = Element.CaptureChildWindow(() => Element.ChildById("btCreateColumn").ButtonInvoke(),
                                                 () => "Adding new column for {0} on SearchControl {1}".FormatWith(token, Element.Current.Name));

            using (WindowProxy wp = new WindowProxy(win))
            {
                if (displayName != null)
                {
                    wp.Element.Descendant(a => a.Current.ControlType == ControlType.Edit).Pattern <ValuePattern>().SetValue(displayName);
                }

                wp.Element.ChildById("btAccept").ButtonInvoke();
            }
        }
Esempio n. 4
0
        public static AutomationElement CaptureChildWindow(this AutomationElement element, Action action, Func <string> actionDescription = null, int?timeOut = null)
        {
            if (actionDescription == null)
            {
                actionDescription = () => "Get Windows after";
            }

            var parentWindow = WindowProxy.Normalize(element);

            var previous = parentWindow.Children(a => a.Current.ControlType == ControlType.Window).Select(a => a.GetRuntimeId().ToString(".")).ToHashSet();

            action();

            AutomationElement newWindow = null;

            List <AutomationElement> currentWindows = new List <AutomationElement>();

            element.Wait(() =>
            {
                currentWindows = parentWindow.Children(a => a.Current.ControlType == ControlType.Window);
                newWindow      = currentWindows.FirstOrDefault(a => !previous.Contains(a.GetRuntimeId().ToString(".")));

                MessageBoxProxy.ThrowIfError(newWindow);

                if (newWindow != null)
                {
                    return(true);
                }


                return(false);
            }, () => actionDescription() +
                         "\r\n\tcurrentWindows: " + currentWindows.ToString(a => NiceToString(a), "\r\n\t\t") +
                         "\r\n\tnewWindow: " + NiceToString(newWindow) +
                         "\r\n\tprevious: " + previous.ToString(a => a, " ")
                         , timeOut ?? CapturaWindowTimeout);
            return(newWindow);
        }