Hi all @Appium_Master @rgonalo @bhaskar @Arvind_Patel @Hassan_Radi
I am able to install and launch the app in both the devices connected but script is being executed only on one.
NODE 1:
{
"capabilities":
[
{
"browserName":"android",
"version":"4.4.2",
"maxInstances":5,
"platform":"ANDROID",
"deviceName": "3204da2a5075c0b5"
}
],
"configuration":
{
"nodeTimeout":120,
"cleanUpCycle":2000,
"timeout":10000,
"proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://xxxx:5566/wd/hub",
"maxSession":2,
"port":5566,
"register":true,
"registerCycle":5000,
"hub": "xxxx:4441/grid/register",
"hubPort": 4441,
"hubHost": "xxxx",
"role":"node"
}
}
NODE 2:
{
"capabilities":
[
{
"browserName":"android",
"version":"4.4.2",
"maxInstances":5,
"platform":"ANDROID",
"deviceName": "8a2d363"
}
],
"configuration":
{
"nodeTimeout":120,
"cleanUpCycle":2000,
"timeout":10000,
"proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://xxxx:5577/wd/hub",
"maxSession":2,
"port":5577,
"register":true,
"registerCycle": 5000,
"hub": "xxxx:4441/grid/register",
"hubPort": 4441,
"hubHost": "xxxx",
"role":"node"
}
}
I am passing device id as a parameter from testng.xml file
Script:
public class appGrid {
WebDriver driver = null;
DesiredCapabilities capabilities = new DesiredCapabilities();
@Parameters(value={"device_id1","device_id2","ApplicationPath"})
@BeforeTest
public void atStart(@Optional("nnn")String device_id1,String device_id2, String ApplicationPath) throws MalformedURLException, InterruptedException
{
//capabilities=DesiredCapabilities.android();
capabilities.setCapability("automationName", "Appium");
capabilities.setCapability(CapabilityType.BROWSER_NAME,"android");
capabilities.setCapability("platformVersion", "4.4.2");//Or//capabilities.setCapability(CapabilityType.VERSION, "4.1.2");
capabilities.setCapability(CapabilityType.PLATFORM,"ANDROID");
//capabilities.setCapability("platformName","ANDROID");//Or//capabilities.setCapability(CapabilityType.PLATFORM, "Android");
capabilities.setCapability("app", ApplicationPath);
capabilities.setCapability("appPackage", "com.app.android.staging"); //Replace with your app's package
capabilities.setCapability("appActivity", "com.app.android.ui.TabActivity"); //Replace with app's Activity
//setting new command timeout for selenium server
capabilities.setCapability("newCommandTimeout", "2000000");//33.33 mins
if("8a2d363".equalsIgnoreCase(device_id2))
{
System.out.println("in nexus: "+device_id2);
//
capabilities.setCapability("deviceName",device_id2);
//capabilities.setCapability("udid","8a2d363");
//capabilities.setCapability("deviceName","Micromax A311");
capabilities.setCapability("sleep", "1000");
try
{
driver = new AndroidDriver(new URL("http://xxxx:4441/wd/hub"), capabilities);
}
catch (Exception e)
{
e.printStackTrace();
}
}
if ("3204da2a5075c0b5".equalsIgnoreCase(device_id1))
{
System.out.println("in Samsung galaxy: "+device_id1);
//
capabilities.setCapability("deviceName", device_id1);
// capabilities.setCapability("udid", "3204da2a5075c0b5");
// capabilities.setCapability("deviceName","SM-N750");
capabilities.setCapability("sleep", "15000");
try
{
driver = new AndroidDriver(new URL("http://xxxx:4441/wd/hub"), capabilities);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
I understand the driver mentioned 1st is overwriting the last one but If I mention the last one only out of IF block, I see the installation in only one device.
Really looking forward for help.
I have been struggling for implementing at last point from long time.
Thanks in advance !