Clearing the IP Address Field in Desktop Windows Applications

Applies to TestComplete 15.40, last modified on July 05, 2022

While testing IP Address 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.

To clear the IP address field in the IP Address control, use the Clear method of the Win32IPAddress object. TestComplete associates this object with IP Address controls whose class names are listed in the Object Mapping options of your project.

Below is an example that demonstrates how you can clear the IP Address control labeled as IP address and located in the operating system's Internet Protocol (TCP/IP) Properties window:

JavaScript, JScript

function main()
{
  var IPAddress;
    
  // Obtain the IP Address control
  IPAddress = Sys.Process("Explorer").Window("#32770", "Internet Protocol (TCP/IP) Properties", 1).Window("#32770", "General", 1).Window("SysIPAddress32", "", 1);
    
  // Clear the IP address field
  IPAddress.Clear();
}

Python

def Main():
    
  # Obtain the IP Address control
  IPAddress = Sys.Process("Explorer").Window("#32770", "Internet Protocol (TCP/IP) Properties", 1).Window("#32770", "General", 1).Window("SysIPAddress32", "", 1)
    
  # Clear the IP address field
  IPAddress.Clear()

VBScript

Sub main
  Dim IPAddress
    
  ' Obtain the IP Address control
  Set IPAddress = Sys.Process("Explorer").Window("#32770", "Internet Protocol (TCP/IP) Properties", 1).Window("#32770", "General", 1).Window("SysIPAddress32", "", 1)

  ' Clear the IP address field
  IPAddress.Clear
End Sub

DelphiScript

procedure main;
var IPAddress;
begin
  
  // Obtain the IP Address control
  IPAddress := Sys.Process('Explorer').Window('#32770', 'Internet Protocol (TCP/IP) Properties', 1).Window('#32770', 'General', 1).Window('SysIPAddress32', '', 1);
       
  // Clear the IP address field
  IPAddress.Clear;
end;

C++Script, C#Script

function main()
{
  var IPAddress;
    
  // Obtain the IP Address control
  IPAddress = Sys["Process"]("Explorer")["Window"]("#32770", "Internet Protocol (TCP/IP) Properties", 1)["Window"]("#32770", "General", 1)["Window"]("SysIPAddress32", "", 1);
  
  // Clear the IP address field
  IPAddress["Clear"]();
}

See Also

Working With IP Address Controls in Desktop Windows Applications
Clear Method (IPAddress Controls)

Highlight search results