Exemplo n.º 1
0
        public HtmlDocument Get_HtmlDocumentToWindow1(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue)
        {
            try
            {
                this.hwndWizard = hwnd;


                ////Get the window object(Main window).
                UIObject objWindow = UIObject.FromHandle(this.hwndWizard);

                ////Get the specific UI object.
                UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue);

                ////Create window to the specific UI object.
                Window winIE_Server = new Window(objIE_Server.NativeWindowHandle);

                //// Get HTML Document(Main window).
                this.htmlDocWizzrd = new HtmlDocument(winIE_Server);
            }
            catch (Exception e)
            {
            }

            return(this.htmlDocWizzrd);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function returns htmlDocument for a given window.
        /// </summary>
        /// <param name="hwnd">Handle pointer to the window (main frame).</param>
        /// <param name="uiPropertyKey">Desired UI property key.</param>
        /// <param name="uiPropertyValue">Desired UI property value.</param>
        /// <param name="specialCond">The thread will keep on looping till the desired condition is attained</param>
        /// <returns>Html document.</returns>
        public HtmlDocument Get_HtmlDocumentToWindow(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue, object specialCond)
        {
            try
            {
                this.hwndWizard = hwnd;

                do
                {
                    ////Get the window object
                    UIObject objWindow = UIObject.FromHandle(this.hwndWizard);

                    ////Get the Internet Explorer_Server object
                    UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue);
                    Window   winIE_Server = new Window(objIE_Server.NativeWindowHandle);

                    //// Get HTML Document
                    this.htmlDocWizzrd = new HtmlDocument(winIE_Server);
                }while ((bool)specialCond);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(this.htmlDocWizzrd);
        }
Exemplo n.º 3
0
        public Window Get_HtmlDocumentToWindow(IntPtr hid, string abc, string xyz)
        {
            try
            {
                this.hwd = hid;



                ////Get the window object
                UIObject objWindow = UIObject.FromHandle(this.hwd);

                ////Get the Internet Explorer_Server object



                UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(abc), xyz);



                winIE_Server = new Window(objIE_Server.NativeWindowHandle);

                //  doc = new HtmlDocument(winIE_Server);
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(winIE_Server);
        }
Exemplo n.º 4
0
        public ScrollChangedEventWaiter(IScroll root, ScrollProperty scrollProperty, double expectedValue)
            : base(new PropertyChangedEventSource(root as UIObject, Scope.Element, UIProperty.Get("Scroll." + scrollProperty.ToString())))
        {
            Log.Comment("ScrollChangedEventWaiter - Constructor for scrollProperty={0} and expectedValue={1}.",
                        scrollProperty.ToString(), expectedValue.ToString());

            this.root                = root as UIObject;
            this.scrollProperty      = scrollProperty;
            this.expectedDoubleValue = expectedValue;

            if (!double.IsNaN(this.expectedDoubleValue))
            {
                switch (this.scrollProperty)
                {
                case ScrollProperty.HorizontalScrollPercent:
                    this.AddFilter(new Predicate <WaiterEventArgs>(args => root.HorizontalScrollPercent == expectedValue));
                    break;

                case ScrollProperty.HorizontalViewSize:
                    this.AddFilter(new Predicate <WaiterEventArgs>(args => root.HorizontalViewSize == expectedValue));
                    break;

                case ScrollProperty.VerticalScrollPercent:
                    this.AddFilter(new Predicate <WaiterEventArgs>(args => root.VerticalScrollPercent == expectedValue));
                    break;

                case ScrollProperty.VerticalViewSize:
                    this.AddFilter(new Predicate <WaiterEventArgs>(args => root.VerticalViewSize == expectedValue));
                    break;
                }
            }
            this.Reset();
        }
Exemplo n.º 5
0
        public void TopNavigationHaveCorrectSelectionWhenChangingMenuItems()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "Top NavigationView Test" }))
            {
                for (int i = 0; i < 3; i++)
                {
                    Log.Comment("Iteration: " + i);
                    Log.Comment("Invoke ChangeDataSource");
                    var button = new Button(FindElement.ById("ChangeDataSource"));
                    button.Invoke();
                    Wait.ForIdle();

                    Log.Comment("Reset TestResult");
                    var resetButton = new Button(FindElement.ById("ResetResult"));
                    resetButton.Invoke();
                    Wait.ForIdle();

                    ElementCache.Refresh();
                    UIObject selectedItem = FindElement.ByName("Happy new year Item");

                    Log.Comment("Verify the item is selected");
                    Verify.IsTrue(Convert.ToBoolean(selectedItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
                }
            }
        }
        /// <summary>
        /// This function returns htmlDocument for a given window, it searches 5 times(project requirement).
        /// </summary>
        /// <param name="hwnd">Handle pointer to the window (main frame).</param>
        /// <param name="uiPropertyKey">Desired UI property key.</param>
        /// <param name="uiPropertyValue">Desired UI property value.</param>
        /// <param name="elementToFind">The thread will keep on looping till the desired element is found in the return html.</param>
        /// <param name="isSpecific">If the function is for specific code.</param>
        /// <returns>Html document.</returns>
        public HtmlDocument Get_HtmlDocumentToWindow(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue, string elementToFind, bool isSpecific)
        {
            try
            {
                int count = 0;
                this.hwndWizard = hwnd;
                do
                {
                    ////Get the window object(Main window).
                    UIObject objWindow = UIObject.FromHandle(this.hwndWizard);

                    ////Get the specific UI object.
                    UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue);

                    ////Create window to the specific UI object.
                    Window winIE_Server = new Window(objIE_Server.NativeWindowHandle);

                    //// Get HTML Document(Main window).
                    this.htmlDocWizzrd = new HtmlDocument(winIE_Server);
                    count++;
                }while ((!this.htmlDocWizzrd.RawHtml.ToString().Contains(elementToFind)) && (count < 5));
            }
            catch (Exception e)
            {
#if debug
                throw new MitabaseException(MitaBaseMessages.HtmlDocNotFetch + Environment.NewLine + e.Message + Environment.NewLine + "UIElementWindow.");
#endif
                throw new MitabaseException(MitaBaseMessages.HtmlDocNotFetch);
            }

            return(this.htmlDocWizzrd);
        }
Exemplo n.º 7
0
        /// <summary>
        /// This function returns htmlDocument for a given window.
        /// </summary>
        /// <param name="hwnd">Handle pointer to the window (main frame).</param>
        /// <param name="uiPropertyKey">Desired UI property key.</param>
        /// <param name="uiPropertyValue">Desired UI property value.</param>
        /// <param name="elementToFind">The thread will keep on looping till the desired element is found in the return html.</param>
        /// <param name="isSpecific">If the function is for specific code.</param>
        /// <returns>Html document.</returns>
        public HtmlDocument Get_HtmlDocumentToWindow(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue, string elementToFind, bool isSpecific)
        {
            try
            {
                int count = 0;
                this.hwndWizard = hwnd;
                do
                {
                    ////Get the window object
                    UIObject objWindow = UIObject.FromHandle(this.hwndWizard);

                    ////Get the Internet Explorer_Server object
                    UIObject objIE_Server = objWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue);
                    Window   winIE_Server = new Window(objIE_Server.NativeWindowHandle);

                    //// Get HTML Document
                    this.htmlDocWizzrd = new HtmlDocument(winIE_Server);
                    count++;
                }while ((!this.htmlDocWizzrd.RawHtml.ToString().Contains(elementToFind)) && (count < 5));
            }
            catch (Exception e)
            {
                throw e;
            }

            return(this.htmlDocWizzrd);
        }
        /// <summary>
        /// This method is used when exact UI property to a control is known.
        /// </summary>
        /// <param name="hwnd">Handle pointer to the window (main frame).</param>
        /// <param name="uiPropertyKey">Desired UI property key.</param>
        /// <param name="uiPropertyValue">Desired UI property value.</param>
        /// <returns>Control window.</returns>
        public Window Get_WindowToSpecificControl(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue)
        {
            try
            {
                this.hwndWizard = hwnd;

                ////Get the window object(Main window).
                UIObject objSignupWindow = UIObject.FromHandle(this.hwndWizard);

                ////Get the specific UI object.
                UIObject objIE_Server = objSignupWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue);

                ////Create window to the specific UI object.
                this.winControl = new Window(objIE_Server.NativeWindowHandle);
            }
            catch (Exception e)
            {
#if debug
                throw new MitabaseException(MitaBaseMessages.CreateWindowFail + Environment.NewLine + e.Message + Environment.NewLine + "UIElementWindow.");
#endif
                throw new MitabaseException(MitaBaseMessages.CreateWindowFail);
            }

            return(this.winControl);
        }
Exemplo n.º 9
0
        public void MenuItemAutomationSelectionTest()
        {
            var testScenarios = RegressionTestScenario.BuildAllRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    UIObject firstItem  = FindElement.ByName("Home");
                    UIObject secondItem = FindElement.ByName("Apps");
                    UIObject thirdItem  = FindElement.ByName("Games");

                    Log.Comment("Verify the second item is not already selected");
                    Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    firstItem.SetFocus();
                    AutomationElement    firstItemAE  = AutomationElement.FocusedElement;
                    SelectionItemPattern firstItemSIP = firstItemAE.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;

                    Log.Comment("Move focus to the second item by pressing down(left nav)/right(right nav) arrow once");
                    var key = Key.Right;
                    if (testScenario.IsLeftNavTest)
                    {
                        key = Key.Down;
                    }
                    KeyboardHelper.PressKey(key);
                    Wait.ForIdle();
                    Verify.IsTrue(secondItem.HasKeyboardFocus);

                    AutomationElement    secondItemAE  = AutomationElement.FocusedElement;
                    SelectionItemPattern secondItemSIP = secondItemAE.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;

                    Log.Comment("Select the second item using SelectionItemPattern.Select and verify");
                    secondItemSIP.Select();
                    Wait.ForIdle();
                    Verify.IsTrue(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    Log.Comment("Deselect the second item");
                    firstItemSIP.Select();
                    Wait.ForIdle();
                    Verify.IsTrue(Convert.ToBoolean(firstItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));


                    Log.Comment("Select the second item using SelectionItemPattern.AddToSelection and verify");
                    secondItemSIP.AddToSelection();
                    Wait.ForIdle();
                    Verify.IsTrue(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    ClickClearSelectionButton();
                    Log.Comment("second item is unselected");
                    Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
                }
            }
        }
Exemplo n.º 10
0
 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);
         }
     }
 }
Exemplo n.º 11
0
        public ValueChangedEventWaiter(IValue root, string expectedValue = "")
            : base(new PropertyChangedEventSource(root as UIObject, Scope.Element, UIProperty.Get("Value.Value")))
        {
            this.root          = root as UIObject;
            this.expectedValue = expectedValue;

            if (expectedValue.Length > 0)
            {
                this.AddFilter(new Predicate <WaiterEventArgs>(args => root.Value == expectedValue));
            }

            this.Start();
        }
Exemplo n.º 12
0
        public UIObject FindItemByProperty(
            UIObject uiObject,
            UIProperty uiProperty,
            object value)
        {
            Validate.ArgumentNotNull(parameter: uiProperty, parameterName: nameof(uiProperty));
            if (value != null && uiProperty == UIProperty.Get(property: AutomationElement.SearchVirtualItemsProperty))
            {
                throw new ArgumentException(message: StringResource.Get(id: "FindItemByProperty_ArgumentException"));
            }
            var num     = (int)ActionHandler.Invoke(sender: UIObject, actionInfo: ActionEventArgs.GetDefault(action: "WaitForReady"));
            var element = uiObject == (UIObject)null ? Pattern.FindItemByProperty(element: null, property: uiProperty.Property, value: value) : Pattern.FindItemByProperty(element: uiObject.AutomationElement, property: uiProperty.Property, value: value);

            return(!(element == null) ? new UIObject(element: element) : null);
        }
Exemplo n.º 13
0
        public void VerifyNavigationViewItemIsSelectedWorks()
        {
            using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "NavigationView Init Test" }))
            {
                Log.Comment("Verify the 1st NavItem.IsSelected=true works");
                UIObject item1 = FindElement.ByName("Albums");
                Verify.IsNotNull(item1);
                Verify.IsTrue(Convert.ToBoolean(item1.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                Log.Comment("Verify the 2nd NavItem.IsSelected=true is ignored");
                UIObject item2 = FindElement.ByName("People");
                Verify.IsNotNull(item2);
                Verify.IsFalse(Convert.ToBoolean(item2.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
            }
        }
Exemplo n.º 14
0
        public void SelectionFollowFocusTest()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled on RS1 and earlier because SingleSelectionFollowFocus on RS2.");
                return;
            }
            var testScenarios = RegressionTestScenario.BuildTopNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    Log.Comment("Check SelectionFollowFocus");
                    CheckBox selectionFollowFocusCheckbox = new CheckBox(FindElement.ById("SelectionFollowFocusCheckbox"));
                    selectionFollowFocusCheckbox.Check();
                    Wait.ForIdle();

                    UIObject firstItem  = FindElement.ByName("Apps");
                    UIObject secondItem = FindElement.ByName("Games");

                    Log.Comment("Verify the second item is not already selected");
                    Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    firstItem.Click();
                    Wait.ForIdle();

                    Verify.IsTrue(Convert.ToBoolean(firstItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    Log.Comment("Move focus to the second item by pressing down(left nav)/right(right nav) arrow once");
                    var key = Key.Right;
                    if (testScenario.IsLeftNavTest)
                    {
                        key = Key.Down;
                    }
                    KeyboardHelper.PressKey(key);
                    Wait.ForIdle();

                    Log.Comment("Verify second item is selected and has focus because of SelectionFollowFocus");
                    Verify.IsTrue(secondItem.HasKeyboardFocus);
                    Verify.IsTrue(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    ClickClearSelectionButton();
                    Log.Comment("second item is unselected");
                    Verify.IsFalse(Convert.ToBoolean(secondItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// This method is used when exact UI property to a control is known.
        /// </summary>
        /// <param name="hwnd">Handle pointer to the window (main frame).</param>
        /// <param name="uiPropertyKey">Desired UI property key.</param>
        /// <param name="uiPropertyValue">Desired UI property value.</param>
        /// <returns>Control window.</returns>
        public Window Get_WindowToSpecificControl(IntPtr hwnd, string uiPropertyKey, string uiPropertyValue)
        {
            try
            {
                this.hwndWizard = hwnd;
                UIObject objSignupWindow = UIObject.FromHandle(this.hwndWizard);
                UIObject objIE_Server    = objSignupWindow.Descendants.Find(UIProperty.Get(uiPropertyKey), uiPropertyValue);
                this.winControl = new Window(objIE_Server.NativeWindowHandle);
            }
            catch (Exception e)
            {
                throw e;
            }

            return(this.winControl);
        }
Exemplo n.º 16
0
        public void VerifyDeselectionDisabled()
        {
            var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    UIObject homeItem = FindElement.ByName("Home");
                    Verify.IsNotNull(homeItem);
                    Verify.IsTrue(Convert.ToBoolean(homeItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                    KeyboardHelper.PressDownModifierKey(ModifierKey.Control);
                    homeItem.Click(); // Explicitly testing ctrl+click here
                    Wait.ForIdle();
                    Verify.IsTrue(Convert.ToBoolean(homeItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));
                    KeyboardHelper.ReleaseModifierKey(ModifierKey.Control);
                }
            }
        }
        private void HittestingAccessibilityTest()
        {
            if (!IsRS5OrHigher())
            {
                return;
            }

            var textBox = FindElement.ByName <Edit>("HittestingTextBox");

            using (var textBoxWaiter = new PropertyChangedEventWaiter(textBox, UIProperty.Get("Value.Value")))
            {
                TestEnvironment.Application.CoreWindow.Click();

                Log.Comment("HittestingAccessibilityTest: Waiting until OnPointerMoved handler in UI test returns.");
                textBoxWaiter.Wait();
                Log.Comment("HittestingAccessibilityTest: EventWaiter of HittestingAccessibilityTest is raised.");

                Log.Comment("HittestingAccessibilityTest: Value of textBox: \"{0}\".", textBox.Value);
                Verify.AreEqual(Constants.PointerMovedText, textBox.Value);
            }
        }
        private void FallenBackTest()
        {
            var textBox    = FindElement.ByName <Edit>("FallenBackTextBox");
            var testButton = FindElement.ByName <Button>("FallenBackButton");

            if (testButton != null && textBox != null)
            {
                using (var textBoxWaiter = new PropertyChangedEventWaiter(textBox, UIProperty.Get("Value.Value")))
                {
                    testButton.Click();

                    Log.Comment("FallenBackTest: textBoxWaiter: Waiting until fallenback screencapture and results checking.");
                    textBoxWaiter.Wait();
                    Log.Comment("EventWaiter of FallenBackTextBox is raised.");

                    Log.Comment("FallenBackTest: Value of textBox: \"{0}\".", textBox.Value);
                    Verify.AreEqual(Constants.TrueText, textBox.Value);
                }
            }
            else
            {
                Verify.Fail("FallenBackTest: FallenBackButton or any other UIElement is not found.");
            }
        }
        // Reverse forward playing using positive playback rate by setting playback rate to negative.
        private void ReversePositivePlaybackRateAnimationAccessibilityTest()
        {
            var textBox    = FindElement.ByName <Edit>("ReversePositivePlaybackRateAnimationTextBox");
            var playButton = FindElement.ByName <Button>("ReversePositivePlaybackRateAnimationPlayButton");

            if (playButton != null && textBox != null)
            {
                using (var textBoxWaiter = new PropertyChangedEventWaiter(textBox, UIProperty.Get("Value.Value")))
                {
                    playButton.Click();

                    Log.Comment("ReversePositivePlaybackRateAnimationAccessibilityTest: textBoxWaiter: Waiting until AnimatedVisualPlayer playing ends.");
                    textBoxWaiter.Wait();
                    Log.Comment("EventWaiter of reversePositivePlaybackRateAnimationProgressTextBox is raised.");

                    Log.Comment("ReversePositivePlaybackRateAnimationAccessibilityTest: Value of textBox: \"{0}\".", textBox.Value);
                    Verify.AreEqual(Constants.ZeroText, textBox.Value);
                }
            }
            else
            {
                Verify.Fail("ReversePositivePlaybackRateAnimationAccessibilityTest: playButton or any other UIElement is not found.");
            }
        }
Exemplo n.º 20
0
        public ScrollChangedEventWaiter(IScroll root, ScrollProperty scrollProperty, bool?expectedValue)
            : base(new PropertyChangedEventSource(root as UIObject, Scope.Element, UIProperty.Get("Scroll." + scrollProperty.ToString())))
        {
            Log.Comment("ScrollChangedEventWaiter - Constructor for scrollProperty={0} and expectedValue={1}.",
                        scrollProperty.ToString(), expectedValue == null ? "null" : expectedValue.ToString());

            this.root              = root as UIObject;
            this.scrollProperty    = scrollProperty;
            this.expectedBoolValue = expectedValue;

            if (this.expectedBoolValue != null)
            {
                switch (this.scrollProperty)
                {
                case ScrollProperty.HorizontallyScrollable:
                    this.AddFilter(new Predicate <WaiterEventArgs>(args => root.HorizontallyScrollable == expectedValue));
                    break;

                case ScrollProperty.VerticallyScrollable:
                    this.AddFilter(new Predicate <WaiterEventArgs>(args => root.VerticallyScrollable == expectedValue));
                    break;
                }
            }
        }
 public UIEventWaiter GetToggledWaiter()
 {
     return(new PropertyChangedEventWaiter(root: UIObject, scope: Scope.Element, UIProperty.Get(name: "Toggle.ToggleState")));
 }
        public void AccessibilityTest()
        {
            using (var setup = new TestSetupHelper("AnimatedVisualPlayer Tests"))
            {
                var progressTextBox = FindElement.ByName <Edit>("ProgressTextBox");
                var isPlayingTextBoxBeforePlaying = FindElement.ByName <Edit>("IsPlayingTextBoxBeforePlaying");
                var isPlayingTextBoxBeingPlaying  = FindElement.ByName <Edit>("IsPlayingTextBoxBeingPlaying");
                var playButton = FindElement.ByName <Button>("PlayButton");

                if (playButton != null &&
                    progressTextBox != null &&
                    isPlayingTextBoxBeforePlaying != null &&
                    isPlayingTextBoxBeingPlaying != null)
                {
                    using (var progressTextBoxWaiter = new PropertyChangedEventWaiter(progressTextBox, UIProperty.Get("Value.Value")))
                    {
                        playButton.Click();

                        Log.Comment("Waiting until AnimatedVisualPlayer playing ends.");
                        progressTextBoxWaiter.Wait();
                        Log.Comment("EventWaiter of progressTextBox is raised.");

                        Log.Comment("Value of isPlayingTextBoxBeforePlaying: \"{0}\".", isPlayingTextBoxBeforePlaying.Value);
                        Verify.AreEqual(Constants.FalseText, isPlayingTextBoxBeforePlaying.Value);

                        //
                        // isPlayingTextBoxBeingPlaying value is supposed to be updated
                        // inside the event handler function of Click for playButton in
                        // the UI test.
                        //
                        Log.Comment("Value of isPlayingTextBoxBeingPlaying: \"{0}\".", isPlayingTextBoxBeingPlaying.Value);
                        Verify.AreEqual(Constants.TrueText, isPlayingTextBoxBeingPlaying.Value);

                        Log.Comment("Value of progressTextBox: \"{0}\".", progressTextBox.Value);
                        Verify.AreEqual(Constants.PlayingEndedText, progressTextBox.Value);
                    }
                }
                else
                {
                    Verify.Fail("PlayButton or any other UIElement is not found.");
                }

                ToZeroKeyframeAnimationAccessibilityTest();
                FromOneKeyframeAnimationAccessibilityTest();
                ReverseNegativePlaybackRateAnimationAccessibilityTest();
                ReversePositivePlaybackRateAnimationAccessibilityTest();
                HittestingAccessibilityTest();
                FallenBackTest();
            }
        }
Exemplo n.º 23
0
 public UIProperty GetUIProperty()
 {
     return(UIProperty.Get(name: this._propertyName));
 }
Exemplo n.º 24
0
        bool SetToggleState(ToggleState toggleState)
        {
            for (var index = 0; index < 3; ++index)
            {
                if (this._togglePattern.ToggleState == toggleState)
                {
                    return(true);
                }
                if (index < 2)
                {
                    using (var changedEventWaiter = new PropertyChangedEventWaiter(root: this, scope: Scope.Element, UIProperty.Get(name: "Toggle.ToggleState"))) {
                        Toggle();
                        if (!changedEventWaiter.TryWait())
                        {
                            Log.Out(msg: "ToggleState did not change before timeout.");
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 25
0
        private UIObject Launch(string deploymentDir)
        {
            UIObject coreWindow = null;

            // When running from MUXControls repo we want to install the app.
            // When running in TestMD we also want to install the app.
            // In CatGates, we install the test app as part of the deploy script, so we don't need to do anything here.
#if BUILD_WINDOWS
            if (TestEnvironment.TestContext.Properties.Contains("RunFromTestMD"))
            {
                TestAppInstallHelper.InstallTestAppIfNeeded(deploymentDir, _packageName, _packageFullName);
            }
#elif USING_TAEF
            TestAppInstallHelper.InstallTestAppIfNeeded(deploymentDir, _packageName, _packageFullName);
#else
            BuildAndInstallTestAppIfNeeded();
#endif

            Log.Comment("Launching app {0}", _appName);

            coreWindow = LaunchApp(_packageName);

            Verify.IsNotNull(coreWindow, "coreWindow");

            Log.Comment("Waiting for the close-app invoker to be found to signal that the app has launched successfully...");

            for (int retries = 0; retries < 5; ++retries)
            {
                UIObject obj;
                coreWindow.Descendants.TryFind(UICondition.Create("@AutomationId='__CloseAppInvoker'"), out obj);
                if (obj != null)
                {
                    Log.Comment("Invoker found!");
                    break;
                }

                Log.Comment("Invoker not found. Sleeping for 500 ms before trying again...");
                Thread.Sleep(500);
            }

            var unhandledExceptionReportingTextBox = new Edit(coreWindow.Descendants.Find(UICondition.Create("@AutomationId='__UnhandledExceptionReportingTextBox'")));
            var valueChangedSource = new PropertyChangedEventSource(unhandledExceptionReportingTextBox, Scope.Element, UIProperty.Get("Value.Value"));
            valueChangedSource.Start(new TestAppCrashDetector());

            Log.Comment("15056441 tracing, device family:" + Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily);

            // On phone, we work around different scale factors between devices by configuring the test app to
            // lay out the test pages at the device's resolution, effectively giving us a scale factor of 1.0.
            if (PlatformConfiguration.IsDevice(DeviceType.Phone))
            {
                Log.Comment("Enabling view scaling workaround on phone.");

                try
                {
                    var viewScalingCheckBox = new CheckBox(coreWindow.Descendants.Find(UICondition.Create("@AutomationId='__ViewScalingCheckBox'")));
                    using (var waiter = viewScalingCheckBox.GetToggledWaiter())
                    {
                        viewScalingCheckBox.Check();
                    }
                    Log.Comment("15056441 Tracing: New checkbox state is " + viewScalingCheckBox.ToggleState);
                }
                catch (UIObjectNotFoundException)
                {
                    Log.Error("Could not find the view scaling CheckBox.");
                    TestEnvironment.LogDumpTree(UIObject.Root);
                    throw;
                }
            }

            return(coreWindow);
        }
Exemplo n.º 26
0
        private UIObject Launch(string deploymentDir)
        {
            UIObject coreWindow = null;

            // When running from MUXControls repo we want to install the app.
            // When running in TestMD we also want to install the app.
#if USING_TAEF
            TestAppInstallHelper.InstallTestAppIfNeeded(deploymentDir, _packageName, _packageFamilyName, _appInstallerName);
#else
            InstallTestAppIfNeeded();
#endif

            Log.Comment("Launching app {0}", _appName);

            coreWindow = LaunchApp();

            Verify.IsNotNull(coreWindow, "coreWindow");

            Log.Comment("Waiting for the close-app invoker to be found to signal that the app has launched successfully...");

            for (int retries = 0; retries < 5; ++retries)
            {
                UIObject obj;
                coreWindow.Descendants.TryFind(UICondition.Create("@AutomationId='__CloseAppInvoker'"), out obj);
                if (obj != null)
                {
                    Log.Comment("Invoker found!");
                    break;
                }

                Log.Comment("Invoker not found. Sleeping for 500 ms before trying again...");
                Thread.Sleep(500);
            }

            var unhandledExceptionReportingTextBox = new Edit(coreWindow.Descendants.Find(UICondition.Create("@AutomationId='__UnhandledExceptionReportingTextBox'")));
            var valueChangedSource = new PropertyChangedEventSource(unhandledExceptionReportingTextBox, Scope.Element, UIProperty.Get("Value.Value"));
            valueChangedSource.Start(new TestAppCrashDetector());

            Log.Comment("15056441 tracing, device family:" + Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily);

            return(coreWindow);
        }
        public UIEventWaiter GetExpandedWaiter()
        {
            var changedEventWaiter = new PropertyChangedEventWaiter(root: UIObject, scope: Scope.Subtree, UIProperty.Get(name: "ExpandCollapse.ExpandCollapseState"));

            changedEventWaiter.AddFilter(callback: ExpandFilter);
            return(changedEventWaiter);
        }
        public void ToggleTest()
        {
            using (var setup = new TestSetupHelper("SplitButton Tests"))
            {
                SplitButton splitButton = FindElement.ByName <SplitButton>("ToggleSplitButton");

                TextBlock toggleStateTextBlock        = FindElement.ByName <TextBlock>("ToggleStateTextBlock");
                TextBlock toggleStateOnClickTextBlock = FindElement.ByName <TextBlock>("ToggleStateOnClickTextBlock");

                Verify.AreEqual("Unchecked", toggleStateTextBlock.DocumentText);
                Verify.AreEqual("Unchecked", toggleStateOnClickTextBlock.DocumentText);

                Log.Comment("Click primary button to check button");
                using (var toggleStateWaiter = new PropertyChangedEventWaiter(splitButton, Scope.Element, UIProperty.Get("Toggle.ToggleState")))
                {
                    ClickPrimaryButton(splitButton);
                    Verify.IsTrue(toggleStateWaiter.TryWait(TimeSpan.FromSeconds(1)), "Waiting for the Toggle.ToggleState event should succeed");
                }

                Verify.AreEqual("Checked", toggleStateTextBlock.DocumentText);
                Verify.AreEqual("Checked", toggleStateOnClickTextBlock.DocumentText);

                Log.Comment("Click primary button to uncheck button");
                ClickPrimaryButton(splitButton);

                Verify.AreEqual("Unchecked", toggleStateTextBlock.DocumentText);
                Verify.AreEqual("Unchecked", toggleStateOnClickTextBlock.DocumentText);

                Log.Comment("Clicking secondary button should not change toggle state");
                ClickSecondaryButton(splitButton);

                Verify.AreEqual("Unchecked", toggleStateTextBlock.DocumentText);
                Verify.AreEqual("Unchecked", toggleStateOnClickTextBlock.DocumentText);
            }
        }
Exemplo n.º 29
0
        public void TabNavigationTest()
        {
            var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios();

            foreach (var testScenario in testScenarios)
            {
                using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName }))
                {
                    // TODO: Update RS3 and below tab behavior to match RS4+
                    if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4))
                    {
                        Log.Warning("Test is disabled because the repeater tab behavior is currently different on RS3 and below.");
                        return;
                    }

                    SetNavViewWidth(ControlWidth.Wide);

                    Button   togglePaneButton = new Button(FindElement.ById("TogglePaneButton"));
                    UIObject searchBox        = FindElement.ByNameAndClassName("PaneAutoSuggestBox", "TextBox");
                    UIObject settingsItem     = FindElement.ByName("Settings");

                    VerifyTabNavigationWithoutMenuItemSelected();
                    VerifyTabNavigationWithMenuItemSelected();

                    void VerifyTabNavigationWithoutMenuItemSelected()
                    {
                        Log.Comment("Verify Tab navigation without a selected menu item");

                        // Clear any item selection
                        var clearSelectedItemButton = new Button(FindElement.ByName("ClearSelectedItemButton"));

                        clearSelectedItemButton.Click();
                        Wait.ForIdle();

                        Verify.AreEqual("null", GetSelectedItem());

                        UIObject firstMenuItem = FindElement.ByName("Home");
                        UIObject lastMenuItem  = FindElement.ByName("HasChildItem");

                        // Set focus on the pane's toggle button.
                        togglePaneButton.SetFocus();
                        Wait.ForIdle();

                        Log.Comment("Verify that pressing tab while TogglePaneButton has focus moves to the search box");
                        KeyboardHelper.PressKey(Key.Tab);
                        Wait.ForIdle();
                        Verify.IsTrue(searchBox.HasKeyboardFocus);

                        Log.Comment("Verify that pressing tab while the search box has focus moves to the first menu item");
                        KeyboardHelper.PressKey(Key.Tab);
                        Wait.ForIdle();
                        Verify.IsTrue(firstMenuItem.HasKeyboardFocus);

                        Log.Comment("Verify that pressing tab thrice more will move focus to the settings item");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.None, 3);
                        Wait.ForIdle();
                        Verify.IsTrue(settingsItem.HasKeyboardFocus);

                        Log.Comment("Verify that pressing SHIFT+tab thrice will move focus to the last menu item");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 3);
                        Wait.ForIdle();
                        Verify.IsTrue(lastMenuItem.HasKeyboardFocus);

                        Log.Comment("Verify that pressing SHIFT+tab will move focus to the search box");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1);
                        Wait.ForIdle();
                        Verify.IsTrue(searchBox.HasKeyboardFocus);

                        Log.Comment("Verify that pressing SHIFT+tab will move focus to the TogglePaneButton");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1);
                        Wait.ForIdle();
                        Verify.IsTrue(togglePaneButton.HasKeyboardFocus);
                    }

                    void VerifyTabNavigationWithMenuItemSelected()
                    {
                        Log.Comment("Verify Tab navigation with a selected menu item");

                        // Select a menu item (preferably not the first or last menu item)
                        UIObject thirdMenuItem = FindElement.ByName("Games");

                        var selectedItemComboBox = new ComboBox(FindElement.ById("SelectedItemCombobox"));

                        selectedItemComboBox.SelectItemByName("Games");
                        Wait.ForIdle();

                        Verify.IsTrue(Convert.ToBoolean(thirdMenuItem.GetProperty(UIProperty.Get("SelectionItem.IsSelected"))));

                        // Set focus on the pane's toggle button.
                        togglePaneButton.SetFocus();
                        Wait.ForIdle();

                        Log.Comment("Verify that pressing tab while TogglePaneButton has focus moves to the search box");
                        KeyboardHelper.PressKey(Key.Tab);
                        Wait.ForIdle();
                        Verify.IsTrue(searchBox.HasKeyboardFocus);

                        Log.Comment("Verify that pressing tab while the search box has focus moves to the selected menu item");
                        KeyboardHelper.PressKey(Key.Tab);
                        Wait.ForIdle();
                        Verify.IsTrue(thirdMenuItem.HasKeyboardFocus);

                        Log.Comment("Verify that pressing tab thrice more will move focus to the settings item");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.None, 3);
                        Wait.ForIdle();
                        Verify.IsTrue(settingsItem.HasKeyboardFocus);

                        Log.Comment("Verify that pressing SHIFT+tab thrice will move focus to the selected menu item");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 3);
                        Wait.ForIdle();
                        Verify.IsTrue(thirdMenuItem.HasKeyboardFocus);

                        Log.Comment("Verify that pressing SHIFT+tab will move focus to the search box");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1);
                        Wait.ForIdle();
                        Verify.IsTrue(searchBox.HasKeyboardFocus);

                        Log.Comment("Verify that pressing SHIFT+tab will move focus to the TogglePaneButton");
                        KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1);
                        Wait.ForIdle();
                        Verify.IsTrue(togglePaneButton.HasKeyboardFocus);
                    }
                }

                string GetSelectedItem()
                {
                    return(FindElement.ByName("SelectionChangedItemType").GetText());
                }
            }
        }
Exemplo n.º 30
0
 public static IEnumerable <UIObject> GetTopLevelWindowsClassicApp(
     int processId)
 {
     UICollection.Timeout = TimeSpan.Zero;
     foreach (var uiObject in UIObject.Root.Children.FindMultiple(condition: UICondition.Create(property: UIProperty.Get(name: "ProcessId"), value: processId).AndWith(newCondition: UICondition.Create(property: UIProperty.Get(name: "ControlType"), value: ControlType.Window))))
     {
         yield return(uiObject);
     }
 }