Back to Blog
Automation Testing

Automation testing of a mobile app in AWS Device Farm

Avanish Pandey

November 13, 2022

Automation testing of a mobile app in AWS Device Farm

Here Automation testing of a mobile app in AWS Device Farm, A gadget ranch is a trying climate that permits QAs to distantly test the exhibition of versatile applications on countless genuine gadgets. It offers admittance to both present-day and heritage renditions of devices from different makers. Besides, these gadgets accompany pre-introduced OS and programs.

Different gadget ranch sellers are accessible on the lookout. While picking the seller, we thought about the accompanying – scope of gadgets upheld for Android and iOS, testing system uphold alongside investigating and announcing abilities. We focused on AWS gadget ranch as the best fit for our necessities.

AWS gadget ranch

AWS Device Farm is an application testing administration. It lets you improve the nature of your web and versatile applications by testing them over a broad scope of work area programs and genuine cell phones. Furthermore, you don’t need to deal with any testing foundation.

AWS gadget ranches permit application testing in two modes:

Robotized Testing: It allows you to transfer your test bundles or utilize AWS worked in content free similarity tests.

Far off Access: You can transfer your application and collaborate with a gadget through your internet browser continuously.

We utilized robotized testing, which helped test our application in equal against a monstrous assortment of actual gadgets in the AWS Cloud.

Mechanized Testing of Android application with AWS gadget ranch

Pre-essentials Appium Cucumber TestNG

IAM client record and admittance to gadget ranch comfort

Composing TestNG Tests utilizing Appium components and Cucumber details Design contents

Set up pom.xml

The get-together will experience the modules and conditions added to our pom.xml record needed to work with AWS gadget ranch.

AWS Device Farm

The primary activity is to ensure that your pom.xml record contains the accompanying line:

<packaging>jar</packaging>

This line shows that you will

incorporate your Maven venture with a solitary packed JAR yield document. For a similar explanation, make a point to add the following expert container module.

container: Allows to bundle our principle classes as a container document

test-container: Allows us get-together to bundle our test classes as a container record

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-container plugin</artifactId>

<version>2.6</version>

<executions>

<execution>

<goals>

<goal>test-jar</goal>

</goals>

</execution>

</executions>

</plugin>

Characterize the conditions for Appium, TestNG and cucumber

<dependencies>

<dependency>

<groupId>org.testng</groupId>

<artifactId>testng</artifactId>

<version>6.11</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>io.appium</groupId>

<artifactId>java-client</artifactId>

<version>4.1.2</version>

</dependency>

</dependencies>

<dependency>

<groupId>info.cukes</groupId>

<artifactId>cucumber-java</artifactId>

<version>1.2.5</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>info.cukes</groupId>

<artifactId>cucumber-testng</artifactId>

<version>1.2.4</version>

</dependency>

Module beneath ensures that the entirety of the conditions for your undertaking gets included with the resultant JAR document.

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-reliance plugin</artifactId>

<version>2.10</version>

<executions>

<execution>

<id>copy-dependencies</id>

<phase>package</phase>

<goals>

<goal>copy-dependencies</goal>

</goals>

<configuration>

<outputDirectory>${project.build.directory}/reliance containers/</outputDirectory>

</configuration>

</execution>

</executions>

</plugin>

The underneath module is the get together device to parse your guidance document.

<plugin>

<artifactId>maven-gathering plugin</artifactId>

<version>2.5.4</version>

<executions>

<execution>

<phase>package</phase>

<goals>

<goal>single

</goal>

</goals>

<configuration>

<finalName>zip-with-dependencies</finalName>

<appendAssemblyId>false</appendAssemblyId>

<descriptors>

<descriptor>src/primary/get together/zip.xml</descriptor>

</descriptors>

</configuration>

</execution>

</executions>

</plugin>

  1. Make a document called xml in the accompanying way src/principle/get together/zip.xml with beneath Assembly

<assembly

xmlns="http://maven.apache.org/modules/expert get together module/gathering/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-case" xsi:schemaLocation="http://maven.apache.org/modules/expert get together module/gathering/1.1.0 http://maven.apache.org/xsd/gathering 1.1.0.xsd">

<id>zip</id>

<formats>

<format>zip</format>

</formats>

<includeBaseDirectory>false</includeBaseDirectory>

<fileSets>

<fileSet>

<directory>${project.build.directory}</directory>

<outputDirectory>./</outputDirectory>

<includes>

<include>*.jar</include>

</includes>

</fileSet>

<fileSet>

<directory>${project.build.directory}</directory>

<outputDirectory>./</outputDirectory>

<includes>

<include>/reliance containers/</include>

</includes>

</fileSet>

</fileSets>

</assembly>

  1. Set up your venture

Add the component records to the assets organizer in an accompanying way src/test/assets:

Essentially add information suppliers (property records that incorporate area, test information documents, and so forth) similar to that of highlight documents.

  1. Run mvn clean order, which assists with getting out the past JAR records made
  1. Run mvn – DskipTests bundle order, which helps run the content to create the JAR document by skirting running the We have to remember our documents and organizers. When the compress record is made after the construct is useful, it incorporates all the vital container documents needed to execute our tests.

Note: We can check for the container records in the compressed document produced by utilizing the JD-GUI application.

Transferring test bundle and begin running on AWS Device Farm:

To transfer the test bundle and run on gadget ranch, you have to have an IAM client account on AWS with composing authorization access.

At that point, go to gadget ranch support and make another venture by giving your task the name.

  1. Make another run where you will have five stages to finish to run your test bundle.

Transfer your .apk document to be tried.

Here in this progression, pick Appium Java TestNG and transfer your compress document produced for your test bundle. (AWS Device Farm)

When your compress document is transferred, at that point, you can choose the execution climate; you need to run your tests. Here we will select a custom climate and select the default test detail gave by AWS gadget ranch. You can likewise alter it appropriately, relying upon your need.

Amazon Device Farm (ADF) is an application testing administration that encourages testing and cooperation with Android, iOS, and Web applications on genuine, actual telephones and tablets. Amazon Web Services facilitate these gadgets. The Amazon Device Farm can be utilized in two different ways:

Mechanized testing of Android, iOS, and Web applications utilizing an assortment of accessible testing structures

Distant access of genuine gadgets onto which applications can be stacked, run, and explored

In Amazon Device Farm, mechanized tests can be run utilizing Appium, Calabash, etc. You can find out about the total rundown of upheld test types here.

I have tried an application utilizing the Appium Java TestNG system in ADF. This post is a bit by bit manages on the best way to run computerized test contents for versatile applications on Amazon Device Farm over a broad scope of gadgets.

Essentials

Overshadowing (For the nearby turn of events/execution)

JDK (Java Development Kit) (For the nearby turn of events/execution) Android SDK (For the nearby turn of events/execution)

Appium

TestNG

Selenium-worker independent Apache Maven

BUILDING APPIUM JAVA TESTNG PACKAGE USING ECLIPSE

Make New Maven Project in Eclipse

Add conditions of Selenium, Appium, and TestNG in the pom.xml

Compose all experiments in Project name > src (Source) > test > Java > Tests bundle MODULE LEAD QUALITY ASSURANCE

Amazon Device Farm (ADF) is an application testing administration that encourages testing and cooperation with Android, iOS, and Web applications on genuine, actual telephones and tablets. Amazon Web Services facilitate these gadgets. The Amazon Device Farm can be utilized in two different ways:

AWS Device Farm

Mechanized testing of Android, iOS, and Web applications utilizing an assortment of accessible testing structures

Distant access of genuine gadgets onto which applications can be stacked, run, and explored

In Amazon Device Farm, mechanized tests can be run utilizing Appium, Calabash, etc. You can find out about the total rundown of upheld test types here.

I have tried an application utilizing the Appium Java TestNG system in ADF. This post is a bit direct on the best way to run computerized test contents for portable applications on Amazon Device Farm over a broad scope of gadgets.

Requirements

Shroud (For neighborhood improvement/execution)

JDK (Java Development Kit) (For neighborhood improvement/execution) Android SDK (For neighborhood improvement/execution)

Appium

TestNG

Selenium-worker independent Apache Maven

BUILDING APPIUM JAVA TESTNG PACKAGE USING ECLIPSE

Make New Maven Project in Eclipse

Add conditions of Selenium, Appium, and TestNG in the pom.xml

Compose all experiments in Project name > src (Source) > test > Java > Tests bundle Task STRUCTURE IN ECLIPSE

The Project Structure will look as it’s appeared beneath in Eclipse:

Here is how Amazon Device Farm is set up to test the Android Native application by executing the Appium Java TestNG test onto ADF. The code to do so is given beneath:

bundle test.AbstractBaseTests;

import io.appium.java_client.MobileElement; import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.*;
import java.net.MalformedURLException; import java.net.URL;
import java.util.concurrent.TimeUnit;
/**
  • A theoretical base for the entirety of the Android tests inside this bundle
*
  • Responsible for setting up the Appium tester

*/

public conceptual class TestBase {

/**

  • Make the driver This permits it to be made just a single time
  • and utilized over the entirety of the test

*/

public static AndroidDriver<MobileElement> driver;

/**

  • This permits the route to work inside the
  • The class name is returned so we can explore it from the route
  • @return The name of the Android class

*/

public theoretical String getName();

/**

  • Method to introduce the test’s page

*/ @BeforeTest

public theoretical void setUpPage();

/**

  • This strategy runs before some other

*

  • Appium follows a customer – worker model:
  • We are setting up our appium customer so as to associate with Device Farm’s appium

*

  • @throws MalformedURLException An exemption that happens when the URL isn’t right

*/ @BeforeSuite

public void setUpAppium() tosses MalformedURLException{

last String URL_STRING = "http://127.0.0.1:4723/wd/center"; Url = new URL(URL_STRING);

/Use an unfilled DesiredCapabilities object

driver = new AndroidDriver<MobileElement>(url, new DesiredCapabilities());

/Use a higher worth if your versatile components set aside effort to appear driver.manage().timeouts().implicitlyWait(35, TimeUnit.SECONDS);

}

/**

  • never forget to stop

*/ @AfterSuite

public void tearDownAppium(){ driver.quit();

}

/**

  • Restart the application after each test class to return to the fundamental
  • screen and to reset the conduct

*/ @AfterClass

public void restartApp() {

driver.resetApp();

}

}

The neighborhood climate is currently set up with an Eclipse venture that comprises TestNG tests. Presently run the test suite locally with Appium and approve the tests. On the off chance that the trial is effective, at that point, prepare to run the tests on Amazon Device Farm.

Adjust POM.XML

A bundle in .zip design should be made to transfer on ADF. This bundle ought to contain Android Appium Java TestNG tests and all the test conditions. Pom.xml of the Maven should be changed before making a .zip bundle. Allude to this connection to meet the necessities during the bundling phase of a Maven fabricate.

Assemble PACKAGE WITH DEPENDENCIES

Open the order brief, explore to the workspace, and enter the accompanying order:

A compress with-dependencies.zip record will be made in the objective organizer.

AWS CONSOLE STEPS:

Open the AWS Console and log in. Go to the Device Farm and make a venture. Inside the undertaking, select Automated tests > Create another run.

Transfer the Android APK record. The subtleties will be shown as appeared underneath once the APK document is transferred.

Arrange test: Select test type > Appium Java TestNG and transfer the .compress record that contains both the trial and conditions.

Select Devices: Select the gadgets on which you need to run your test. The default gadget pool can be

chosen, or you can make another gadget pool of your decision.

Indicate Device State: Here, we can determine gadget states to supersede any gadget settings. This considers adding extra information or potentially introducing different applications for ADF to use during the run. Additionally, we can determine whether Wi-Fi, Bluetooth, GPS, or NFC will be empowered during the run, pre-set the gadget scope and longitude for the run, and pre-set the run’s gadget region.

Audit and start run: Here, we can change the transferred APK record, test document (.compress record), and Device pool.

Affirm and Start Run: Click on the "Affirm and Start Run" button. This will take an alternate measure of time contingent upon the application size and experiments. Test outcomes are shown once the trial is finished.

REPORTS

Amazon Device Farm test reports give pass/bomb data, logcat catches, gadget logs, screen captures, recordings, and execution information. Snap here for point by point data on examining reports in ADF.

Advantages OF USING ADF FOR MOBILE AUTOMATION TESTING

ADF Automation tests are helpful for Smoke and Regression tests

Various gadgets dependent on make, model, transporter variation, and working framework rendition can be chosen for a trial without buying them.

During a trial, Device Farm catches execution tests each second.

Reports in Device Farm contain pass and bomb data, crash reports, test and gadget logs, recordings, screen captures, and execution information.

Reports incorporate both nitty-gritty per-gadget information just as significant level outcomes, for example, the number of events of a given issue.

Avanish Pandey

November 13, 2022

icon
icon
icon

Subscribe to our Newsletter

Sign up to receive and connect to our newsletter

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Latest Article