Search code examples
androidpythonandroidviewclient

How to record the activity name via AndroidViewClient/Culebra


In order to shorcut and go directly to the current activity page of Android I must first find the activity name, if it is a fragment I try to get the closest activity as possible. I use a few commands to find this info, like "adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'" or "adb shell dumpsys activity top". Unfortunately it seems that "adb shell uiautomator dump" has only the package name of the current activity in the xml file, so it is not useful. Is that possible for Culebra to record the activity name of the current activity and generate it's associated code when it is an activity and not a fragment, something like device.startActivity(component='...') ? This would be very helpful and will permit the play back of the generated script directly from the activity.


Solution

  • I think your idea may be very helpful to others so I decided to add this functionality to culebra v 10.3.4.

    The context menu, now includes Generates a startActivity()

    enter image description here

    which generates a line like this in the output script (considering that in this example Calculator was the Activity on top of the stack)

    device.startActivity('com.android.calculator2/.Calculator')