Increasing Test Coverage with Hybrid Automation Frameworks

Eqxtech Admin
Equinox Media Tech
Published in
5 min readApr 20, 2022

Originally published at https://eqxtech.com on April 20, 2022
by
Kunj Vegada

In today’s world, people tend to browse on mobile browsers more than desktop browsers. Due to this, it is critical for any Testing team to test thoroughly on mobile browsers in addition to desktop browsers.

All software needs testing before it can be released to end users. Software testing is a crucial part of the development cycle as it ensures superior quality deliverables to the end users. However, testing different browsers and devices manually is a very time-consuming and costly affair. It involves too much effort and time.

Every company focuses on testing, and most of them are tending towards automation testing over manual testing. This is because, in the manual testing process, the testing team generates various test cases and manually tests every feature. If a defect is found, the defect is reported to the developers to fix the errors. Again, the process continues until the quality product is attained.

Available solutions on the market

Today, there are very few solutions available on the market that can be used for web and mobile automation together. Most tools are limited to a single programming language, and do not give the opportunity to select another programming language, perhaps one you are more comfortable with. Often, teams will need to do heavy modifications in order to run the same scripts between mobile and web browsers.

What is Hybrid Automation Framework

There are two major types of automation frameworks available in the market

  1. Framework which works on web browsers like Selenium
  2. Works on mobile devices (native as well as mobile browsers) like Appium

A hybrid automation framework is a combination of both types of frameworks based on the requirements of a given project. With this type of automation framework, we can run any test script on mobile as well as desktop browsers with minor tweaks and can handle different test approaches like data-driven or library architecture. This can help us to get the benefits of different test approaches, less duplicate code logic, and overcome the disadvantages of individual frameworks.

Case Study

Developers and testers use the Appium framework for the automation of web, native, and hybrid mobile applications. The Selenium framework is used for web application automation.

Appium and Selenium have one common thing as they use the WebDriver protocol to communicate with the target platform: Appium with the mobile device, Selenium with a web browser. Appium clients wrap the Selenium WebDriver client libraries. Appium uses an extended set of the WebDriver APIs, specific for the interaction with mobile devices.

High Level Requirements

To run same set of automation scripts on web and mobile browsers, our automation framework should support both app and selenium. Let’s check what features we should add to our framework to achieve our goal:

  1. Avoid duplicate code in test scripts
  2. Reuse element locators
  3. Less maintenance efforts
  4. Coverage should be increased

Solution

Here if we create different frameworks for mobile browser and web browser then there will be lot of duplicate code and maintenance will be high. It will require a greater number of resources to work on multiple projects. Instead of the creation of two different projects, we decided to create a single framework which has the support of Appium as well as selenium to run the same test cases on mobile and web browsers.

How it works

Nowadays most of the applications have multiple types of clients: web, desktop, mobile, which in turn can be run on diverse hardware platforms under various operating systems. For an Automation engineer, it is necessary to execute tests on all combinations of hardware and browser. Let us check how it works.

We design a framework in such a way that the user should provide an input where he wishes to run test cases and based on that input corresponding type of driver will create and run a test script on desired platform. We can create a global variable call executionType in config.properties file which will accept value like desktop browser or mobile browser a value as desktopBrowser then selenium webdriver will create and it will run scripts with that. If a user enters value as mobileBrowser then appium driver will be created based on provided capabilities and it will run test script on device browser.

High level Architecture Diagram

Glimpse of Framework code

Switching the driver between Web and Mobile
Method to detect a Mobile Browser

Most responsive websites will provide similar functionality on all supported platforms. Users will find some difference with respect to UI based on mobile browser compared to desktop browser. To handle these kinds of changes we need to use some set of different code to test same functionality on web and mobile browser. Based on which platform test case execution is going on, it will use respective code block.

Pros:

  • Robust Framework: When the framework is built in a structured manner, it helps improve the overall quality and reliability of a software.
  • Saves time in test case creation/maintenance: With a hybrid framework, engineers must write only a single code for the test cases so when there is any functional update then they must change it in one place only.
  • Code reusability: We can write dynamic code and reuse it for similar functionalities on different pages. As we maintain single framework so code will not be duplication in different projects.
  • No need for multiple projects: It helps to get rid of maintaining different projects for the same application — different platform
  • Increase test coverage: As we can run same set of test scripts on mobile browser as well as on web browsers, testing coverage will increase.

Cons:

Framework maintenance will be complex: Hybrid frameworks will contain multiple types of web drivers based on hardware specifications. So, it will be complex to understand and maintain changes in case of changes in hardware specification.

Conclusion

Selenium and Appium are not different frameworks, which can be used only for web and mobile test automation respectively, we can combine these frameworks in one test for testing web applications in the mobile browser and desktop browser, which can interact with web and mobile clients. The same set of test cases can be reused and run on both platforms.

Originally published at https://eqxtech.com on April 20, 2022.

--

--