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.
You can set an address in the IP Address control by doing one of the following:
- Assign a value to the
wAddress
property of theWin32IPAddress
object. During the test run, this object will be automatically associated with IP Address controls whose class names are listed in the project’s Object Mapping options.The
wAddress
property specifies the IP address as a string. This string consists of four three-digit fields separated by periods. The range of values each field can contain is from 0 to 255.Below is an example that demonstrates how you can assign a value to the IP Address control that is labeled 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);
// Set an IP address
IPAddress.wAddress = "192.168.1.125";
}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) # Set an IP address IPAddress.wAddress = "192.168.1.125"
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)
' Set an IP address
IPAddress.wAddress = "192.168.1.125"
End SubDelphiScript
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);
// Set an IP address
IPAddress.wAddress := '192.168.1.125';
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);
// Set an IP address
IPAddress["wAddress"] = "192.168.1.125";
} -
Use the
SetAddress
method of theWin32IPAddress
object to set an IP address as a sequence of four three-digit numbers within the range from 0 to 255. TheSetAddress
method has four parameters that correspond to these numbers.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);
// Set an IP address
IPAddress.SetAddress ("192","168","1","125");
}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) # Set an IP address IPAddress.SetAddress ("192","168","1","125")
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)
' Set an IP address
IPAddress.SetAddress "192","168","1","125"
End SubDelphiScript
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);
// Set an IP address
IPAddress.SetAddress ('192','168','1','125');
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);
// Set an IP address
IPAddress["SetAddress"] ("192","168","1","125");
}
See Also
Working With IP Address Controls in Desktop Windows Applications
wAddress Property (IPAddress Controls)
SetAddress Method (IPAddress Controls)