How to point tests to run on Selenium Grid C#
Hey everyone -
I have set up my selenium grid server and a few nodes. I can see the nodes registered on the console on my Selenium Hub. What is the next step here? If I point my tests to hit the machine where the Hub is running, do the tests automatically start using the grid?
Is there anything I need to add to my StartUp and TearDown methods?
Yes it does? Where are you stuck?
Please keep in mind that the hub and the nodes should be in same subnet.
Everytime I run my tests, they just seem to run on the Hub, nothing is getting passed to the nodes..
Here is my test startup..
string windowsApplicationDriverUrl = "http://127.0.0.1:4723";
appCapabilities.AddAdditionalCapability("platformName", "WINDOWS");
appCapabilities.AddAdditionalCapability("app", GetAppLocation());
appCapabilities.AddAdditionalCapability("appArguments", "enableautomation");
session = new WindowsDriver<WindowsElement>(new Uri(windowsApplicationDriverUrl), appCapabilities, TimeSpan.FromMinutes(2));
session.Manage().Window.Maximize();
Do I need to use a RemoteWebDriver or something? I cant seem to find a way to set that without getting errors. I am using NUnit & NUnit console runner to run my tests, no idea if that makes a difference.
@anunay1 also not sure what you mean by them being in the same subnet. I was able to add the node to the Hub and in the selenium server console I can see the node there.
Once you start the selenium server its gives you the below information:
C:\SeleniumGrid>java -jar selenium-server-standalone-3.141.59.jar -role hub -port 4725 22:22:31.073 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358 22:22:31.195 INFO [GridLauncherV3.lambda$buildLaunchers$5] - Launching Selenium Grid hub on port 4725 2020-07-13 22:22:31.598:INFO::main: Logging initialized @802ms to org.seleniumhq.jetty9.util.log.StdErrLog 22:22:32.272 INFO [Hub.start] - Selenium Grid hub is up and running 22:22:32.273 INFO [Hub.start] - Nodes should register to http://192.168.29.72:4725/grid/register/ 22:22:32.273 INFO [Hub.start] - Clients should connect to http://192.168.29.72:4725/wd/hub
Change the appiumjson file as below: { "capabilities": [{ "browserName": "", "version": "", "maxInstances": 3, "platform": "WINDOWS" }], "configuration": { "cleanUpCycle": 2000, "timeout": 30000, "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", "maxSession": 3, "register": true, "registerCycle": 10000, "hubPort": "Your port name", "hubHost": "Your host ip", "nodeTimeout": 120, "nodePolling": 2000, "hubProtocol": "http" } }
and start appium with the above json config from command line
In the solution change the url to: string windowsApplicationDriverUrl = "http://192.168.29.72:4725/wd/hub";(which is shown in the selenium server)
It should work.
@anunay1 oooh ok so my problem was that the URL should be the IP of the actual Hub?
Yes
@anunay1 Thanks! Looks like this may of done it because now I do not see the tests starting up on the Hub, however appears I have another issue.
I keep getting a message "Marking the node .. as down: cannot reach the node for 2 tries." then it says "Registered a node ...". Keeps flipping between these messages. So it looks like i am actually having issues with my node. Is this indicitive of a network issue?
Both the Hub and node are VMs on my companys network
Yes its a network issue
Once you start the selenium server its gives you the below information:
C:\SeleniumGrid>java -jar selenium-server-standalone-3.141.59.jar -role hub -port 4725 22:22:31.073 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358 22:22:31.195 INFO [GridLauncherV3.lambda$buildLaunchers$5] - Launching Selenium Grid hub on port 4725 2020-07-13 22:22:31.598:INFO::main: Logging initialized @802ms to org.seleniumhq.jetty9.util.log.StdErrLog 22:22:32.272 INFO [Hub.start] - Selenium Grid hub is up and running 22:22:32.273 INFO [Hub.start] - Nodes should register to http://192.168.29.72:4725/grid/register/ 22:22:32.273 INFO [Hub.start] - Clients should connect to http://192.168.29.72:4725/wd/hub
Change the appiumjson file as below: { "capabilities": [{ "browserName": "", "version": "", "maxInstances": 3, "platform": "WINDOWS" }], "configuration": { "cleanUpCycle": 2000, "timeout": 30000, "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", "maxSession": 3, "register": true, "registerCycle": 10000, "hubPort": "Your port name", "hubHost": "Your host ip", "nodeTimeout": 120, "nodePolling": 2000, "hubProtocol": "http" } }
and start appium with the above json config from command line
In the solution change the url to: string windowsApplicationDriverUrl = "[http://192.168.29.72:4725/wd/hub";(which](http://192.168.29.72:4725/wd/hub%22;(which) is shown in the selenium server)
It should work.
@anunay1 you mentioned start appium with the above json config from command line, Can you please share the command? It will be helpful. Thanks
java -jar /path/to/selenium.jar node --config appium.json
for more info check https://appium.io/docs/en/2.0/guides/grid/
@anunay1 or @Tree55Topz please share me the node config JSON it will be helpful. I am using this below json for node configuration and using the command java -jar /path/to/selenium.jar node --config appium.json i am trying to register my node with hub but is not registering. Please help
{ "capabilities": [ { "browserName": "", "version": "", "maxInstances": 3, "platformName": "WINDOWS" } ], "configuration": { "cleanUpCycle": 2000, "timeout": 30000, "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", "url": "http://127.0.0.1:4723/wd/hub", "host": "127.0.0.1", "port": 4723, "maxSession": 1, "register": true, "registerCycle": 10000, "hub": "http://10.0.0.8:4444/grid/register", "hubPort": 4444, "hubHost": "10.0.0.8", "nodeTimeout": 120, "nodePolling": 2000, "hubProtocol": "http" } }