String strIP = "Your IP";
//Launch Selenium Hub
GridHubConfiguration config = new GridHubConfiguration();
config.setTimeout(30000000);
config.setPort(4444);
Hub hub = new Hub(config);
hub.start();
RegistrationRequest req = new RegistrationRequest();
req.setRole(GridRole.NODE);
Map<String, Object> nodeConfiguration = new HashMap<String, Object>();
nodeConfiguration.put(RegistrationRequest.PROXY_CLASS, "org.openqa.grid.selenium.proxy.DefaultRemoteProxy");
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");
nodeConfiguration.put("Dwebdriver.chrome.driver=chromedriver", "");
URL remoteURL = new URL("http://"+strIP+":5555");
nodeConfiguration.put(RegistrationRequest.REMOTE_HOST, remoteURL);
req.setConfiguration(nodeConfiguration);
DesiredCapabilities capabilities2 = DesiredCapabilities.chrome();
capabilities2.setCapability("browserName","chrome");
capabilities2.setCapability("platform", "MAC");
capabilities2.setCapability("ensureCleanSession", "true");
capabilities2.setCapability("maxInstances",5);
req.addDesiredCapability(capabilities2);
SelfRegisteringRemote remote = new SelfRegisteringRemote(req);
try
{
remote.startRemoteServer();
}
catch (Exception f)
{
System.out.println(f); //Fails here org.openqa.grid.common.exception.GridConfigurationException: no server set to register to the hub
}
remote.startRegistrationProcess(); //I Let this run
System.out.println("Stop Here"); //Break point Here
When this code runs, and I open my browser to localhost:4444/grid/console# it displays the below.
Any ides how I can pass the version? Or any idea why it says "no server set to register to the hub"?
Thanks for any help you can provide.
import org.openqa.grid.common.GridRole;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.internal.utils.GridHubConfiguration;
import org.openqa.grid.internal.utils.SelfRegisteringRemote;
import org.openqa.grid.selenium.proxy.DefaultRemoteProxy;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.server.SeleniumServer;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class HubViaCode {
public static void main(String[] args) throws Exception {
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", "MAC");
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();
Thread.currentThread().join();
}
}
--
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 selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/71082bc6-41a4-440b-8b8c-66168e204424%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0ef52aa8-1ae4-427f-809d-452fb826d0be%40googlegroups.com.
Sai Kiran,
You cannot programmatically wire in node to a hub when the machines on which they run are different.
When you wire in a node to a hub via code, it would be done in the same JVM.
So you would need to resort to the manual way of registering nodes to hub as detailed in the wiki page of Grid2.
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/
--
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 selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c99b88c1-25d3-4c99-bcdb-96cc90d0cc8c%40googlegroups.com.
Rajiv,
I think, going forward, you should start the hub and the node as shown below :
public static void main(String[] args) throws
Exception {
String hubHost = "localhost";
String hubPort = "4444";
String[] gridArgs = new String[] {"-role", "hub", "-timeout", "30000000", "-host", hubHost, "-port", hubPort};
GridLauncherV3.main(gridArgs);
String[] nodeArgs = new String[] {"-role", "node", "-hub", String.format("http://%s:%s/grid/register", hubHost, hubPort),
"-port", "5555"};
GridLauncherV3.main(nodeArgs);
Thread.currentThread().join();
}
You can always improvise this, by creating the configuration files (if required) via your code. But starting the Hub and the mode via the main() method is a lot more stable, because that’s the only actual way in which people are expected to start the hub and the node and that’s why the arguments hardly change. The internals of Selenium can change.
If you are still keen on using the APIs for starting, then you can take a look at the internals of GridLauncherV3.main() to understand how to set various things.
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: <seleniu...@googlegroups.com> on behalf of Rajiv Sharma <rajiv....@gmail.com>
Reply-To: <seleniu...@googlegroups.com>
Date: Tuesday, October 10, 2017 at 11:59 AM
To: Selenium Users <seleniu...@googlegroups.com>
Error! Filename not specified.
--
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 selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/71082bc6-41a4-440b-8b8c-66168e204424%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 selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/59165c65-5f15-4f8a-b0b8-7bd16383be31%40googlegroups.com.
Rajiv,
Not sure, what version of Selenium are you working with. Assuming that you are using Selenium 3.6.0 you should be using “com.google.guava:guava:jar:23.0”.
But it looks like you are explicitly resolving to some other version of guava libraries which explains the error that you are seeing.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0bc81ad7-2927-4ea5-872e-1ae09983a0ee%40googlegroups.com.
For the first scenario, I guess its due to a bad/wrong chromedriver binary version.
For the second scenario, it’s a valid error. The hub is basically saying that it doesn’t have any nodes that can service xx.yy version of chrome.
Debugging steps that you can follow:
You should see something like this :
$ chromedriver
Starting ChromeDriver 2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2) on port 9515
Only local connections are allowed.
$ curl -i -H "Accept: application/json" -X POST -d '{"desiredCapabilities":{"browserName":"chrome"}}' http://localhost:9515/session
HTTP/1.1 200 OK
Content-Length:816
Content-Type:application/json; charset=utf-8
Connection:close
{"sessionId":"820e5299fe7d0d8afeaef475a8ad5a91","status":0,"value":{"acceptSslCerts":true,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2)","userDataDir":"/var/folders/mj/81r6v7nn5lqgqgtfl18spfpw0000gn/T/.org.chromium.Chromium.2OnOxX"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":false,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platform":"Mac OS X","rotatable":false,"setWindowRect":true,"takesHeapSnapshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"61.0.3163.100","webStorageEnabled":true}}
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2a99bf56-18c6-49fe-b300-8220cf134de5%40googlegroups.com.
public static void main(String[] args) throws Exception {
String[] gridArgs = new String[] { "-role",
"hub","-hubConfig","D:\\workspace-new\\thread\\hubConfig.json" };
GridLauncherV3.main(gridArgs);
System.setProperty("webdriver.chrome.driver", "D:\\JavaJar\\chromedriver_win32\\chromedriver.exe");
String[] nodeArgs = new String[] { "-role", "node",
"-nodeConfig","D:\\workspace-new\\thread\\nodeconfig.json"};
GridLauncherV3.main(nodeArgs);
Thread.currentThread().join();
}
WebDriver driver = new RemoteWebDriver(new URL("http://192.168.56.1:4444/wd/hub"), DesiredCapabilities.chrome());
AFAIK it cannot be set via the node configuration file. Why wouldn't adding it to the PATH variable as a one time activity per machine not work for you ?
capabilities2.setCapability(<span style="color:#3933ff"
Can you please explain/clarify what you are trying to do?
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: <seleniu...@googlegroups.com> on behalf of shashank shekhar <sshashan...@gmail.com>
Reply-To: <seleniu...@googlegroups.com>
Date: Wednesday, August 15, 2018 at 8:51 AM
To: Selenium Users <seleniu...@googlegroups.com>
Subject: Re: [selenium-users] Programmatically open Selenium Hub and Node - ErrorDefaultRemoteProxy unknown version
Hi @ Krishnan Mahadevan,
Error! Filename not specified.
--
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 selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/71082bc6-41a4-440b-8b8c-66168e204424%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 selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fde9bc5f-2b45-4235-8dab-8ccdc16ca652%40googlegroups.com.
The only reason why your code works fine in debug mode but doesn’t work fine in the normal mode is because, you aren’t waiting till the node finishes its registration process and wires itself to the hub. Before that happens, you are routing tests to your hub and the hub is basically telling you “Hey, I don’t have any nodes at all with me”.
Merely adding a Thread.sleep(45 * 1000) [ Time can vary] after the node registration code should do the trick. There are sophisticated ways of making this an intelligent wait, but a simple sleep should do the trick.
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/
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fde9bc5f-2b45-4235-8dab-8ccdc16ca652%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 view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/39E7112E-0431-40FD-8313-EAA23346B40C%40gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/39E7112E-0431-40FD-8313-EAA23346B40C%40gmail.com.
Sep 02, 2018 11:48:19 AM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 3.10.0-693.11.6.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 237 milliseconds
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'newnode-26.openstacklocal', ip: '10.0.0.55', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-693.11.6.el7.x86_64', java.version: '1.8.0_161'
Driver info: driver.version: unknown
Command duration or timeout: 537 milliseconds
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
-----------------------------------------------------------------------------------------------------------------------------
I have downloaded the selenium-server-standalone.jar latest and running the command.
java -jar /var/lib/jenkins/selenium-server-standalone-3.12.0.jar -role hub -port 8070 21:26:16.789 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.12.0', revision: '7c6e0b3' 21:26:16.792 INFO [GridLauncherV3$2.launch] - Launching Selenium Grid hub on port 8070 2018-09-02 21:26:17.175:INFO::main: Logging initialized @859ms to org.seleniumhq.jetty9.util.log.StdErrLog 21:26:17.378 INFO [Hub.start] - Selenium Grid hub is up and running 21:26:17.380 INFO [Hub.start] - Nodes should register to http://172.17.0.1:8070/grid/register/ 21:26:17.380 INFO [Hub.start] - Clients should connect to http://172.17.0.1:8070/wd/hub 21:26:20.901 INFO [DefaultGridRegistry.add] - Registered a node http://10.0.0.55:3333
kindly help.
The errors that are shared by you, seem to suggest that you have a problem with your chromedriver+chrome setup.
Just to rule out chromedriver+chrome issues, please try doing the following on your unix machine and see if you notice a browser spin up.
22:05 $ chromedriver
Starting ChromeDriver 2.37.544337 (8c0344a12e552148c185f7d5117db1f28d6c9e85) on port 9515
Only local connections are allowed.
curl --header "Content-Type: application/json" --request POST --data '{"desiredCapabilities":{"browserName":"chrome"}}' http://localhost:9515/session
if you don’t see the browser open up, then it means you have a problem with your chromedriver + chrome combo.
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/
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/28e4ebea-7b10-4054-93ca-a88b15da2346%40googlegroups.com.
Enter code here...public class BaseSetup {
protected static AndroidDriver<MobileElement> driver = null;
protected AppiumDriverLocalService service;
public WebDriverWait wait;
private ThreadLocalDriver threadLocalDriver = new ThreadLocalDriver();
@Parameters({"deviceName","platformVersion","udid","URL_","Sport","deviceId","sysPort","bootStrap","wdaPort","path"})
@BeforeMethod(alwaysRun = true)
public void setUp (String deviceName, String platformVersion, String udid, String URL_, String Sport, String deviceId, String sysPort, String bootStrap, String wdaPort, String path) throws MalformedURLException, InterruptedException {
System.out.println("Driver Is Initiated");
DesiredCapabilities dc = new DesiredCapabilities();
// Mobile setup
dc.setCapability(MobileCapabilityType.DEVICE_NAME, deviceName);
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, platformVersion);
dc.setCapability(AndroidMobileCapabilityType.SYSTEM_PORT, sysPort);
dc.setCapability("appium:unlockType", "password");
dc.setCapability("appium:unlockKey", "@sadA");
// Application setup
dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "sad");
dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "csad");
dc.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS,"true");
dc.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
// Driver configuration
// int port = Integer.parseInt(Sport); //need when use function .using
service = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File("/usr/local/bin/node"))
.withAppiumJS(new File("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js"))
.withArgument(Arg.ADDRESS,URL_)
.withArgument(Arg.PORT,Sport)
.withArgument(Arg.CALLBACKPORT,Sport)
.withArgument(Arg.WDALOCALPORT,wdaPort)
.withArgument(Arg.BootstrapPort,bootStrap)
.withArgument(Arg.NODECONFIG,path)
.withArgument(Arg.SESSIONOVERRIDE));
service.start();
Thread.sleep(7000); // Needed for appium server to wait for selenium grid to register the node
driver = new AndroidDriver (new URL("http://localhost:4444/wd/hub"), dc);
// threadLocalDriver.setTLDriver(new AndroidDriver<MobileElement>(new URL("http://"+URL_+":"+Sport+"/wd/hub"),dc));
// threadLocalDriver.setTLDriver(new AndroidDriver<MobileElement>(new URL("http://localhost:4444/wd/hub"),dc));
// driver = threadLocalDriver.getTLDriver();
// wait = new WebDriverWait(driver, 10);
}
@AfterMethod
public void tearDown(){
if (driver != null)
driver.quit();
System.out.println("Driver quit");
}
}