I have a spring mvc web-app which basically runs selenium test on client machine.
I have created a selenium-hub and node in client system by using following commands -
>java -jar selenium-server-standalone-3.0.1.jar -role hub
>java -Dwebdriver.ie.driver=D:\IEDriver\IEDriverServer.exe -jar selenium-server-standalone-3.0.1.jar -role node -hub http://localhost:4444/grid/register -timeout 20 -browserTimeout 60
my spring controller takes parameters for url and runs a selenium test using that parameter in client system using RemoteWebDriver
here is my spring controller-
@RequestMapping("/remote-app/{policyNumber}")
public @ResponseBody String getOIPA(@PathVariable("policyNumber") String polNumber,HttpServletRequest request) throws MalformedURLException
{
String clientIp = request.getRemoteAddr();
System.out.println("Input policy number : "+polNumber);
System.out.println("Client IP : "+clientIp);
oipaService.openOipaAddressScreenRemote(polNumber,clientIp);
return "hello "+polNumber+" "+clientIp;
}
here is my service method which runs the tests -
public void openOipaAddressScreenRemote(String policyNumber,String ip) throws MalformedURLException {
System.out.println("Policy number input : "+policyNumber);
String oipaURL = "https://mydom.com/PASJava_Term";
String userName = "user";
String password = "pwd";
//-------------------
String remoteUrlString = "http://"+ip+":4444/wd/hub";
System.out.println(remoteUrlString);
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new RemoteWebDriver(new URL(remoteUrlString),caps);
//-------------------
driver.get(oipaURL);}
It gives me desired results in my organization's client systems (PC), which connects to IPv4 address of client.
But the problem is, when I use Laptop clients in my organization, it returns me IPv6, which the app is not able to connect.
They are getting connected by laptop names, e.g. - lt00123.
i.e. selenium RemoteWebDriver is able to connect to http://lt00123:4444/wd/hub
How to identify the client address (ipv4 , or machine name) as required if it is at all possible.
EDIT: after using solution from here I solved the IPv6 problem. And from here I found that I need to set up hub at one machine (preferably in server location), and node at client machine using the hub. now my spring controller doesn't need to know client's address. It already knows the location of hub.