public static IUiElement PerformNavigateToNextSibling(this IUiElement element) { IUiElement result = null; var walker = new classic.TreeWalker(classic.Condition.TrueCondition); try { result = AutomationFactory.GetUiElement(walker.GetNextSibling(element.GetSourceElement() as classic.AutomationElement)); } catch { } return(result); }
public static IUiElement PerformNavigateToNextSibling(this IUiElement element) { IUiElement result = null; var walker = new classic.TreeWalker(classic.Condition.TrueCondition); try { result = AutomationFactory.GetUiElement(walker.GetNextSibling(element.GetSourceElement() as classic.AutomationElement)); } catch { } return result; }
protected void GetAutomationElementsSiblings(bool nextSibling) { if (!CheckAndPrepareInput(this)) { return; } var walker = new classic.TreeWalker( classic.Condition.TrueCondition); // 20120823 // 20131109 //foreach (AutomationElement inputObject in this.InputObject) { /* foreach (IUiElement sibling in from inputObject in InputObject let sibling = null select nextSibling ? ObjectsFactory.GetUiElement(walker.GetNextSibling(inputObject.GetSourceElement())) : ObjectsFactory.GetUiElement(walker.GetPreviousSibling(inputObject.GetSourceElement()))) { //if (nextSibling) { // // 20120823 // //sibling = walker.GetNextSibling(this.InputObject); // sibling = walker.GetNextSibling(inputObject); //} else { // // 20120823 // //sibling = walker.GetPreviousSibling(this.InputObject); // sibling = walker.GetPreviousSibling(inputObject); //} // 20131113 // WriteObject(this, sibling); WriteObject(this, sibling); } */ // 20140111 // foreach (IUiElement sibling in from inputObject in InputObject let sibling = null select nextSibling ? AutomationFactory.GetUiElement(walker.GetNextSibling(inputObject.GetSourceElement() as AutomationElement)) : AutomationFactory.GetUiElement(walker.GetPreviousSibling(inputObject.GetSourceElement() as AutomationElement))) // { // WriteObject(this, sibling); // } foreach (IUiElement inputObject in InputObject) { IUiElement sibling = null; // 20140102 // sibling = nextSibling ? AutomationFactory.GetUiElement(walker.GetNextSibling(inputObject.GetSourceElement())) : AutomationFactory.GetUiElement(walker.GetPreviousSibling(inputObject.GetSourceElement())); sibling = nextSibling ? AutomationFactory.GetUiElement(walker.GetNextSibling(inputObject.GetSourceElement() as classic.AutomationElement)) : AutomationFactory.GetUiElement(walker.GetPreviousSibling(inputObject.GetSourceElement() as classic.AutomationElement)); WriteObject(this, sibling); } // 20120823 /* foreach (IUiElement inputObject in this.InputObject) { // 20131109 //AutomationElement sibling = null; //sibling = nextSibling ? walker.GetNextSibling(inputObject) : walker.GetPreviousSibling(inputObject); IUiElement sibling = null; // 20131112 //sibling = nextSibling ? (new UiElement(walker.GetNextSibling(inputObject.SourceElement))) : (new UiElement(walker.GetPreviousSibling(inputObject.SourceElement))); sibling = nextSibling ? ObjectsFactory.GetUiElement(walker.GetNextSibling(inputObject.SourceElement)) : ObjectsFactory.GetUiElement(walker.GetPreviousSibling(inputObject.SourceElement)); //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 */ }
private List<IUiElement> GetAutomationElementsWithWalker( IUiElement element, string name, string automationId, string className, string[] controlType, bool caseSensitive, bool onlyOneResult, bool onlyTopLevel) { var resultCollection = new List<IUiElement>(); var walker = new classic.TreeWalker( classic.Condition.TrueCondition); try { IUiElement oneMoreElement = AutomationFactory.GetUiElement(walker.GetFirstChild(element.GetSourceElement() as classic.AutomationElement)); resultCollection = ProcessAutomationElement( oneMoreElement, name, automationId, className, controlType, caseSensitive, onlyOneResult, onlyTopLevel); if ((onlyTopLevel || onlyOneResult) && (null != resultCollection) && resultCollection.Count > 0) { return resultCollection; } else if (null != resultCollection) { WriteObject(this, resultCollection); } while (oneMoreElement != null) { oneMoreElement = AutomationFactory.GetUiElement(walker.GetNextSibling(oneMoreElement.GetSourceElement() as classic.AutomationElement)); resultCollection = ProcessAutomationElement( oneMoreElement, name, automationId, className, controlType, caseSensitive, onlyOneResult, onlyTopLevel); if ((onlyTopLevel || onlyOneResult) && (null != resultCollection) && resultCollection.Count > 0) { return resultCollection; } else if (null != resultCollection) { WriteObject(this, resultCollection); } } } catch {} walker = null; return resultCollection; }
protected void GetAutomationElementsSiblings(bool nextSibling) { if (!CheckAndPrepareInput(this)) { return; } var walker = new classic.TreeWalker( classic.Condition.TrueCondition); // 20120823 // 20131109 //foreach (AutomationElement inputObject in this.InputObject) { /* * foreach (IUiElement sibling in from inputObject in InputObject let sibling = null select nextSibling ? ObjectsFactory.GetUiElement(walker.GetNextSibling(inputObject.GetSourceElement())) : ObjectsFactory.GetUiElement(walker.GetPreviousSibling(inputObject.GetSourceElement()))) * { * //if (nextSibling) { * // // 20120823 * // //sibling = walker.GetNextSibling(this.InputObject); * // sibling = walker.GetNextSibling(inputObject); * //} else { * // // 20120823 * // //sibling = walker.GetPreviousSibling(this.InputObject); * // sibling = walker.GetPreviousSibling(inputObject); * //} * * // 20131113 * // WriteObject(this, sibling); * WriteObject(this, sibling); * } */ // 20140111 // foreach (IUiElement sibling in from inputObject in InputObject let sibling = null select nextSibling ? AutomationFactory.GetUiElement(walker.GetNextSibling(inputObject.GetSourceElement() as AutomationElement)) : AutomationFactory.GetUiElement(walker.GetPreviousSibling(inputObject.GetSourceElement() as AutomationElement))) // { // WriteObject(this, sibling); // } foreach (IUiElement inputObject in InputObject) { IUiElement sibling = null; // 20140102 // sibling = nextSibling ? AutomationFactory.GetUiElement(walker.GetNextSibling(inputObject.GetSourceElement())) : AutomationFactory.GetUiElement(walker.GetPreviousSibling(inputObject.GetSourceElement())); sibling = nextSibling ? AutomationFactory.GetUiElement(walker.GetNextSibling(inputObject.GetSourceElement() as classic.AutomationElement)) : AutomationFactory.GetUiElement(walker.GetPreviousSibling(inputObject.GetSourceElement() as classic.AutomationElement)); WriteObject(this, sibling); } // 20120823 /* * foreach (IUiElement inputObject in this.InputObject) { * * // 20131109 * //AutomationElement sibling = null; * //sibling = nextSibling ? walker.GetNextSibling(inputObject) : walker.GetPreviousSibling(inputObject); * IUiElement sibling = null; * // 20131112 * //sibling = nextSibling ? (new UiElement(walker.GetNextSibling(inputObject.SourceElement))) : (new UiElement(walker.GetPreviousSibling(inputObject.SourceElement))); * sibling = nextSibling ? ObjectsFactory.GetUiElement(walker.GetNextSibling(inputObject.SourceElement)) : ObjectsFactory.GetUiElement(walker.GetPreviousSibling(inputObject.SourceElement)); * * * //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 */ }
private List <IUiElement> GetAutomationElementsWithWalker( IUiElement element, string name, string automationId, string className, string[] controlType, bool caseSensitive, bool onlyOneResult, bool onlyTopLevel) { var resultCollection = new List <IUiElement>(); var walker = new classic.TreeWalker( classic.Condition.TrueCondition); try { IUiElement oneMoreElement = AutomationFactory.GetUiElement(walker.GetFirstChild(element.GetSourceElement() as classic.AutomationElement)); resultCollection = ProcessAutomationElement( oneMoreElement, name, automationId, className, controlType, caseSensitive, onlyOneResult, onlyTopLevel); if ((onlyTopLevel || onlyOneResult) && (null != resultCollection) && resultCollection.Count > 0) { return(resultCollection); } else if (null != resultCollection) { WriteObject(this, resultCollection); } while (oneMoreElement != null) { oneMoreElement = AutomationFactory.GetUiElement(walker.GetNextSibling(oneMoreElement.GetSourceElement() as classic.AutomationElement)); resultCollection = ProcessAutomationElement( oneMoreElement, name, automationId, className, controlType, caseSensitive, onlyOneResult, onlyTopLevel); if ((onlyTopLevel || onlyOneResult) && (null != resultCollection) && resultCollection.Count > 0) { return(resultCollection); } else if (null != resultCollection) { WriteObject(this, resultCollection); } } } catch {} walker = null; return(resultCollection); }