This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
135 / 169
Nov 2015
1 month later

@Arvind_Patel
Can you please provide me exact steps to set up selenium grid. I want it from scratch.
I would like to know on how to run these json files, where to add them and all. Could you please help me with the same.

8 days later

Needed help
@Arvind_Patel @Hassan_Radi

My json files are:

node1.json

{
"capabilities":
[
{
"browserName": "Android",
"version”:”5.0.2”,
"maxInstances": 3,
"platform":"ANDROID",
"deviceName”:”X1033”
}
],
"configuration":
{
"nodeTimeout":120,
"port":4723,
"hubPort":4444,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:4723/wd/hub",
"hub": "127.0.0.1:4444/grid/register",
"hubHost":"127.0.0.1",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}

node2.json

{
"capabilities":
[
{
"browserName": "Android",
"version":"5.1",
"maxInstances": 3,
"platform":"ANDROID",
"deviceName”:”X1033”
}
],
"configuration":
{
"nodeTimeout":120,
"port":4728,
"hubPort":4444,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:4728/wd/hub",
"hub": "127.0.0.1:4444/grid/register",
"hubHost":"127.0.0.1",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}

Opened 2 appium on ports 4723 & 4728

Started grid on mac with command:

java -jar selenium-server-standalone-2.48.2.jar -role hub

starting node with command:

java -jar selenium-server-standalone-2.48.2.jar -role node -hub http://localhost:4444/grid/register10 —port 4723 -nodeConfig node1.json

getting ERROR:

Mac-mini:jar intelligrape$ java -jar selenium-server-standalone-2.48.2.jar -role node -hub http://localhost:4444/grid/register10 —port 4723 -nodeConfig node1.json
16:16:30.700 INFO - Launching a Selenium Grid node
Error building the config :Error with the JSON of the config : Wrong format for the JSON input : com.google.gson.stream.MalformedJsonException: Expected name at line 1 column 2 path $.
Usage: java -jar selenium-server.jar -role node [options]

-host:
: usually not needed and determined
automatically. For exotic network configuration, network with
VPN, specifying the host might be necessary.

-port:
: the port the remote/hub will listen on. Default to 4444.

-cleanupCycle:
in ms. How often a proxy will check for timed out thread.

-timeout:
the timeout in seconds before the hub automatically ends
a test that hasn't had any activity in the last X seconds. The
browser will be released for another test to use. This typically
takes care of the client crashes.

-browserTimeout:
The timeout in seconds a browser can hang

-hub:
http://localhost:4444/grid/register10 : the url that will be used
to post the registration request. This option takes precedence
over -hubHost and -hubPort options.

-hubHost:
: the host address of a hub the registration
request should be sent to. Default to localhost. Option -hub
takes precedence over this option.

-hubPort:
: the port listened by a hub the registration request
should be sent to. Default to 4444. Option -hub takes precedence
over this option.

-proxy:
the class that will be used to represent the node. By default
org.openqa.grid.selenium.proxy.DefaultRemoteProxy.

-maxSession:
max number of tests that can run at the same time on the node,
independently of the browser used.

-registerCycle:
how often in ms the node will try to register itself again.Allow
to restart the hub without having to restart the nodes.

-nodePolling:
in ms. Interval between alive checks of node how often the hub
checks if the node is still alive.

-unregisterIfStillDownAfter:
in ms. If the node remains down for more than
unregisterIfStillDownAfter millisec, it will disappear from the
hub.Default is 1min.

-downPollingLimit:
node is marked as down after downPollingLimit alive checks.

-nodeStatusCheckTimeout:
in ms. Connection and socket timeout which is used for node alive
check.

This synopsis lists options available in node role only. To get help
on the command line options available for other roles run the server
with -help name and the corresponding -role name value.
org.openqa.grid.common.exception.GridConfigurationException: Error with the JSON of the config : Wrong format for the JSON input : com.google.gson.stream.MalformedJsonException: Expected name at line 1 column 2 path $.
at org.openqa.grid.common.RegistrationRequest.loadFromJSON(RegistrationRequest.java:574)
at org.openqa.grid.common.RegistrationRequest.build(RegistrationRequest.java:378)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:83)
Caused by: org.openqa.grid.common.exception.GridConfigurationException: Wrong format for the JSON input : com.google.gson.stream.MalformedJsonException: Expected name at line 1 column 2 path $.
at org.openqa.grid.common.JSONConfigurationUtils.loadJSON(JSONConfigurationUtils.java:81)
at org.openqa.grid.common.RegistrationRequest.loadFromJSON(RegistrationRequest.java:550)
... 2 more
Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected name at line 1 column 2 path $.
at com.google.gson.internal.Streams.parse(Streams.java:56)
at com.google.gson.JsonParser.parse(JsonParser.java:84)
at com.google.gson.JsonParser.parse(JsonParser.java:59)
at com.google.gson.JsonParser.parse(JsonParser.java:45)
at org.openqa.grid.common.JSONConfigurationUtils.loadJSON(JSONConfigurationUtils.java:79)
... 3 more
Caused by: com.google.gson.stream.MalformedJsonException: Expected name at line 1 column 2 path $.
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1573)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:517)
at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:418)
at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:666)
at com.google.gson.internal.bind.TypeAdapters$25.read(TypeAdapters.java:642)
at com.google.gson.internal.Streams.parse(Streams.java:44)
... 7 more

@tovaibhav1

These two lines are the ones causing the issue. You are using invalid double quotes, thus the inability to parse the json file. Please use this site to validate your json file: http://jsonlint.com/25

Change every to be "

Thanks @Hassan_Radi but I used command from location "C:\Program Files (x86)\Appium\node_modules\appium\bin>"

node appium -a 192.168.1.2 -p 4723 --nodeconfig D:\TehnologyWork\Softwares\jar\node1.json

I am receiving error

C:\Program Files (x86)\Appium\node_modules\appium\bin>node appium -a 192.168.1.2 -p 4723 --nodeconfig D:\TehnologyWork\Softwares\jar\node1.json

info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
info: Appium REST http interface listener started on 192.168.1.2:4723
info: [debug] Non-default server args: {"address":"192.168.1.2","nodeconfig":"D:\TehnologyWork\Softwares\jar\node1.json"}
info: Console LogLevel: debug
> error: Unable to load node configuration file to register with grid

@tovaibhav1
I am not sure what is causing this weird issue, but if I were you, I would try to load the same file using Appium .exe application and see how it would react. This would tell me if it is a problem with the file itself or the parameters I am passing.

@Hassan_Radi Please guide

My node are:
node1.json

{
"capabilities": [
{
"browserName": "Android",
"version": "5.1",
"maxInstances": 3,
"platform": "ANDROID",
"deviceName": "X1033"
}
],
"configuration": {
"nodeTimeout": 120,
"port": 4723,
"hubPort": 4444,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url": "http: //127.0.0.1: 4723/wd/hub",
"hub": "127.0.0.1: 4444/grid/register",
"hubHost": "127.0.0.1",
"nodePolling": 2000,
"registerCycle": 10000,
"register": true,
"cleanUpCycle": 2000,
"timeout": 30000,
"maxSession": 1
}
}

node2.json

{
"capabilities": [
{
"browserName": "Android",
"version": "5.1.1",
"maxInstances": 3,
"platform": "ANDROID",
"deviceName": "emulator_1"
}
],
"configuration": {
"nodeTimeout": 120,
"port": 4728,
"hubPort": 4444,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url": "http: //127.0.0.1: 4728/wd/hub",
"hub": "127.0.0.1: 4444/grid/register",
"hubHost": "127.0.0.1",
"nodePolling": 2000,
"registerCycle": 10000,
"register": true,
"cleanUpCycle": 2000,
"timeout": 30000,
"maxSession": 1
}
}

Started HUB

java -jar selenium-server-standalone-2.48.2.jar -role hub

Started Nodes

node appium -a 127.0.0.1 -p 4723 --nodeconfig D:\TehnologyWork\Softwares\jars\node1.json

node appium -a 127.0.0.1 -p 4728 --nodeconfig D:\TehnologyWork\Softwares\jars\node2.json

When I execute test for any device, always script runs in one appium server which is started firstly i.e. node1.

public static ThreadLocal> dr = new ThreadLocal>();

@BeforeMethod
@Parameters("deviceName")
public void beforeMethod(String deviceName) throws MalformedURLException{
	try{
		if(deviceName.equals("XT1033")){
			AndroidDriver<MobileElement>  driver = null;
			DesiredCapabilities capabilities=new DesiredCapabilities();
			capabilities.setCapability("platformName", "Android");
			capabilities.setCapability("platformVersion","5.1");
			capabilities.setCapability("deviceName", deviceName);
			capabilities.setCapability("app",System.getProperty("user.dir") + "/resources/app-Channel31-debug.apk");
			URL serverAddress = new URL("http://127.0.0.1:4444/wd/hub");
			driver = new AndroidDriver<MobileElement>(serverAddress, capabilities);
			setDriver(driver);

		}
		if(deviceName.equals("emulator_1")){
			AndroidDriver<MobileElement>  driver = null;
			DesiredCapabilities capabilities=new DesiredCapabilities();
			capabilities.setCapability("platformName", "Android");
			capabilities.setCapability("platformVersion","5.1.1");
			capabilities.setCapability("deviceName", deviceName);
			capabilities.setCapability("app",System.getProperty("user.dir") + "/resources/american swan- prod.apk");
			URL serverAddress = new URL("http://127.0.0.1:4444/wd/hub");
			driver = new AndroidDriver<MobileElement>(serverAddress, capabilities);
			setDriver(driver);
		}
	}

Hi @tovaibhav1,
you are trying to select the node with deviceName, but the hub does not use this capability.
The hub only reads browserName, version, platform and applicationName. The other capabilities (deviceName, platformVersion, platformName, ...) are Appium capabilities, not used by the hub.

In this case, you could add version capability to each test:

capabilities.setCapability("version","5.1");
capabilities.setCapability("version","5.1.1");
2 months later

I can see there are some success using appium grid over Selenium but is there one person that managed to do this using windows (without emulator!) simply** two Android devices**?

Hello all,

I'm trying to have some mobile automated tests running with appium and selenium grid. Once i done all configuration stuff and added grid nodes, how do i run my tests parallely in both devices?

Here's my setUp():

desired_caps = {}
	desired_caps['platformName'] = 'Android'
	desired_caps['platformVersion'] = '5.1'
	desired_caps['deviceName'] = ''
	desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__), 'C:/Users/andre.mendes/Desktop/workspace/powerpro/apps/powerpro.apk'))
	desired_caps['appPackage'] = 'com.psafe.powerpro'
	desired_caps['appActivity'] = '.MainActivity'
	desired_caps['noReset'] = False
	self.driver = webdriver.Remote('http://127.0.0.1:4444/wd/hub', desired_caps)
	self.driver.implicitly_wait(15)

What it supposed to be in deviceName in this case?

If i leave it blank, here's what i got:

C:\Users\andre.mendes\Desktop\workspace\powerpro>java -jar selenium-server-standalone-2.44.0.jar -role hub

19:16:58.691 INFO - Launching a selenium grid server

2016-02-18 19:16:59.937:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT

2016-02-18 19:16:59.968:INFO:osjsh.ContextHandler:startedo.s.j.s.ServletContextHandler{/,null}2016-02-18 19:16:59.995:INFO:osjs.AbstractConnector:StartedSocketConnector@0.0.0.0:4444

19:49:48.183 INFO - Got a request to create a new session: Capabilities[{app=C:\Users\andre.mendes\Desktop\workspace\powerpro\apps\powerpro.apk, appPackage=com.psafe.powerpro, appActivity=.MainActivity, noReset=true, platformVersion=5.1, platformName=Android, deviceName=}]

19:49:48.183 INFO - Available nodes: [host :http://127.0.0.1:4723, host :http://127.0.0.1:4733]

 19:49:48.183 INFO - Trying to create a new session on node host :http://127.0.0.1:4723

19:49:48.183 INFO - Trying to create a new session on test slot {newCommandTimeout=30, browserName=Android, maxInstances=1, version=5.1,deviceName=0429058934,deviceReadyTimeout=5, platform=ANDROID}

I only can run the first node registered in grid. In this case http://127.0.0.1:47231.

I even tried to create a script with two setup(), each one to each device, but even this way, tests only ran in this same device (http://127.0.0.1:4723)

12 days later

I have started working on running parallel android devices by using grid.My Problem is the app installed and opened both connected devices properly.but it has not typed any values which i have given. After that it shows error message in setup method.
Can anyone help me for this issue????