// protected System.Collections.Generic.Dictionary<string, string> convertHashtableToDictionary( // Hashtable hashtable) // { // System.Collections.Generic.Dictionary<string, string> dict = // new System.Collections.Generic.Dictionary<string, string>(); // // this.WriteVerbose(this, hashtable.Keys.Count.ToString()); // // foreach (string key1 in hashtable.Keys) { // // string keyUpper = key1.ToUpper(); // // this.WriteVerbose(this, "found key: " + keyUpper); // // dict.Add(keyUpper, hashtable[key1].ToString()); // // this.WriteVerbose(this, "added to the dictionary: " + // keyUpper + " = " + dict[keyUpper].ToString()); // } // // return dict; // } protected bool testControlWithAllSearchCriteria( GetCmdletBase cmdlet, Hashtable[] hashtables, AutomationElement element) { bool result = false; foreach (Hashtable hashtable in hashtables) { //cmdlet.WriteVerbose(cmdlet, "hashtable: " + hashtable.Keys); result = testControlByPropertiesFromDictionary( this.ConvertHashtableToDictionary(hashtable), element); if (result) { return result; } // if (! result) { // cmdlet.WriteVerbose(cmdlet, "test of the control has failed"); // return result; // } cmdlet.WriteVerbose(cmdlet, "test of the control has passed"); } //result = true; return result; }
internal void SearchByWildcardViaUIA( //GetControlCmdletBase cmdlet, //T cmdlet, //CommonCmdletBase cmdlet, //HasTimeoutCmdletBase cmdlet, GetCmdletBase cmdlet, ref ArrayList resultCollection, AutomationElement inputObject, string name, string automationId, string className, string strValue, System.Windows.Automation.AndCondition conditionsForWildCards) { this.WriteVerbose((cmdlet as PSTestLib.PSCmdletBase), "[getting the control] using WildCard search"); try { // string cmdletValue = string.Empty; // try { // cmdletValue = cmdlet.Value; // } // catch {} // 20130220 GetControlCollectionCmdletBase cmdlet1 = new GetControlCollectionCmdletBase( //cmdlet.InputObject, null != cmdlet.InputObject ? cmdlet.InputObject : (new AutomationElement[]{ AutomationElement.RootElement }), //null, name, //cmdlet.Name, automationId, //cmdlet.AutomationId, className, //cmdlet.Class, //cmdlet.Value, //string.Empty != cmdlet.Value ? cmdlet.Value : null, strValue, (new string[] {}), this.caseSensitive); try { this.WriteVerbose((cmdlet as PSTestLib.PSCmdletBase), "using the GetAutomationElementsViaWildcards_FindAll method"); ArrayList tempList = cmdlet1.GetAutomationElementsViaWildcards_FindAll( cmdlet1, inputObject, conditionsForWildCards, cmdlet1.CaseSensitive, false, false); cmdlet.WriteVerbose( cmdlet, "there are " + tempList.Count.ToString() + " elements that match the conditions"); foreach (AutomationElement tempElement2 in tempList) { if (null == cmdlet.SearchCriteria || 0 == cmdlet.SearchCriteria.Length) { resultCollection.Add(tempElement2); cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element added to the result collection (no SearchCriteria)"); } else { cmdlet.WriteVerbose(cmdlet, "WildCardSearch: checking search criteria"); if (testControlWithAllSearchCriteria(cmdlet, cmdlet.SearchCriteria, tempElement2)) { cmdlet.WriteVerbose(cmdlet, "WildCardSearch: the control matches the search criteria"); resultCollection.Add(tempElement2); cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element added to the result collection (SearchCriteria)"); } // cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element added to the result collection (SearchCriteria) (2)"); } // cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element added to the result collection (SearchCriteria) (3)"); } cmdlet.WriteVerbose(cmdlet, "WildCardSearch: element(s) added to the result collection: " + resultCollection.Count.ToString()); } catch (Exception eUnexpected) { // this.WriteVerbose(this, eUnexpected.Message); this.WriteError( this, "The input control or window has been possibly lost." + eUnexpected.Message, "UnexpectedError", ErrorCategory.ObjectNotFound, true); } } catch (Exception eWildCardSearch) { this.WriteError( cmdlet, "The input control or window has been possibly lost." + eWildCardSearch.Message, "UnexpectedError", ErrorCategory.ObjectNotFound, true); } }
// protected System.Collections.Generic.Dictionary<string, string> convertHashtableToDictionary( // Hashtable hashtable) // { // System.Collections.Generic.Dictionary<string, string> dict = // new System.Collections.Generic.Dictionary<string, string>(); // // this.WriteVerbose(this, hashtable.Keys.Count.ToString()); // // foreach (string key1 in hashtable.Keys) { // // string keyUpper = key1.ToUpper(); // // this.WriteVerbose(this, "found key: " + keyUpper); // // dict.Add(keyUpper, hashtable[key1].ToString()); // // this.WriteVerbose(this, "added to the dictionary: " + // keyUpper + " = " + dict[keyUpper].ToString()); // } // // return dict; // } protected internal bool TestControlWithAllSearchCriteria( GetCmdletBase cmdlet, Hashtable[] hashtables, AutomationElement element) { bool result = false; foreach (Hashtable hashtable in hashtables) { //cmdlet.WriteVerbose(cmdlet, "hashtable: " + hashtable.Keys); result = testControlByPropertiesFromDictionary( this.ConvertHashtableToDictionary(hashtable), element); if (result) { // 20130423 if (Preferences.HighlightCheckedControl) { UIAHelper.HighlightCheckedControl(element); } return result; } // if (! result) { // cmdlet.WriteVerbose(cmdlet, "test of the control has failed"); // return result; // } //cmdlet.WriteVerbose(cmdlet, "test of the control has passed"); cmdlet.WriteVerbose(cmdlet, "test of the control has finished"); } //result = true; return result; }