Exemple #1
0
        /// <summary>
        /// Find the DirectUI window for MSAA (Accessible)
        /// </summary>
        /// <param name="browserWindowDetails">The browser WindowDetails</param>
        /// <returns>WindowDetails for the DirectUI window</returns>
        public static WindowDetails GetDirectUI(WindowDetails browserWindowDetails)
        {
            if (browserWindowDetails == null)
            {
                return(null);
            }
            WindowDetails tmpWD = browserWindowDetails;

            // Since IE 9 the TabBandClass is less deep!
            if (IEHelper.IEVersion() < 9)
            {
                tmpWD = tmpWD.GetChild("CommandBarClass");
                if (tmpWD != null)
                {
                    tmpWD = tmpWD.GetChild("ReBarWindow32");
                }
            }
            if (tmpWD != null)
            {
                tmpWD = tmpWD.GetChild("TabBandClass");
            }
            if (tmpWD != null)
            {
                tmpWD = tmpWD.GetChild("DirectUIHWND");
            }
            return(tmpWD);
        }
Exemple #2
0
        public static IEnumerable <string> GetBrowserUrls()
        {
            // FireFox
            foreach (WindowDetails window in WindowDetails.GetAllWindows("MozillaWindowClass"))
            {
                if (window.Text.Length == 0)
                {
                    continue;
                }
                AutomationElement currentElement  = AutomationElement.FromHandle(window.Handle);
                Condition         conditionCustom = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom), new PropertyCondition(AutomationElement.IsOffscreenProperty, false));
                for (int i = 5; i > 0 && currentElement != null; i--)
                {
                    currentElement = currentElement.FindFirst(TreeScope.Children, conditionCustom);
                }
                if (currentElement == null)
                {
                    continue;
                }

                Condition         conditionDocument = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document), new PropertyCondition(AutomationElement.IsOffscreenProperty, false));
                AutomationElement docElement        = currentElement.FindFirst(TreeScope.Children, conditionDocument);
                if (docElement == null)
                {
                    continue;
                }
                foreach (AutomationPattern pattern in docElement.GetSupportedPatterns())
                {
                    if (pattern.ProgrammaticName != "ValuePatternIdentifiers.Pattern")
                    {
                        continue;
                    }
                    string url = (docElement.GetCurrentPattern(pattern) as ValuePattern).Current.Value.ToString();
                    if (!string.IsNullOrEmpty(url))
                    {
                        yield return(url);

                        break;
                    }
                }
            }

            foreach (WindowDetails window in WindowDetails.GetAllWindows("MozillaWindowClass"))
            {
                if (window.Text.Length == 0)
                {
                    continue;
                }
                AutomationElement currentElement = AutomationElement.FromHandle(window.Handle);
            }
            foreach (string url in IEHelper.GetIEUrls())
            {
                yield return(url);
            }
        }