I am trying to read the Text from RichTextBox using White's UI automation framework however it always returns null.
Already added the below code to the RichtextBox.cs
protected override AutomationPeer OnCreateAutomationPeer()
{
return new RichTextBoxAutomationPeer(this);
}
Is there any workaround to get the text? or by using TextPattern?
I have been using white for a while now, I know this is really late , but i had the same issue. I have used text pattern to get the value from a rich text box, find the sample code below , hope this helps in anyway.
AutomationElement ele =window.GetElement(SearchCriteria.ByAutomationId("richTextBoxId>"));
if (ele != null)
{
TextPattern txtPattern = ele.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
String controlText = txtPattern.DocumentRange.GetText(-1);
Debug.WriteLine("the text is" + controlText);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With