获取app-package和app-activity的值

Posted 超级宝宝11

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取app-package和app-activity的值相关的知识,希望对你有一定的参考价值。

原文链接:http://sqa.stackexchange.com/questions/12373/android-app-testing-with-appium/12382#12382

I suggest you to use adb (android Debug Bridge) tool (part of Android SDK). So, install application under test on target Android device or emulator. And you should run application to get current activity and package name. So, after running app execute the following commands from command line (android-sdk/platform-tools/adb):

1 adb shell 
2 dumpsys window windows | grep -E mCurrentFocus|FocusedApp

And you will get something like this:

mCurrentFocus=Window{43270790 u0 com.estrongs.android.pop/com.estrongs.android.pop.view.FileExplorerActivity} mFocusedApp=AppWindowToken{44d67b88 token=Token{435e5990 ActivityRecord{434ee320 u0 com.estrongs.android.pop/.view.FileExplorerActivity t133

So, current activity is com.estrongs.android.pop/.view.FileExplorerActivity and application package name is com.estrongs.android.pop is this case.

Steps:

  1. Install apk on device or emulator//安装待测apk。
  2. Run application//运行待测apk。
  3. Execute adb shell from command line//执行adb shell命令。
  4. Execute command to get current activity from device(shell) shell://执行下面命令。

    dumpsys window windows | grep -E ‘mCurrentFocus|FocusedApp‘

I hope it helps you.

以上是关于获取app-package和app-activity的值的主要内容,如果未能解决你的问题,请参考以下文章

注解和反射反射获取泛型反射获取注解

C# 获取控件高度和宽度的问题

如何获取当前的日期和时间

微信js-sdk开发获取签名和获取地理位置接口示例

Flutter获取图片大小(网络图片和本地图片)

获取图片和下载到本地和名字和链接的获取