private SelfRegisteringRemote attachNodeToHub(DesiredCapabilities capability,
GridRole role, int nodePort, SeleniumProtocol protocol) throws Exception {
SelfRegisteringRemote node = null;
RegistrationRequest registrationRequest = RegistrationRequest
.localWebdriverNoCapabilities();
capability.setCapability("seleniumProtocol", protocol);
capability.setCapability(
RegistrationRequest.UNREGISTER_IF_STILL_DOWN_AFTER, 1);
// capability.setCapability(RegistrationRequest.MAX_TESTS_BEFORE_CLEAN, 5);
// capability.setCapability(RegistrationRequest.MAX_INSTANCES, 5);
registrationRequest.addDesiredCapability(capability);
registrationRequest.setRole(role);
// registrationRequest.loadFromJSON(resource);
registrationRequest.setConfiguration(fetchNodeConfiguration(role, nodePort,
protocol));
node = new SelfRegisteringRemote(registrationRequest);
node.startRemoteServer();