appium and android
September 28, 2020

How to Use Appium for Android Testing on Perfecto

Mobile Application Testing
Automation

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.

Why Appium?

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.

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.

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.

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.

appium and android

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 and android

 

 

4. Run Your Appium Tests

After adding these values to the PerfectoAppium.java 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", “com.example.android.myApp“);

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

RemoteWebDriver driver = new RemoteWebDriver(new URL ("https://<<your_cloud_name>>.perfectomobile.com/nexperience/perfectomobile/wd/hub/fast"), capabilities);

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

 

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 Appiunm, 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 and android

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 and android

 

Try Appium for Android With Perfecto

Now that you’ve learned about Appium for Android, give it a try in the Perfecto testing cloud. Leveraging a cloud testing solution like Perfecto means you can create, run, and analyze your test automation with Appium on real devices in the cloud.

With Perfecto and Appium for mobile app testing, you’ll be able to:

  • Scale testing across platforms.
  • Find and fix bugs faster.
  • Integrate into your CI/CD pipeline.
  • Extend test coverage.

See for yourself why Perfecto makes mobile testing with Appium so much better. You can get started with a free 14-day trial of Perfecto today.

Try Perfecto

Related Content