GetPreviousSibling() 공개 메소드

public GetPreviousSibling ( AutomationElement element ) : AutomationElement
element AutomationElement
리턴 AutomationElement
 public void TreeIterationTest()
 {
     TreeWalker walker = new TreeWalker(Automation.ControlViewCondition);
     AutomationElement startingElement = ExplorerTargetTests.explorerHost.Element;
     AutomationElement iter = startingElement;
     iter = walker.GetFirstChild(iter);
     iter = walker.GetNextSibling(iter);
     iter = walker.GetParent(iter);
     Assert.AreEqual(startingElement, iter);
     iter = walker.GetLastChild(iter);
     iter = walker.GetPreviousSibling(iter);
     iter = walker.GetParent(iter);
     Assert.AreEqual(startingElement, iter);
 }
예제 #2
0
		private void VerifyGetPreviousSibling (TreeWalker tree, AutomationElement rootElement, AutomationElement expectedElement)
		{
			AutomationElement actualChild = tree.GetPreviousSibling (rootElement);
			Assert.AreEqual (expectedElement, actualChild,
				String.Format ("GetPreviousSibling with root element named {0}: Expected element named {1}, got element named {2}",
				GetName (rootElement), GetName (expectedElement), GetName (actualChild)));
			if (expectedElement != null)
				Assert.AreNotSame (expectedElement, actualChild, "GetPreviousSibling returns a new instance");
		}
        protected void GetAutomationElementsSiblings(bool nextSibling)
        {
            if (!this.CheckControl(this)) { return; }

            System.Windows.Automation.TreeWalker walker =
                new System.Windows.Automation.TreeWalker(
                    System.Windows.Automation.Condition.TrueCondition);

            // 20120823
            foreach (AutomationElement inputObject in this.InputObject) {

                AutomationElement sibling = null;
                if (nextSibling) {
                    // 20120823
                    //sibling = walker.GetNextSibling(this.InputObject);
                    sibling = walker.GetNextSibling(inputObject);
                } else {
                    // 20120823
                    //sibling = walker.GetPreviousSibling(this.InputObject);
                    sibling = walker.GetPreviousSibling(inputObject);
                }
                WriteObject(this, sibling);

            } // 20120823
        }
예제 #4
0
		public void GetPreviousSiblingTest ()
		{
			Condition buttonCondition = new PropertyCondition (AEIds.ControlTypeProperty, ControlType.Button);
			TreeWalker buttonWalker = new TreeWalker (buttonCondition);

			AssertRaises<ArgumentNullException> (
				() => buttonWalker.GetPreviousSibling (null),
				"passing null to TreeWalker.GetPreviousSibling");

			//VerifyGetPreviousSibling (buttonWalker, button7Element, null); // TODO: scrollbar button

			VerifyGetPreviousSibling (buttonWalker, button6Element, button7Element);
			VerifyGetPreviousSibling (buttonWalker, button5Element, button6Element);
			VerifyGetPreviousSibling (buttonWalker, button4Element, button5Element);
			VerifyGetPreviousSibling (buttonWalker, button3Element, button4Element);
			VerifyGetPreviousSibling (buttonWalker, button2Element, button3Element);

			// TODO: Test how for buttonWalker, GetPreviousSibling
			//       eventually gets all buttons on the entire
			//       desktop?

			// Elements whose parents (not the desktop) are also in
			// the tree run out of siblings as expected.
			Condition groupCondition = new PropertyCondition (AEIds.ControlTypeProperty, ControlType.Group);
			TreeWalker groupWalker = new TreeWalker (groupCondition);

			VerifyGetPreviousSibling (groupWalker, groupBox3Element, null);
			VerifyGetPreviousSibling (groupWalker, groupBox2Element, groupBox3Element);
		}