Determining Maximum Text Length in an Edit Control in Desktop Windows Applications

Applies to TestComplete 15.68, last modified on October 16, 2024

Note: To learn how to simulate user actions over text edit box controls in web applications, see Working With Text Edit Controls in Web Applications.

When working with an edit control you may need to find out the maximum length of the text. The number of characters a user can enter in an edit control is determined by the edit control’s properties, which are set by the developer. It means that you can only place, for example, 30 characters in the edit control and anymore input is impossible. You can modify the entered text, but its length can not be more than the specified limit.

While testing edit controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

You can obtain the text limit by using the wLimit property. This property belongs to the Win32Edit object, which is automatically associated with the edit control, when a test runs, and retrieves the maximum number of characters, which can be placed in current control.

The following code example demonstrates how you can obtain the maximum length of the text within the edit control:

JavaScript, JScript

// Post text limit to log
Log.Message (Edit.wLimit);

Python

# Post text limit to log
Log.Message (Edit.wLimit)

VBScript

' Post text limit to log
Log.Message Edit.wLimit

DelphiScript

// Post text limit to log
Log.Message(Edit.wLimit);

C++Script, C#Script

// Post text limit to log
Log["Message"](Edit["wLimit"]);

Note: If wLimit is equal to -1, it means that the text limit is not specified. In this case you use any amount of characters in the edit control.

See Also

Working With Edit Controls in Desktop Windows Applications
wLimit Property (Edit Controls)
Working With Text Edit Controls in Web Applications

Highlight search results