2 1 L A B S
Appium grid

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.

Setting up Appium:

First you need to set up Appium locally. If you have not set up Appium locally yet, here is the link for setting it up on OS X, and here is the link for setting it up on windows.

Setting the grid locally:

Configuring the Grid:

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:

> hostname

Finally, if the grid is setup successfully you will see the following:

blank

Setting Up the Node:

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”.

 

Script Execution:

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):

blank

Setting the grid on cloud:

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:

blank

 

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.

blank blank

 

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)

blankblank

 

blank

 

Now we have our mobile automation set up for grid testing.

Useful Libraries:

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
Ruby https://github.com/appium/ruby_lib, https://github.com/appium/ruby_lib_core
Python https://github.com/appium/python-client
JavaScript (Node.js) https://github.com/webdriverio/webdriverio
PHP https://github.com/appium/php-client
C# (.NET) https://github.com/appium/appium-dotnet-driver
Robot Framework https://github.com/serhatbolsu/robotframework-appiumlibrary

 

Hardware Configuration for Appium:

Minimum Hardware Requirements:

  • Intel® i5 or i7 processor.
  • 1 GB free hard disk space.
  • 8 GB RAM
  • 1 available USB 2.0 port and USB cable.

USB Recommendations:

  • Backports from the desktop are recommended.
  • Try avoiding USB 3.0 ports.
  • Pluggable USB 2.07 is recommended as a USB hub.
  • If using Samsung or HTC, then ensure that Samsung Kites or HTC sync is not installed.
  • Allow USB debugging for android phones.
  • Makes sure that the iTunes is up to date.

Making Mobile Devices Ready for Automation:

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,

  1. Open “Settings” panel of the phone.
  2. Go in to the “About” section.
  3. Tap on the “Software Information” and then click “More”.
  4. Keep on tapping the build number 7 times to enable the “developers mode”.
  5. To verify the “Developers Options”, go back to the “Settings”.
  6. Tap on the Developer Options to turn on the USB Debugging.

blank

 

WD/HUB While Creating an Instance Through Appium:

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.

Conclusion:

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.

Useful Resources and Links:

https://www.seleniumeasy.com/appium-tutorials/connecting-appium-to-selenium-grid-example

http://appium.io/docs/en/advanced-concepts/grid/

https://medium.com/@ar.xa.vasquez/how-to-register-an-appium-node-to-a-selenium-grid-546f08aadc66

https://testguild.com/create-mobile-testing-grid/

https://www.softwaretestinghelp.com/appium-studio-tutorial-2/

Related Post

Leave a Comment

Subscribe To Our Newsletter

21Labs

Connecting testing and production.Autonomously.

California, USA

© Copyrights 2020 21Labs All rights reserved. Made with By 21Labs