I am using Appium to automatically test some Android apps. It is a great testing tool.
My question is:
Assume the package name of the target app is package_name1. When running the test, it clicks buttons and it is possible that one button click will switch to another app such as the Settings app on the device. I want to know how to detect this. One simple way I can think of is to get the package name of the current activity and compare it against package_name1, but I cannot find the API to get the package name.
Any activity(as far as i know) contains two things.
Package name
Activity name
From this Ex: “com.Android.Settings.LaunchSettings”,
the package name is: “com.Android.Settings”
the activity name is: rest of the string following package name is activity name.
So activity name for the above ex is: “LaunchSettings”
A good topic raised about getting PackageName,
As far as i know there is no direct implementation for getting Package Name in Appium Api. Consider your scinario , you may have 2 possible ways,
The current activities must not be the same for two apps , you can compare them and verify