截至目前,我所做的事情如下:
driver.get("http://www.whatismyip.com/");
String myIP = driver.findElement(By.id("greenip")).getText();
System.out.println(myIP);
有没有更好的方法呢?
(注:我尝试了这个解决方案,但NetworkInterface会给出多个IP地址,而InetAddress.getLocalHost().getHostAddress()
则会给出错误的IP地址。)