2

I'm trying to launch remoteWebdriver, for that I have created a hub progmatically then I have added a node on it. That is fine.The problem now when I execute:

Thread.currentThread().join();

The program stop executing, and if I remove this line I get error.

try{
      String strIP = "localhost";

        GridHubConfiguration config = new GridHubConfiguration();
        config.setTimeout(30000000);
        config.setPort(4444);
        config.setHost(strIP);

        Hub hub = new Hub(config);
        hub.start();
        RegistrationRequest req = new RegistrationRequest();
        req.setRole(GridRole.NODE);
        Map<String, Object> nodeConfiguration = new HashMap<>();
        nodeConfiguration.put(RegistrationRequest.PROXY_CLASS, DefaultRemoteProxy.class.getName());

        nodeConfiguration.put(RegistrationRequest.MAX_SESSION, 5);
        nodeConfiguration.put(RegistrationRequest.PORT, 5555);
        nodeConfiguration.put(RegistrationRequest.HOST, 4444);
        nodeConfiguration.put(RegistrationRequest.AUTO_REGISTER, true);
        nodeConfiguration.put(RegistrationRequest.REGISTER_CYCLE, 5000);
        nodeConfiguration.put(RegistrationRequest.HUB_HOST, "localhost");
        nodeConfiguration.put(RegistrationRequest.HUB_PORT, 4444);
        nodeConfiguration.put("remoteHost", "http://" + strIP + ":5555");
        nodeConfiguration.put("url", "http://" + strIP + ":5555");

        nodeConfiguration.put("role", "node");
        nodeConfiguration.put("hub", "http://localhost:4444/grid/register");
        URL remoteURL = new URL("http://" + strIP + ":5555");
        nodeConfiguration.put(RegistrationRequest.REMOTE_HOST, remoteURL.toExternalForm());

        req.setConfiguration(nodeConfiguration);
        DesiredCapabilities capabilities2 = DesiredCapabilities.chrome();
        capabilities2.setCapability("browserName", "chrome");
        capabilities2.setCapability("platform", "WINDOWS");
        capabilities2.setCapability("ensureCleanSession", "true");
        capabilities2.setCapability("maxInstances", 5);
        req.addDesiredCapability(capabilities2);
        SelfRegisteringRemote remote = new SelfRegisteringRemote(req);
        remote.setRemoteServer(new SeleniumServer(req.getConfiguration()));
        remote.startRemoteServer();
        remote.startRegistrationProcess();

            WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/register"),DesiredCapabilities.chrome());

        Thread.currentThread().join();

              String URL="http://localhost:4444/wd/hub";

        WebDriver driver = new RemoteWebDriver(new URL(URL),DesiredCapabilities.chrome());
        driver.get("https://www.youtube.com");  

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Ihor Patsian
  • 1,288
  • 2
  • 15
  • 25
omar
  • 81
  • 1
  • 9
  • 2
    As answered [here](http://stackoverflow.com/questions/37008076/cant-execute-code-after-thread-currentthread-join/), joining the current thread is nonsensical. At least if you're not ensuring the current thread gets programmatically interrupted somehow. – Mena May 03 '16 at 15:25
  • can you please share complete code ? I'm trying to start , stop Grid programmatically as well and looking for this solution – vikramvi Dec 19 '16 at 20:41

0 Answers0