Exemple #1
0
        public AutomationElement GetCell(AutomationElement dataItem)
        {
            ScrollItemPattern scroll = (ScrollItemPattern)dataItem.GetCurrentPattern(ScrollItemPattern.Pattern);

            scroll.ScrollIntoView();

            // find the DataGridCell to activate.
            int index = this.index;

            if (this.Parent != null)
            {
                index = this.Parent.index;
            }

            int i = 0;
            AutomationElement cell = null;

            foreach (AutomationElement e in dataItem.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "DataGridCell")))
            {
                if (i == index)
                {
                    cell = e;
                    break;
                }
                i++;
            }

            if (cell == null)
            {
                throw new Exception("Expecting a DataGridCell to appear at index " + index + " in the DataItem" + Name + ". We found " + i + " DataGridCells.");
            }

            return(cell);
        }
Exemple #2
0
        public void ScrollIntoView(bool log)
        {
            if (log)
            {
                procedureLogger.Action(string.Format("Scroll {0} into view.", this.NameAndType));
            }

            ScrollItemPattern sip = (ScrollItemPattern)element.GetCurrentPattern(ScrollItemPattern.Pattern);

            sip.ScrollIntoView();
        }
        public static void EnsureElementIsScrolledIntoView(this AutomationElement element)
        {
            if (!(bool)element.GetCurrentPropertyValue(AutomationElement.IsScrollItemPatternAvailableProperty))
            {
                return;
            }

            ScrollItemPattern scrollItemPattern = element.GetScrollItemPattern();

            scrollItemPattern.ScrollIntoView();
        }
Exemple #4
0
 public static bool ScrollTo(AutoElem e)
 {
     if (e.TryGetCurrentPattern(ScrollItemPattern.Pattern, out object obj))
     {
         ScrollItemPattern Pattern = obj as ScrollItemPattern;
         Pattern.ScrollIntoView();
         Console.WriteLine("scrolled to");
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private void ScrollPeopleListPrivate(string listViewId)
        {
            using (var setup = new TestSetupHelper("PersonPicture Tests"))
            {
                Log.Comment("Finding ListView");
                ListView peopleListView = new ListView(FindElement.ById(listViewId));
                Verify.IsNotNull(peopleListView, "ListView found");

                Log.Comment("Retrieving first ListView");
                ListViewItem firstLVI = peopleListView.AllItems[0];
                Verify.IsNotNull(firstLVI, "First ListViewItem retrieved");

                Log.Comment("Retrieving fifth ListView at index 4");
                ListViewItem fifthLVI = peopleListView.AllItems[4];
                Verify.IsNotNull(fifthLVI, "Fifth ListViewItem retrieved");

                Verify.IsFalse(firstLVI.IsOffscreen, "First item is on screen");
                Verify.IsTrue(fifthLVI.IsOffscreen, "Fifth item is off screen");

                firstLVI.SetFocus();
                Wait.ForIdle();

                AutomationElement firstItemAE = AutomationElement.FocusedElement;

                fifthLVI.SetFocus();
                Wait.ForIdle();

                AutomationElement fifthItemAE = AutomationElement.FocusedElement;

                Log.Comment("Scroll to the fifth item using the automation ScrollItemPattern");
                ScrollItemPattern fifthItemSIP = fifthItemAE.GetCurrentPattern(ScrollItemPattern.Pattern) as ScrollItemPattern;
                fifthItemSIP.ScrollIntoView();
                Wait.ForIdle();

                Verify.IsTrue(firstLVI.IsOffscreen, "First item is off screen");
                Verify.IsFalse(fifthLVI.IsOffscreen, "Fifth item is on screen");

                Log.Comment("Scroll back to the first item using the automation ScrollItemPattern");
                ScrollItemPattern firstItemSIP = firstItemAE.GetCurrentPattern(ScrollItemPattern.Pattern) as ScrollItemPattern;
                firstItemSIP.ScrollIntoView();
                Wait.ForIdle();

                Verify.IsFalse(firstLVI.IsOffscreen, "First item is on screen");
                Verify.IsTrue(fifthLVI.IsOffscreen, "Fifth item is off screen");
            }
        }
Exemple #6
0
        public static void ScrollIntoView(AutomationElement ae)
        {
            try
            {
                ScrollItemPattern pattern = ae.GetCurrentPattern(ScrollItemPattern.Pattern) as ScrollItemPattern;

                if (null == pattern)
                {
                    return;
                }

                pattern.ScrollIntoView();
            }
            catch
            {
            }
        }
        // </Snippet100>

        // <Snippet101>
        ///--------------------------------------------------------------------
        /// <summary>
        /// A Select, AddToSelection or RemoveFromSelection event handler that
        /// scrolls a SelectionItem object into the viewable region of its
        /// container control.
        /// </summary>
        ///--------------------------------------------------------------------
        private void OnSelectionItemSelect(
            object src, SelectionChangedEventArgs e)
        {
            AutomationElement selectionItem = src as AutomationElement;

            ScrollItemPattern scrollItemPattern = GetScrollItemPattern(selectionItem);

            if (scrollItemPattern == null)
            {
                return;
            }

            try
            {
                scrollItemPattern.ScrollIntoView();
            }
            catch (InvalidOperationException)
            {
                // The item cannot be scrolled into view.
                // TO DO: error handling.
            }
        }
Exemple #8
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal void pattern_ScrollIntoView(Type expectedException, CheckType checkType)
        {
            string call = "ScrollIntoView()";

            try
            {
                Comment("Before " + call + ", BoundingRectagle = '" + m_le.Current.BoundingRectangle + "'");
                _pattern.ScrollIntoView();
                Comment("After " + call + ", BoundingRectagle = '" + m_le.Current.BoundingRectangle + "'");
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                {
                    throw;
                }

                TestException(expectedException, actualException, call, checkType);
                return;
            }

            TestNoException(expectedException, call, checkType);
        }
Exemple #9
0
        public void ScrollIntoView()
        {
            ScrollItemPattern scroll = (ScrollItemPattern)item.GetCurrentPattern(ScrollItemPattern.Pattern);

            scroll.ScrollIntoView();
        }
Exemple #10
0
 public GridRow ScrollIntoView()
 {
     ScrollItemPattern?.ScrollIntoView();
     return(this);
 }
 public static void xtScrollIntoView(this UIItem item)
 {
     patt_ScrollItemPattern = Retry.For(() => ((ScrollItemPattern)item.AutomationElement.GetCurrentPattern(ScrollItemPattern.Pattern)), TimeSpan.FromSeconds(10));
     patt_ScrollItemPattern.ScrollIntoView();
 }
        /// <summary>
        ///     Scrolls the content area of a container object in order to display the control within the visible region (viewport) of the container.
        /// </summary>
        /// <param name = "control">The UI Automation element</param>
        /// <remarks>
        ///     This method does not provide the ability to specify the position of the control within the visible region (viewport) of the container
        /// </remarks>
        internal static void ScrollIntoView(AutomationElement control)
        {
            ScrollItemPattern pat = (ScrollItemPattern)CommonUIAPatternHelpers.CheckPatternSupport(ScrollItemPattern.Pattern, control);

            pat.ScrollIntoView();
        }