...

/

Designing Mobile Automation Framework

Designing Mobile Automation Framework

Learn how to design a framework for testing mobile applications using Appium and TestNG.

Our main job is to design one single framework that will be robust and cater to our needs of automating Android, iOS, and mobile web.

In this lesson, we will learn the basics components of designing a mobile automation framework.

Main components

The following are the major components of the mobile automation framework using Appium and TestNG:

Components of Mobile Automation Framework
Components of Mobile Automation Framework

Configuration management

Configuration Management is essential for any framework. It allows us to externalize the configurable parameters and override them at runtime.

We will create a singleton class for managing configurable parameters. Since the framework will be provided as a library that will be used in test projects as a dependency, we will have the default values of the configurations in the framework and the project-specific configurations, that override the default present in the framework, inside the test project.

In addition to these, the configurations should be overridable at runtime and also from the command-line.

We might be running our test suite against multiple environments. In such a case, we might also want to maintain environment-specific configurations as well.

In the below code sample do the following:

  • Load the file default.properties and override the properties with project-specific config.properties.
  • The given key is prefixed with an env name (such as stage, prod, qa, etc.) and searched for in Environment Variables. If it is not found, then it looks for the key in Environment Variables. If either of the key’s values are found, the key is returned.
  • If neither the given key prefixed with env nor the key itself is found in Environment Variables, then the same process is repeated with JVM arguments. If either of the key’s values are found, then they are returned.
  • If neither form is found in JVM arguments, then we repeat the same searching process with properties loaded from config.properties. If neither form of key is found in config.properties, the same is repeated with properties in default.properties. If either of the key’s values are found, then they are returned.
  • If not found in Environment Variables, JVM arguments, config.properties or default.properties, the provided default value is returned.

The value is looked up in the hierarchy as given in the image for environment-specific value, and if it isn’t found, then the global value in the ...