GetText
void GetText(string control)Description
Retrieves the content text of a UI control.
This first tries to use the ValuePattern, and if the control does not support it, falls back to the TextPattern in UIAutomation.
It returns the actual text value currently displayed inside the control.
Typical use cases
- TextBox input (e.g. user typed "Max" → Text = "Max")
- ProgressBar text (e.g. "75 %")
- Editable ComboBox current value
Notes
- This method does not return labels, captions, or accessible names; use GetName for those.
- ValuePattern is used for standard input fields, while TextPattern is used for rich text or multi-line controls.
Parameters
- control - Identifier of the UI control.
Returns
- string - The current text content of the control.
Example
void main()
{
string userInput = GetText("TXT_USERNAME");
VerifyEqual(userInput, "Max");
}