示例#1
0
        public static UIObject ByNameAndClassName(UIObject root, string name, string className, bool shouldWait)
        {
            UICondition condition = UICondition.CreateFromName(name).AndWith(UICondition.CreateFromClassName(className));
            UIObject    uiObject  = null;

            root.Descendants.TryFind(condition, out uiObject);

            if (shouldWait && !root.Descendants.TryFind(condition, out uiObject))
            {
                Log.Comment("Object name = '{0}' className = '{1}' didn't exist, waiting...", name, className);
                try
                {
                    TestEnvironment.WaitUntilElementLoadedByName(name);
                    TestEnvironment.WaitUntilElementLoadedByClassName(className);
                }
                catch (WaiterTimedOutException)
                {
                    Log.Error("Could not find object with condition '{0}'!", condition.ToString());
                    DumpHelper.DumpFullContext();

                    throw;
                }

                root.Descendants.TryFind(condition, out uiObject);

                Log.Comment("...Found");
            }

            return(uiObject);
        }
 public static IEnumerable <UIObject> GetTopLevelWindowsModernApp(int processId)
 {
     UICollection.Timeout = TimeSpan.Zero;
     foreach (var uiObject in UIObject.Root.Children.FindMultiple(condition: UICondition.CreateFromClassName(className: "ApplicationFrameWindow")))
     {
         if (uiObject.Children.Contains(uiProperty: UIProperty.Get(name: "ProcessId"), value: processId))
         {
             yield return(uiObject);
         }
     }
 }
示例#3
0
        private UICondition CreateTopLevelWindowCondition()
        {
            string deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;

            if (deviceFamily.Equals("Windows.Desktop", StringComparison.OrdinalIgnoreCase) ||
                deviceFamily.Equals("Windows.Server", StringComparison.OrdinalIgnoreCase) ||
                deviceFamily.Equals("Windows.Team", StringComparison.OrdinalIgnoreCase))
            {
                return(UICondition.CreateFromClassName("ApplicationFrameWindow"));
            }
            else
            {
                return(UICondition.CreateFromClassName("Windows.UI.Core.CoreWindow"));
            }
        }
        public void RichSuggestBox_DefaultTest()
        {
            var richSuggestBox = FindElement.ByName("richSuggestBox");
            var richEditBox    = new TextBlock(FindElement.ByClassName("RichEditBox"));
            var tokenCounter   = new TextBlock(FindElement.ById("tokenCounter"));
            var tokenListView  = FindElement.ById("tokenListView");

            Verify.AreEqual(string.Empty, richEditBox.GetText());

            richEditBox.SendKeys("Hello@Test1");

            var suggestListView = richSuggestBox.Descendants.Find(UICondition.CreateFromClassName("ListView"));

            Verify.IsNotNull(suggestListView);
            Verify.AreEqual(3, suggestListView.Children.Count);
            InputHelper.LeftClick(suggestListView.Children[0]);

            var tokenInfo1 = tokenListView.Children[0];
            var text       = "Hello\u200b@Test1Token1\u200b ";
            var actualText = richEditBox.GetText(false);

            Verify.AreEqual(text, actualText);
            Verify.AreEqual("1", tokenCounter.GetText());
            Verify.AreEqual("Token1", tokenInfo1.Children[0].GetText());
            Verify.AreEqual("5", tokenInfo1.Children[1].GetText());

            richEditBox.SendKeys("@Test2");
            Verify.AreEqual(3, suggestListView.Children.Count);
            InputHelper.LeftClick(suggestListView.Children[1]);

            var tokenInfo2 = tokenListView.Children[1];

            text       = "Hello\u200b@Test1Token1\u200b \u200b@Test2Token2\u200b ";
            actualText = richEditBox.GetText(false);
            Verify.AreEqual(text, actualText);
            Verify.AreEqual("2", tokenCounter.GetText());
            Verify.AreEqual("Token2", tokenInfo2.Children[0].GetText());
            Verify.AreEqual("68", tokenInfo2.Children[1].GetText());

            KeyboardHelper.PressKey(Key.Home);
            richEditBox.SendKeys(" ");
            Verify.AreEqual("6", tokenInfo1.Children[1].GetText());
            Verify.AreEqual("69", tokenInfo2.Children[1].GetText());
        }
示例#5
0
        private UIObject LaunchNonUWPApp(string packageName)
        {
            Debug.Assert(!_isUWPApp);
            var      nameCondition           = UICondition.CreateFromName(packageName);
            var      topLevelWindowCondition = UICondition.CreateFromClassName("Window").AndWith(nameCondition);
            UIObject coreWindow = null;

            try
            {
                coreWindow = UAPApp.Launch(_appName, topLevelWindowCondition);
            }
            catch
            {
                // UAP.Launch launches the app, but fails trying to find a CoreWindow in the launched app. If the
                // App is not UWP (as in the case of WPF app hosting a XAML Island), We can fallback to looking for
                // just a window and use it as the root for future queries.
                // not a uwp app, see if we can find any window with the condition that matches.
                coreWindow = FindCore.ByNameAndClassName(root: UIObject.Root, name: packageName, className: "Window", shouldWait: true);
            }

            return(coreWindow);
        }