[英]How to check the ipV6 address in selenium with java?
应用程序正在显示Ipv6地址。 我的硒项目使用代码dataValid=IntegerValidator.getInstance().isValid("<<IP>>");
但这会返回IPV4
因此测试失败。 我需要返回IPV6
。
我尝试过isValidInet6Address(String inet6Address)
方法,但是
The method isValidInet6Address(String) is undefined for the type InetAddressValidator
显示错误
请尝试使用httpclient库中的InetAddressUtils:
import org.apache.http.conn.util.InetAddressUtils;
public class TestIp {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(InetAddressUtils.isIPv6Address("2001:cdba:0000:0000:0000:0000:3257:9652")); //true
System.out.println(InetAddressUtils.isIPv6Address("2001:cdba::3257:9652")); //true
System.out.println(InetAddressUtils.isIPv6Address("2001:cdba:0:0:0:0:3257:9652")); //true
System.out.println(InetAddressUtils.isIPv6Address("185.23.56.32")); //false
System.out.println(InetAddressUtils.isIPv4Address("192.168.0.5")); //true
System.out.println(InetAddressUtils.isIPv4Address("2001:cdba:0:0:0:0:3257:9652")); //false
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.