private static void LogDumpTreeWorker(string indent, UIObject current) { Log.Comment(indent + current.GetDescription()); indent += " "; foreach (var uiObject in current.Children) { LogDumpTreeWorker(indent, uiObject); } }
public static string GetTextSelection(this UIObject textControl, bool shouldTrim = true) { string textControlContents = null; TextImplementation textImplementation = new TextImplementation(textControl); if (textImplementation.IsAvailable) { textControlContents = textImplementation.SupportsTextSelection ? textImplementation.GetSelection().GetText(-1) : string.Empty; } else { Verify.Fail(string.Format("Expected the text control to implement IText. {0} is {1}", string.IsNullOrEmpty(textControl.AutomationId) ? textControl.Name : textControl.AutomationId, textControl.GetDescription())); } // On phone, copying or pasting text causes a space to be added at the end. // Unless we explicitly care about that space, we'll remove it from the return value. if (shouldTrim) { textControlContents = textControlContents.Trim(); } return(textControlContents); }