Even I am facing the same issue. My node config files are:
file 1
{
"capabilities":
[
{
"browserName": "Android",
"version":"4.4.2",
"maxInstances": 3,
"platform":"ANDROID",
"deviceName":"emulator-5554"
}
],
"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
}
}
File 2
{
"capabilities":
[
{
"browserName": "Android",
"version":"4.4.2",
"maxInstances": 3,
"platform":"ANDROID",
"deviceName":"emulator-5556"
}
],
"configuration":
{
"nodeTimeout":120,
"port":4730,
"hubPort":4444,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://127.0.0.1:4730/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
}
}
Code Written:
public static AndroidDriver driver=null;
@Test(dataProvider="getData")
public void searchTest(String b) throws MalformedURLException, InterruptedException{
if(driver==null){
DesiredCapabilities cap = null;
System.out.println(b);
if(b.equals("mobile1")){
cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability("deviceName","emulator-5556");
cap.setCapability("platformVersion", "4.4.2");
cap.setCapability("platformName","Android");
cap.setCapability("appPackage",
"com.android.contacts");
cap.setCapability("appActivity",
"com.android.contacts.activities.DialtactsActivity");
}else if(b.equals("mobile2")){
cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability("deviceName","emulator-5554");
cap.setCapability("platformVersion", "4.4.2");
cap.setCapability("platformName","Android");
cap.setCapability("appPackage",
"com.android.contacts");
cap.setCapability("appActivity",
"com.android.contacts.activities.DialtactsActivity");
}
driver = new AndroidDriver(new URL("http://localhost:4444/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
driver.quit();
}
}
@DataProvider(parallel=true)
public Object[][] getData(){
Object data[][] = new Object[2][1];
data[0][0] = "mobile1";
data[1][0] = "mobile2";
return data;
}
Every time the code is being executed on a single device where as I have connected two real device with same machine and started the hub as well on same machine:
Hub Started with:
java -jar selenium-server-standalone-2.44.0.jar -role hub
Started node 1:
C:\Users\ishita\Desktop\Appium\Appium2\node_modules\appium\bin>node appium --nodeconfig c:/softwares/jars/appiumnode1.json -p 4728
Started node 2:
C:\Users\Selenium\Desktop\Appium\Appium\node_modules\appium\bin>node appium --nodeconfig c:/softwares/jars/appiumnode2.json -p 4730
Please suggest me the fix as I need to submit a POC on the same UGENTLY !!!
Thanks for the help.
Ishita