Forum Discussion

VasanthVijay's avatar
VasanthVijay
Contributor
10 years ago

how to get ipaddress using jscript in testcomplete?

Hi,

http://support.smartbear.com/viewarticle/24733/

I tried with above link not working.

I need to get ipaddress using jscirpt?

Kindly help me in this case.

  • function GetSystemIpAddress()
    {
    var strQuery = "select * from Win32_NetworkAdapterConfiguration where IPEnabled=True"
    var objectsList = GetObject("winmgmts:").ExecQuery(strQuery)
    if (objectsList.Count > 0)
    {
    eObjectsList = new Enumerator(objectsList);
    for (; !eObjectsList.atEnd(); eObjectsList.moveNext())
    {
    item = eObjectsList.item();
    Log.Message(item.IPAddress(0));
    break;
    }
    }
    }

     

    This the jscript for getting the system ipaddress..Try this.

  • function GetSystemIpAddress()
    {
    var strQuery = "select * from Win32_NetworkAdapterConfiguration where IPEnabled=True"
    var objectsList = GetObject("winmgmts:").ExecQuery(strQuery)
    if (objectsList.Count > 0)
    {
    eObjectsList = new Enumerator(objectsList);
    for (; !eObjectsList.atEnd(); eObjectsList.moveNext())
    {
    item = eObjectsList.item();
    Log.Message(item.IPAddress(0));
    break;
    }
    }
    }

     

    This the jscript for getting the system ipaddress..Try this.

    • Prodigio's avatar
      Prodigio
      Occasional Contributor

      I've tried the solution above, but couldn't get it working.

       

      I'm getting the "JavaScript runtime error" with "Invalid number of parameters".

       

      Unfortunately I'm totally new to JavaScript, so I don't know how to fix that.

       

      I also found other ways of how one could get the IP Address of the machine, where TestComplete is running on, but they felt way more difficult than this one.

       

      I'd appreciate any help on this!