Quality Testing

Quality is delighting customers

Can anyone let me know how to print IP address of system without third party URL using selenium web driver.

Views: 2220

Reply to This

Replies to This Discussion

none of selenium family are designed for detecting system parameters like IP

Selenium as such is not designed to figure out system parameters. Selenium webdriver is a library designed to handle webpage objects, so in no way it can figure out IP address or type of connection to network.

If you are using webdriver/selenium RC Java/C# library then there are other utilities in java and dotnet framework that can help you.

easier way to reach your goal is to find out few websites that can show up your IP address from which the site was opened maybe like your ISP website or google (look bottom part of the page you can see the IP address) and extract using selenium apis.

So you want to get IP address of computer which the test is running? Well - let's start with the problems. Multiple network interfaces - that's normal now days. If you open cmd.exe (I assume you're running Windows) and write "ipconfig" you get list of the network interfaces you have.

My laptop has 4 different IP-addresses. One for WiFi, 3 for virtual machines. Second problem is that it is very likely that the server won't see the same IP address as your machine has. E.g. my machine has IP address 192.168.11.65. Servers won't see that if they are not inside my network. That is private network address. The servers 88.115.123.132  kind of IP address. Why? Well - my home network has about 10 different machines connected to network. It is very expensive to have public IP addresses for all of those. It would be also the security risk. So - I have private network with private addresses. Router is only one which has public IP. That IT is visible for everyone else outside my network, but I don't see it.

If you still want to get IP address of you machine, then at Java:

System.out.println(InetAddress.getLocalHost().getHostAddress());

That shows only one IP address. And it's always the  one which is at machine and not necessarily the public one. 

System.out.println(InetAddress.getLocalHost().getHostAddress());

provided code is correct but the class is Java class and not standalone web driver. You can also refer below link using Java automation

http://www.developer.com/java/java-automation-using-core-java.html

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service