Ask a Question

How do I create a swipe routine that looks for an app on mobile device

New Member

How do I create a swipe routine that looks for an app on mobile device

I don't want to always guarantee what screen a mobile device is starting on. So after pressing the Apps menu on Android, how do I set up my test to Swipe until app is found, then it can click on the app icon. Thanks!

SmartBear Alumni (Retired)

Hi Chopper_elation,


You can do the following:

  1. You need to add the images of your app icon and the menu icon to TestComplete’s Image Repository. TestComplete will search for objects based on these images and touch them on the screen. Please read the Image-Based Testing Principles ( ) article for details.
  2. To swipe the menu window, you can call the Swipe method of the AndroidDevice object. So your test may look like this (this is a sample app that is looking for the GPSTest application on Sony):


function Test() {
  var nameAndroidDevice = "*";
  var AndroidDevice = Mobile.Device(nameAndroidDevice);
  var SonyLaunchApp = ImageRepository.SonyLaunchApp;
  // find the menu icon and touch it
  // swipe the window until the needed app is found
  AndroidDevice.Swipe(700, 200, 100, 600, 1);
  var GPSTestButton = SonyLaunchApp.GPSTest;
  if (GPSTestButton.Exists())
     // the app was found
  AndroidDevice.Swipe(700, 200, 100, 600, 1);
  if (GPSTestButton.Exists())



Tanya Yatskovskaya
SmartBear Community and Education Manager

SmartBear Alumni (Retired)

I would recommend against the image-based approach, because it may be unreliable.


The recommended way to start an app is to add its .apk to TestedApps and use:



If the app is pre-installed and you don't contol it (Calculator for example), you can run it using the "am start" shell command. You need to know the application's package name + activity name, or the intent action.

// JScript
// Run Calculator Mobile.Device.ShellExecute("am start -n");
// Run Calendar Mobile.Device.ShellExecute("am start -n");
// Open Settings Mobile.Device.ShellExecute("am start -n");
// Run Camera Mobile.Device.ShellExecute("am start -a")

To find the application's activity name for use with "am start", run the app on the device, then select the device in the Object Browser and view the RunningTaskInfo.TopActivity property. The activity syntax is PackageName/ShortClassName. For example:


PackageName =
ShortClassName = .Calculator

For more information about the "am start" command, see Using activity manager (am) in Android developer documentation.

Helen Kosova
SmartBear Documentation Team Lead
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
SmartBear Alumni (Retired)

Thanks for your solution, Helen. It’s a very interesting approach!


@chopper_elation, you can choose between two solutions or suggest your own 🙂

Tanya Yatskovskaya
SmartBear Community and Education Manager

Frequent Contributor

Here is my script


function openAppwithADBShell(device,package,activity)
var status = true;
var msg = "";
//Check Device
Mobile["Device"](device)["ShellExecute"]("adb shell am start "+ package +"/"+ activity);
status = false;
msg = Log["Error"]("openAppwithADBShell: "+"Failed!"+"The device: "+device+" is not existed!")
return(new Array("openAppwithADBShell",status,msg));


You should download the System Android Information app to know what is the package and activity of your app.

For example: 


The activity is the one contain the MAIN function.

Showing results for 
Search instead for 
Did you mean: