Skip to content

Instantly share code, notes, and snippets.

@thakurarun
Created November 11, 2013 11:59
Show Gist options
  • Save thakurarun/7412165 to your computer and use it in GitHub Desktop.
Save thakurarun/7412165 to your computer and use it in GitHub Desktop.
It finds the first specified type of control in calling method, and return it;
public static T FindFirstSelectControlInControl_ExtentionMethod<T>(UITestControl ControlInWhichSelectControlCanBeFound)
{
T element = default(T);
var childrenControl = ControlInWhichSelectControlCanBeFound.GetChildren();
if (childrenControl.Count > 0)
{
childrenControl.All(x =>
{
if (x is T)
{
element = (T)Convert.ChangeType(x, typeof(T));
return false;
}
else
{
element = FindFirstSelectControlInControl_ExtentionMethod<T>(x);
if (element != null) return false;
return true;
}
});
}
return element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment