Forum Discussion

sergiobzh's avatar
sergiobzh
New Contributor
15 years ago

get IP adress of localhost

Hello
sorry if my question is very simple but I am a beginner in soapUI.
In a testCase I try to get the IP adress of the localhost (the host on which soapUI is running) . How can I do ?
Thanks a lot.
Sergio

2 Replies

  • Hi Sergio,

    Here we go, just add a groovy script test step with following code lines:

    import java.net.InetAddress;
    localhost = InetAddress.getLocalHost();
    log.info "My local machine name | IP address is : " + localhost
    log.info "Only IP Address : " + localhost.getHostAddress()

    Hope this helps :-)

    Best Regards,
    /Pradeep Bishnoi
    http://learnsoapui.wordpress.com
  • sergiobzh's avatar
    sergiobzh
    New Contributor
    Hello,

    becos I am beginner I dont think to use java which is more elegant than what I used (I am under Windows XP) :
    Process pp = "ipconfig".execute()
    It is not very convenient because dependant of the OS

    Your solution is more elegant and multi-platform

    Thanks for the reply.
    Sergio