This is a step-by-step guide on how to setup an Appium grid and connect your devices locally for the purposes of mobile test automation.
In order to setup the grid initially run the following command in the terminal:
> java -jar selenium-server-standalone.jar -role hub -port 4444 -host hostname
You can use the following command to display the hostname:
Finally, if the grid is setup successfully you will see the following:
Now we will set up the node. Nodes are the instances executed by the Appium to run the tests loaded on the hub.
One needs to connect the device to the machine. Let’s call this device with hostname “My-Node”.
Let’s assume we are using port 4722, run the following command into the terminal:
> Appium –port 4722 –nodeconfig config_ios.json
The name which we will be using for out json file would be “config_ios.json”.
If the grid is not being used, one may get the following appium driver like the below in java:
driver = new AppiumDriver<>(new URL (“http://0.0.0.0:4723/wd/hub”), capabilities);
In this case, we should be calling the hub address, in our case “My-Hub”:
driver = new AppiumDriver<>(new URL (“http://My-Hub:4444/wd/hub”), capabilities);
Finally, it will return the Appium driver and execute the test script on the node machine. Node (json file):
For cloud grid the parameters of the node and hub are given below,
Hub: Windows (hub port: 4444 , hub ip: 10.2.6.46 )
Node1: Windows (node port: 4723 ,node ip: 10.2.6.46 )
Node2: Mac (node port: 4723 ,node ip: 10.2.6.138)
The following command will help to set up the Appium Hub:
> java – jar selenium-server-standalone-*.jar – role hub
The json file for the configuration of the Appium node is given below:
Now the Windows and Mac nodes have been configured. Now we will set up the node by running the following commands:
> appium -nodeconfig “the configuration JSOn absolute path” -no-reset
The configuration json file will require the absolute path.
This also provides the capability of setting up the multiple nodes. In this case, we need to specify listener ports according to the different devices we are using.
We have the following default ports,
Appium server and client: 4723
Appium server and testing device: 4724
However, in order to avoid conflicts we can specify the other port numbers also (e.g 4728, 4730)
Now we have our mobile automation set up for grid testing.
Some of the client libraries can add an extra feature to mobile devices like screen orientation and multi-touch gestures. These libraries use the JSON wire protocol by wrapping up the client libraries. The Appium server itself has the capability to define the official protocols and custom extensions, therefore it provides the Appium users to help to analyze the device behaviours such as installing/uninstalling apps.
|Framework Used||Installing instructions along with GitHub repo|
Before automating the app, one has to enable the “Developers Mode” on his device. Here are the easy-to-follow steps for enabling the mobile devices ready for automation,
wd stands for “Web Driver”.
Grid hub is commonly called as hub while Grid Node is commonly called as node. We use the URI to connect the node and the hub and wd/hub is a part of it.
So we need wd/hub in Appium to connect the node and the hub.
As can be seen “Grid” is used for running tests on different browsers and operating systems for parallel execution. However, if we need to increase the environments like on mobile browsers and platforms then Appium can be a very useful tool to handle this.
A grid is composed of a single hub, it can be a desktop or mobile device. However, the hub receives the all the requests like platform, browser etc and sends them to the machine that will run the tests. It is very difficult to maintain the infrastructure of different Operating Systems, browsers, and mobile devices, therefore the developers, engineers, and automation tester came up with the amazing tool “Appium” which provides the ease of cross-platform testing.