How to Setup Your Own Mobile Device Lab

Hi all, In this article I am going to explain how to create a basic mobile device lab (a.k.a device farm) for your mobile automation projects.

First of all, you need 2 tools and mobile devices:

Grid allows you to scale by distributing tests on several machines (parallel execution). You will also run one Appium node for each mobile device that you will connect to your device lab. At the end, you will have an infrastructure as below.

device farm

Steps to Create a Mobile Device Lab are as follows:

1- Setting up a full running Selenium Grid Infrastructure

2- Creating JSON file for Appium to manage our mobile devices

3- Running Appium Server for each device

4- Changing project structure

Setting up a Fully Running Selenium Grid Infrastructure

Selenium Grid (SG) comes in a *.jar file and it runs on the console. There are some parameters that you need to configure while running the Selenium Grid. The most basic ones explained in the example. By changing the “Port” parameter, you modify the default port of SG. Role parameter is set as “hub” parameter, and it defines that SG behaves as a central request collection point and it receives all the test requests and distributes them the right nodes.

java -jar selenium-server-standalone-2.53.0.jar -port 4444 -role hub

After initializationof above command, point your browser to http://localhost:4444/grid/console URL and see that Selenium Grid is fully functional.

Creating JSON File for Appium to Manage our Mobile Devices

In this step, we need to create *.json files for each mobile devices. Those files have two parts. The first part is “Capabilities” and it keeps specific information of mobile devices like their device ids, browsers, OS names and OS versions. The second part is “Configuration,” and it comprises of information about the Selenium Hub.

Selenium Grid matches test requests with the devices by using definitions in capabilities part. In below at JSON file’s capabilities part, three parameters hold crucial information of the device.

The other parameters are host, port, URL, hubPort, hubHost and you can also change them at Configuration part. You need to modify them according to your infrastructure. Host and port are host IP and port of your Appium server.

After creating this file, save it as “node-devicename.json”. For each mobile device, you need to create a specific file by changing the parameters that I explained above.

To get your device’s UDID, you need to turn on “Developer Settings” on your mobile device and runadb devices” command on the console. Turning on the “Developer Settings” of a mobile device is varying. Thus, you need to find how to do this for your devices in Google 😉

Running Appium Server for Each Mobile Device

In this step, we will configure Appium Nodes. Appium can only handle one mobile device, so we need several Appium servers to interact with all devices as shown in the first picture. Thus, we need to create a small batch file which triggers Appium. This command must be executed in Appium’s folder. That command is shown below:

As you can see, there are many parameters that we need to send Appium server. NodeConfig parameter points the path to the JSON file. “P” and “Bootstrap-port” parameters override the default ports that Appium runs. “UDID” is the device id that Appium will interact.

When you run that command, point your browser to Selenium Grid landing page(http://localhost:4444/grid/console). You will see Appium servers are running properly.

device lab

Changing Project Structure

This part is based on a project that I developed by using Java and TestNG. The below configuration is for that project.

Changing TestNG.xml File

At first, you need to modify your testNG.xml file. You can manage your test suites with this .xml file. For every device you have, you’ll replicate your test tag. In this way, you will pass different parameters to your RemoteWebDriver and to run your tests on a specific device.

You need to set “Thread-count” parameter to your total device number in your device lab.

Changing Java Code

In automation code, we get parameters from our TestNG.xml file and pass them to the Android, iOS, Remote driver. Thus, we need to add “@Parameter” annotation above our test methods, and we can use them in those test methods. In this way, we can use those parameters in DesiredCapabilities Object.

To fully automate your process, I suggest you to use a Continuous Integration tool to trigger test runs. I used Maven as a build manager.

At last, everything is configured and ready to run, hit “Run” button on Jenkins (CI tool) and see all your devices will run the same test in parallel. Automate this process in parallel makes us a happy tester 🙂

If you execute more than one thread for your parallel test runs, please avoid using Singleton Design Pattern in your PageObjects. This implementation causes some weird behavior during test execution. It is better to use ThreadLocal structure so RemoteWebDriver object becomes thread-safe.

You can download my demo project on

Video Link:



Since 2005, Keytorc Software Testing Services has been assisting its customers to manage their critical software testing processes to reduce the total cost of producing high quality systems. Keytorc uses a risk-based prioritization approach to get to the right answers and overcome the top reasons for failure.The Company has the best references from the banking, insurance, telecommunications, IT, commerce and public sectors.


Database Operations in JavaFX

By Onur Baskirt / Apr 1, 2016 / 56 Comments
Before started this section, please check the first article and learn How to Start JAVAFX! At first, part of JavaFX tutorial series, we created a sample JavaFX project, designed the draft version of the UI and set up an...
rest assured

REST API Testing with Rest Assured

By Onur Baskirt / Mar 8, 2016 / 32 Comments
Outline In this post, I will explain what is API and API testing, what is the difference between SOAP and REST services, and how to test REST APIs with Rest Assured Library. What is API? API stands for Application Programming...

How to Write Effective CSS Locators

By Onur Baskirt / Oct 1, 2017 / 0 Comments
Hi all, in this tutorial, I will describe you how to write effective CSS locators to interrogate web elements for your automation projects. As a rule of thumb, your interrogation strategy should be in below order: First try to use...

Selenium-11: Execute JavaScript with JavascriptExecutor

By Onur Baskirt / Jan 27, 2016 / 15 Comments
Outline Sometimes we cannot handle some conditions or problems with Webdriver, web controls don't react well against selenium commands. In this kind of situations, we use Javascript. It is useful for custom synchronizations, hide or show the web elements, change...

Getting Started with JavaFX

By Onur Baskirt / Mar 25, 2016 / 0 Comments
When I started to work in my current position, one of my task is to do manual operations for campaign products  every week. After the second week, I thought that I have to automate this task using a GUI based...

How to Write Smart XPath Locators

By Onur Baskirt / Sep 24, 2017 / 4 Comments
Hi all, in this tutorial, I will describe you how to write smart and non-brittle XPath locators. When we write our test scripts, we generally prefer to use id, name, class, etc. these kinds of locators. However, sometimes we could not...

Selenium-1: Quick Start to Automation with Selenium WebDriver & JAVA & JUnit & Maven & IntelliJ

By Onur Baskirt / Sep 8, 2015 / 26 Comments
Outline Selenium Webdriver is the most popular open source web test automation framework across wide range of browsers and platforms. In this tutorial you will learn how to do web test automation with Selenium Webdriver and the related tools. Audience...
page object model

Page Object Model with C#

By Ege Aksoz / Jun 18, 2017 / 8 Comments
In the previous tutorial, we’ve taken the initial steps and entered the world of automated testing. We also wrote our first automated test. From this point on, since we are not just going to write one test, we need to...

How to Select a Date From DatePicker Using Selenium

By Onur Baskirt / Aug 13, 2016 / 6 Comments
When you need to automate a airway, hotel, or similar websites you need to deal with Datepickers and some times it is a little bit cumbersome to select a specific date on the Datepicker or calendar.  In this post, I...

Selenium Webdriver Performance testing with Jmeter and Selenium Grid

By Ozgur Kaya / Aug 9, 2016 / 2 Comments
In this post, we will complete Selenium Webdriver Performance testing scenario using Jmeter and Selenium Grid. 1- Install Java 7 or later If necessary 2- Download latest Jmeter version 3.0 or higher. 3- Download Jmeter PluginsManager JAR file and...
By | 2017-01-13T21:33:41+00:00 October 16th, 2016|Appium, Mobile Automation, Selenium, Test Automation|4 Comments

About the Author:

Canberk Akduygu
Canberk Akduygu is working as a Technical QA Architect on test automation and performance testing. Formerly, he worked at TEB as QA Project Lead, Ayrotek IBM Business Partner and Yapi Kredi Bank as Java Developer. You can also follow him on Linkedin.


  1. Muhammad Rafique October 20, 2016 at 8:45 am - Reply

    Hello Canberk,

    It was a pretty informative writing, I need to just confirm few things.
    Appium can handle only device interaction, agree, and you have suggested to write a batch script.
    – Cant we run the same appium server by providing different ports for different devices?
    – If several appium are required then can we run all on single machine? if yes then what will be the configurations?
    – If we are providing device capabilities and configurations in device.json files then why we are gain using the port and udid in batch file? How to overcome this
    – To runn all nodes appium configurations in single batch file then how can we configure all?
    – Why we are using bootstrap port in batch file?

    I will be waiting for your comment.


    • Canberk Akduygu
      Canberk Akduygu October 21, 2016 at 10:51 pm - Reply

      Hi Muhammad,

      You should many appium server with regards to your device number. One server can only handle one mobile device. You cannot run an appium server with different port.

      In this example i have run all appium servers in one laptop. I suggest you to get Mac’s. One mini mac can handle up to 15-20 machines.

      We cannot run all appium server in one batch. Batch are sequencial applications. It cannot run the second appium server if the first one is not shut down.

      Bootstarp port is for rmi communication. It cant be the same for every appium server. You need to modify it for every appium that you run.

      Hope those answers help you

  2. David October 22, 2016 at 8:21 am - Reply

    There’s also the, which is similar

  3. Jeiner Rolon January 30, 2017 at 11:17 pm - Reply

    Good afternoon

    Canberk Akduygu we have followed your tutoriual step by step, we have implemented the session for two mobiles, but at the moment of launching the script, the request opens in both mobile but at the moment of following the step by step only does it in one, not We know that more to do, you can guide us.

    Thank you so much.

Leave A Comment