From 11b35d1b5cf3d18dfb95b03b5826bdad93aca33b Mon Sep 17 00:00:00 2001 From: "ivan.danilov-econ" Date: Thu, 1 Aug 2013 12:24:00 +0300 Subject: [PATCH] Added untyped native search criteria (e.g. for searching by RuntimeId property value). --- .../UIItems/Finders/SearchConditionFactory.cs | 6 ++++++ src/TestStack.White/UIItems/Finders/SearchCriteria.cs | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/TestStack.White/UIItems/Finders/SearchConditionFactory.cs b/src/TestStack.White/UIItems/Finders/SearchConditionFactory.cs index 63458bb1..5d55b6f8 100644 --- a/src/TestStack.White/UIItems/Finders/SearchConditionFactory.cs +++ b/src/TestStack.White/UIItems/Finders/SearchConditionFactory.cs @@ -63,5 +63,11 @@ public static SearchCondition CreateForNativeProperty(AutomationProperty automat var automationElementProperty = new AutomationElementProperty(value, automationProperty.ProgrammaticName, automationProperty); return new SimpleSearchCondition(automationElement => automationElement.GetCurrentPropertyValue(automationProperty), automationElementProperty); } + + public static SearchCondition CreateForNativeProperty(AutomationProperty automationProperty, object value) + { + var automationElementProperty = new AutomationElementProperty(value, automationProperty.ProgrammaticName, automationProperty); + return new SimpleSearchCondition(automationElement => automationElement.GetCurrentPropertyValue(automationProperty), automationElementProperty); + } } } \ No newline at end of file diff --git a/src/TestStack.White/UIItems/Finders/SearchCriteria.cs b/src/TestStack.White/UIItems/Finders/SearchCriteria.cs index f3406bae..6b01c92d 100644 --- a/src/TestStack.White/UIItems/Finders/SearchCriteria.cs +++ b/src/TestStack.White/UIItems/Finders/SearchCriteria.cs @@ -92,6 +92,11 @@ public static SearchCriteria ByNativeProperty(AutomationProperty automationPrope return new SearchCriteria(SearchConditionFactory.CreateForNativeProperty(automationProperty, value)); } + public static SearchCriteria ByNativeProperty(AutomationProperty automationProperty, object value) + { + return new SearchCriteria(SearchConditionFactory.CreateForNativeProperty(automationProperty, value)); + } + public static SearchCriteria ByControlType(Type testControlType, WindowsFramework framework) { var searchCriteria = new SearchCriteria(SearchConditionFactory.CreateForControlType(testControlType, framework)); @@ -201,6 +206,12 @@ public virtual SearchCriteria AndNativeProperty(AutomationProperty automationPro return this; } + public virtual SearchCriteria AndNativeProperty(AutomationProperty automationProperty, object value) + { + conditions.Insert(0, SearchConditionFactory.CreateForNativeProperty(automationProperty, value)); + return this; + } + public virtual List Filter(List automationElements) { return conditions.Filter(automationElements);