Node not being registered to hub selenium 3.12.0 (Was passed main parameter '-role')

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Node not being registered to hub selenium 3.12.0 (Was passed main parameter '-role')

Khoosham

Meta -

OS:
Windows 10
Selenium Version:
3.12.0
Browser:
Chrome
Browser Version:
66.0.3359.139 (64-bit)

Expected Behavior -

Node should attach to hub as in selenium version 3.8.1.

Actual Behavior -

I am using selenium 3.8.1 version. i have made my own utility to start/stop hub and register node etc...
Currently i am using this command to register the node to the server and this works great.

String[] args = { "-role", "node", "-host", host, "-hub", hubURL, "-port", port };
GridNodeConfiguration gridNodeConfiguration = new GridNodeConfiguration();
 JCommander.newBuilder().addObject(gridNodeConfiguration).build().parse(args);

The issue i am having is that i have updated to 3.12.0 and the command above does not work.
i get the following error com.beust.jcommander.ParameterException: Was passed main parameter '-role' but no main parameter was defined in your arg class. Like you see above i have already defined the role as node but still the node wont attach. Any help regarding this please ? Thank you.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f9bba9d9-2ff5-40d2-bc2d-1b269c4035cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Node not being registered to hub selenium 3.12.0 (Was passed main parameter '-role')

Krishnan Mahadevan

Please share the complete code, that you are using to start the node.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

From: <[hidden email]> on behalf of Khoosham <[hidden email]>
Reply-To: <[hidden email]>
Date: Tuesday, May 15, 2018 at 6:56 PM
To: Selenium Users <[hidden email]>
Subject: [selenium-users] Node not being registered to hub selenium 3.12.0 (Was passed main parameter '-role')

 

OS:
Windows 10
Selenium Version:
3.12.0
Browser:
Chrome
Browser Version:
66.0.3359.139 (64-bit)

Expected Behavior -

Node should attach to hub as in selenium version 3.8.1.

Actual Behavior -

I am using selenium 3.8.1 version. i have made my own utility to start/stop hub and register node etc...
Currently i am using this command to register the node to the server and this works great.

String[] args = { "-role", "node", "-host", host, "-hub", hubURL, "-port", port };
GridNodeConfiguration gridNodeConfiguration = new GridNodeConfiguration();
 JCommander.newBuilder().addObject(gridNodeConfiguration).build().parse(args);

The issue i am having is that i have updated to 3.12.0 and the command above does not work.
i get the following error com.beust.jcommander.ParameterException: Was passed main parameter '-role' but no main parameter was defined in your arg class. Like you see above i have already defined the role as node but still the node wont attach. Any help regarding this please ? Thank you.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
[hidden email].
To post to this group, send email to
[hidden email].
To view this discussion on the web visit
https://groups.google.com/d/msgid/selenium-users/f9bba9d9-2ff5-40d2-bc2d-1b269c4035cc%40googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CCA09722-16A1-4965-AE46-B1337DADB43E%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Node not being registered to hub selenium 3.12.0 (Was passed main parameter '-role')

Khoosham
In reply to this post by Khoosham
Here is full code

import com.beust.jcommander.JCommander;
import java.util.Arrays;
import java.util.Map;
import org.apache.log4j.Logger;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.common.SeleniumProtocol;
import org.openqa.grid.internal.utils.SelfRegisteringRemote;
import org.openqa.grid.internal.utils.configuration.GridNodeConfiguration;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.server.SeleniumServer;

public class NodeUtility
{
  static Logger log = Logger.getLogger(NodeUtility.class.getName());
  
  public NodeUtility() 
  {
  }
  
  @SuppressWarnings("UseSpecificCatch")
  private GridNodeConfiguration GetNodeConfiguration(Map<String, String> NodeInfoMap) 
  {
    GridNodeConfiguration gridNodeConfiguration = null;
    try
    {
      gridNodeConfiguration = new GridNodeConfiguration();
      gridNodeConfiguration.maxSession = Integer.parseInt((String)NodeInfoMap.get("MAX_SESSION"));
      gridNodeConfiguration.port = Integer.parseInt((String)NodeInfoMap.get("PORT"));
      gridNodeConfiguration.host = ((String)NodeInfoMap.get("HOST"));
      gridNodeConfiguration.hub = "http://" + (String)NodeInfoMap.get("HUB_HOST") + ":" + (String)NodeInfoMap.get("HUB_PORT") + "/wd/register";
      gridNodeConfiguration.registerCycle = Integer.parseInt((String)NodeInfoMap.get("REGISTER_CYCLE"));
      gridNodeConfiguration.browserTimeout = Integer.parseInt((String)NodeInfoMap.get("BROWSER_TIMEOUT"));
      gridNodeConfiguration.timeout = Integer.parseInt((String)NodeInfoMap.get("TIMEOUT"));
      gridNodeConfiguration.cleanUpCycle = Integer.parseInt((String)NodeInfoMap.get("CLEANUP_CYCLE"));
      gridNodeConfiguration.nodeStatusCheckTimeout = Integer.parseInt((String)NodeInfoMap.get("NODE_STATUS_CHECK_TIMEOUT"));
      gridNodeConfiguration.proxy = "org.openqa.grid.selenium.proxy.DefaultRemoteProxy";
      }
    catch (Exception ex) {
      log.error("GetNodeConfiguration: "+ex.toString());
    }
    return gridNodeConfiguration;
  }
  
  public int AttachNodeToHub(Map<String, String> NodeInfoMap) 
  {
      
    SelfRegisteringRemote selfRegisteringRemote;
    String browser = (String)NodeInfoMap.get("BROWSER");
    String host = (String)NodeInfoMap.get("HOST");
    String port = (String)NodeInfoMap.get("PORT");
    String hub_host = (String)NodeInfoMap.get("HUB_HOST");
    String hub_port = (String)NodeInfoMap.get("HUB_PORT");
    int max_instances = Integer.parseInt((String)NodeInfoMap.get("MAX_INSTANCES"));
    String firefox_binary = (String)NodeInfoMap.get("FIREFOX_BINARY");
    String chrome_binary = (String)NodeInfoMap.get("CHROME_BINARY");
    String hubURL = "http://" + hub_host + ":" + hub_port;
    
    try
    { 
      DesiredCapabilities capablilty = new DesiredCapabilities();
      capablilty.setCapability("seleniumProtocol", SeleniumProtocol.WebDriver);
      capablilty.setBrowserName(browser);
      if (!((String)NodeInfoMap.get("VERSION")).equalsIgnoreCase("DEFAULT")) {
            capablilty.setVersion((String)NodeInfoMap.get("VERSION"));
      }
      if (((String)NodeInfoMap.get("ADVANCED_OPTIONS_FLAG")).equalsIgnoreCase("TRUE")) 
      {
        if (browser.equalsIgnoreCase("FIREFOX")) {
            capablilty.setCapability("firefox_binary", firefox_binary);
        }
        if (browser.equalsIgnoreCase("CHROME")) {
            capablilty.setCapability("chrome_binary", chrome_binary);
        }
      }
      String[] args = { "-role", "node", "-host", host, "-hub", hubURL, "-port", port };
      
      GridNodeConfiguration gridNodeConfiguration = new GridNodeConfiguration();
      JCommander.newBuilder().addObject(gridNodeConfiguration).build().parse(args);
      //JCommander jCommander = new JCommander(gridNodeConfiguration, args);
      //System.out.println(Arrays.toString(args));
      //JCommander.newBuilder().addObject(gridNodeConfiguration).args(args).build();
      RegistrationRequest registrationRequest = RegistrationRequest.build(gridNodeConfiguration);
      selfRegisteringRemote = new SelfRegisteringRemote(registrationRequest);
      selfRegisteringRemote.deleteAllBrowsers();
      selfRegisteringRemote.addBrowser(capablilty, max_instances);
      selfRegisteringRemote.setRemoteServer(new SeleniumServer(GetNodeConfiguration(NodeInfoMap)));
      selfRegisteringRemote.startRemoteServer();
      selfRegisteringRemote.sendRegistrationRequest();
      HubUtility.UpdateNode(port, selfRegisteringRemote);
      return 1;
    }
    catch (Exception ex) {
      log.error("AttachNodeToHub:"+ ex.toString());
      return -1;
    }
  }
}

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e0c7c26c-6d26-4897-82d5-0b240e8c93a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.