diff --git a/src/TestStack.White/TestStack.White.csproj b/src/TestStack.White/TestStack.White.csproj index 05976354..d001a9a5 100644 --- a/src/TestStack.White/TestStack.White.csproj +++ b/src/TestStack.White/TestStack.White.csproj @@ -160,6 +160,7 @@ + diff --git a/src/TestStack.White/UIItems/UIItemExtensions.cs b/src/TestStack.White/UIItems/UIItemExtensions.cs new file mode 100644 index 00000000..4b4a5f60 --- /dev/null +++ b/src/TestStack.White/UIItems/UIItemExtensions.cs @@ -0,0 +1,18 @@ +using System.Windows.Automation; +using TestStack.White.Factory; + +namespace TestStack.White.UIItems +{ + public static class UIItemExtensions + { + // DictionaryMappedItemFactory does not have any state and could be shared + private static readonly UIItemFactory ItemFactory = new DictionaryMappedItemFactory(); + + public static T GetParent(this IUIItem thisItem) where T : IUIItem + { + var parent = TreeWalker.ControlViewWalker.GetParent(thisItem.AutomationElement); + var uiItem = ItemFactory.Create(parent, thisItem.ActionListener); + return (T) UIItemProxyFactory.Create(uiItem, uiItem.ActionListener); + } + } +} \ No newline at end of file