How to pass multiple device in framework

How to handle running of a script on multiple devices in the framework.Is that a good practise to pass multiple devices in the same script in framework.Please help.

If you are using Java for your framework and TestNg (very common on this forum, although you don’t list yours) you could do this with a data provider. This link has some basics on parametrizing tests in TestNg:

Thanks for the reply.
How to pass these multiple device parameters in the desired capabilities.
Should the port numbers be different for the different devices.
Can we implement grid in the appium framework.Waiting for the reply
Thanks in advance for the help

Sure. You would create an object of type capabilities, store them on the dataprovider array.

Yes, port numbers should be different for each device. You’ll have to work out a way (maybe just assign each device a port?) so that your capabilities reflect the port to connect to.

You certainly could implement a grid for this.

Thanks Wreed.
Will work on it.

You can refer below solution, please take care of extra parameters (if mentioned here) as all of given parameters might not be required for your execution.

Hope this solution works for you !


		<parameter name="app_package" value=""/>
		<parameter name="app_activity" value=""/>
		<class name="com.appium.parveen.SampleTest" />

Note: Copy/paste the test section for any number of times based on your device selection/capabilities requirement to be passed at runtime.

public class SampleTest {

AppiumDriver dr = null;

@Parameters({"browser","device","platformversion","app","app_package","app_activity","platformName", "category"})
public void setUp(@Optional("android") String browser, String device,String platformversion, String app,
		 String app_package, String app_activity, String platformName, String category) throws Exception {
System.out.println("Sample Test Started");

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(CapabilityType.BROWSER_NAME, browser);
capabilities.setCapability("deviceName", device);
capabilities.setCapability("platformVersion", platformversion);
capabilities.setCapability("platformName", platformName);
capabilities.setCapability("orientation", "LANDSCAPE");

capabilities.setCapability("deviceCategory", category);
capabilities.setCapability("app", app);
capabilities.setCapability("appPackage", app_package);                   
capabilities.setCapability("appActivity", app_activity);

dr = new AppiumDriver(new URL(""), capabilities);

// Similarly you can pass IP Address and PORT form testng.xml and handle in above statement for driver object creation
dr.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

public void quit(){


1 Like

thanks Parveen for the reply.