Skip to content

Commit ebd425a

Browse files
author
Olivier Mireault
committed
If a frameworkId is not set in a AutomationElement, I make an attempt to climb up the parent chain to find one. This avoids a Label element lookup returning multiple ControlType matches.
1 parent 3c12f78 commit ebd425a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/TestStack.White/Mappings/ControlDictionary.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,17 @@ public virtual bool IsEditable(UIItem uiItem)
215215

216216
public virtual Type GetTestControlType(AutomationElement automationElement)
217217
{
218+
TreeWalker tWalker = TreeWalker.ControlViewWalker;
218219
AutomationElement.AutomationElementInformation current = automationElement.Current;
219-
return GetTestControlType(current.ClassName, current.Name, current.ControlType, current.FrameworkId, current.NativeWindowHandle != 0);
220+
AutomationElement parent = tWalker.GetParent(automationElement);
221+
String frameId = current.FrameworkId;
222+
while (string.IsNullOrEmpty(frameId) || tWalker.GetParent(parent) != null)
223+
{
224+
frameId = parent.Current.FrameworkId;
225+
parent = tWalker.GetParent(parent);
226+
}
227+
228+
return GetTestControlType(current.ClassName, current.Name, current.ControlType, frameId, current.NativeWindowHandle != 0);
220229
}
221230
}
222231
}

0 commit comments

Comments
 (0)