appium and android
September 28, 2020

How to Use Appium for Android Testing on Perfecto

Mobile Application Testing

Appium is the leading free open-source cross-platform test automation framework for Android and iOS mobile testing. In this blog, you’ll learn how to execute Appium tests for Android. Keep reading to learn more about Appium for Android testing.

Back to top

Why Appium for Android Testing?

Appium is widely used and backed by a large user community. It is essentially a bolt-on to Selenium that translates Selenium commands that you are most likely familiar with into ones that will work on mobile platforms.

Appium lets you drive mobile native, web, and hybrid app test automation on real (local & cloud) as well as virtual devices (emulators/simulators). It is regularly updated to support new developments in technologies and mobile platforms.

mobile automation testing
Back to top

The Complete Guide to Mobile Automation Testing

Download Now

Like Selenium, you can write Appium tests in multiple languages like Java, C#, Python, JavaScript, etc., and integrate with continuous integration platforms easily.

More and more teams are seeing Appium as their de facto test automation framework. Whether you’re already using Appium or just getting started on mobile testing basics, it’s important to master the Appium basics too.

Back to top

Why Use Perfecto to Run Appium for Android?

Perfecto seamlessly integrates with Appium for iOS and Android testing. Test automation engineers and developers can create and execute standard Appium scripts in various languages (Java, C#, etc.). And they can execute these scripts against real devices in the Perfecto cloud — even across various global locations.

Perfecto has been providing support for Appium for many years and has recently added a new architecture for testing on Android and iOS devices that is fully aligned with local Appium testing.

The new architecture has several benefits:

  • Full compatibility with the Appium standard.
  • Support of Android deep links.
  • Unique Perfecto features, such as biometrics and image injection, on the latest OS versions and devices to complement the Appium feature set.

With Perfecto you can easily run tests in parallel and scale across multiple Android platforms.

Back to top

Appium for Android: How to Execute Your Tests

1. Select an IDE

Most IDEs let you develop Appium tests in much the same way. In our example, we will use IntelliJ. We have a ready-made project that you can quickly adopt here.

2. Create a Security Token

In this project, the integration with Perfecto is already built in. The only things you need to provide are your Perfecto cloud name and security token. Here are steps to configure your test.

For example, if you signed up for a free trial account, then your cloud name would be “mobilecloud” and your security token can be found at the top right hand corner of the screen after you have logged in with your account. You will need to generate a new one the first time. The token is a very long set of characters that are unique to you and should not be shared.

3. Specify the Android Device You Want to Test On

You will also need to specify capabilities for selecting the correct device you want to use. By default, it will look for any Galaxy S device (e.g. S10, S20, etc.) that is available at the time of running.

If you want to specify a particular device to use for your testing, you can go to Manual Testing (Open Device), then select a device you would like to use for automation, and see the Capabilities on the right. You can copy and paste the code into your project too.

appium for android testing code



4. Run Your Appium Tests

After adding these values to the code, your project is ready to run. The tests should fire up on Perfecto using your user account. There is no need to specify user ID or password.

If you have existing Appium scripts, they should largely work after defining the correct endpoint to connect to and the additional capabilities to authenticate the session.

In a nutshell, these are the main things you need to define:

String securityToken = <<some_very_long_token>>;

capabilities.setCapability("appPackage", ““);

capabilities.setCapability("appActivity", “MainActivity“);

RemoteWebDriver driver = new RemoteWebDriver(new URL ("https://<<your_cloud_name>>"), capabilities);

And you can carry on with your Appium commands like findElementByCssSelector, etc. 


Back to top

4 Key Benefits of Using Appium With Perfecto

1.    Perfecto seamlessly integrates with Appium for iOS and Android, and it allows you to easily scale your testing. By defining additional devices in, say, a TestNG configuration XML (among many others), you can quickly run the same test on a new platform. Perfecto supports various execution frameworks like JUnit, TestNG, etc. which you can use with your Appium tests.

2.    With Perfecto and Appium, you can compare up to 32 platforms in parallel and step through your test.

3.    Perfecto enables you to carry out deep analysis of failure reasons with the help of AI-driven test reporting and analytics. This helps you find and fix defects quickly.

appium for android testing

4.    Get access to stack traces, video playback of the whole test, screenshots of every single step of the way, plus additional artifacts like device logs, device vitals (CPU, memory, network in and out), HAR files, PCAP files, and more. Share access to all of these easily, by just sharing just a single URL, as every test report has a unique URL.

appium for android testing
Back to top