Thursday, April 8, 2010

QTP - Find system IP

QTP - Find system IP

If your test is getting executed from different location, it is always a good practice to capture the system IP, so that we can distinguish the results clearly.  

Attaching sample code.

strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress > ''"
Set colItems      = goWMIService.ExecQuery( strQuery, "WQL", 48 )
For Each objItem In colItems
    If IsArray( objItem.IPAddress ) Then
        If UBound( objItem.IPAddress ) = 0 Then
            strIP = objItem.IPAddress(0)
            strIP = Join( objItem.IPAddress, "," )
        End If
    End If
Set colItems      = Nothing
Print strIP

In the following article, system will detect the location name based on the IP address. If no matching location is found based on the IP address, it would treat IP address as location Schedule framework or test using AOM script.


No comments:

Post a Comment