Description
The SetText
action sets the textual contents of a control, that is, replaces the existing contents with the specified text and then emulates touching the enter (return) key.
Declaration
TestObj.SetText(Text)
TestObj | A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section | |||
Text | [in] | Required | String | |
Result | None |
Applies To
The method is applied to the following objects:
Android EditText, iOS TextField, iOS TextView and 2 more objects, Xamarin.Forms Editor, Xamarin.Forms Entry « Collapse the list
View Mode
This method is available in the Object Browser panel and in other panels and dialogs in both Basic and Advanced view modes.
Parameters
The method has the following parameter:
Text
The text to enter in the control. To enter multi-line text in a multi-line control, separate the lines by using new line characters or the corresponding constants.
Result Value
None.
Remarks
-
The
SetText
action fails when it is called for a disabled or read-only control. -
To get a control’s text, use the
wText
property. You can also use it to set text without posting a notification to the log. -
To enter text in certain place within a control, to simulate keystrokes in a control or to simulate character-by-character input, use the
Keys
action.
Example
To view an example that demonstrates how to use the SetText
method to enter text into an Android text edit control, see Entering Text into an Edit Text Control.
For an example that demonstrates how to use the SetText
method to enter text in an iOS text edit control, see Entering Text in an Edit Control.
Possible Issues
If you use the Android onscreen keyboard during the test recording, TestComplete may detect and record the Backspace key input incorrectly. To work around this issue, use the TestComplete Android Agent keyboard to record keyboard input.
To learn more about installing and enabling the TestComplete Android Agent keyboard, see About TestComplete Android Agent Keyboard.
To learn about other issues that may occur when testing Android applications, see Possible Issues With Android Applications.
See Also
Testing Android Applications
Testing iOS Applications
Entering Text into an Edit Text Control
Entering Text in an Edit Control
wText Property (Mobile Edit Controls)