MonkeyRunner_Android view client的配置
2012-12-13 11:25
204 查看
在monkey runner中使用android view client
1.下载 Android view client
https://github.com/dtmilano/AndroidViewClient 2.解压到本地,然后配置ANDROID_VIEW_CLIENT_HOME
在ubuntu 下打开terminal,然后输入vim ~/.bashrc,添加如下设置
export ANDROID_VIEW_CLIENT_HOME=/home/xxx/monkeyrunner/AndroidViewClient-master/AndroidViewClient
3.打开模拟器,然后执行脚本dump.py
输入命令如下:
cd AndroidViewClient
cd examples
./dump.py
运行结果如下:
/home/xxx/monkeyrunner/AndroidViewClient-master/AndroidViewClient/src/com/dtmilano/android/viewclient.py:1013: UserWarning: Running on emulator but no serial number was specified then 'emulator-5554' is used
warnings.warn("Running on emulator but no serial number was specified then 'emulator-5554' is used")
com.android.internal.policy.impl.PhoneWindow$DecorView NO_ID None
android.widget.FrameLayout id/content None
com.android.launcher2.DragLayer id/drag_layer None
com.android.launcher2.AllApps2D id/all_apps_view None
android.widget.GridView id/all_apps_2d_grid None
com.android.launcher2.AllApps2D$HomeButton id/all_apps_2d_home None
com.android.launcher2.Workspace id/workspace None
com.android.launcher2.CellLayout id/cell1 None
com.android.launcher2.CellLayout id/cell2 None
com.android.launcher2.CellLayout id/cell3 None
com.android.launcher2.LauncherAppWidgetHostView id/0xc0000 None
android.widget.LinearLayout id/0x7f0b0017 None
android.widget.ImageButton id/0x7f0b000d None
android.widget.TextView id/0x7f0b0018
android.widget.ImageButton id/0x7f0b0019 None
com.android.launcher2.LauncherAppWidgetHostView id/0xc0001 None
android.widget.RelativeLayout id/icon None
android.widget.ImageView id/horizontal None
android.widget.RelativeLayout id/vertical None
android.widget.TextView NO_ID Home
android.widget.TextView NO_ID .
android.widget.TextView id/all_apps_view 1
android.widget.ImageView id/all_apps_2d_grid None
android.widget.TextView id/all_apps_2d_home See
android.widget.TextView id/name Touch
com.android.launcher2.CellLayout id/cell4 None
com.android.launcher2.LauncherAppWidgetHostView id/0xd0000 None
android.widget.LinearLayout NO_ID None
android.widget.LinearLayout integer/config_allAppsFadeInTime None
android.widget.TextView integer/config_allAppsFadeOutTime
android.widget.TextView integer/config_allAppsBatchLoadDelay Touch
android.widget.ImageView NO_ID None
android.widget.ImageButton integer/config_allAppsBatchSize None
android.widget.ImageView NO_ID None
android.widget.ImageButton id/0x7f0a0004 None
com.android.launcher2.CellLayout id/cell5 None
android.widget.ImageView id/previous_screen None
android.widget.ImageView id/next_screen None
com.android.launcher2.DeleteZone id/delete_zone None
android.widget.RelativeLayout id/all_apps_button_cluster None
com.android.launcher2.HandleView id/all_apps_button None
android.widget.ImageView id/hotseat_left None
android.widget.ImageView id/hotseat_right None
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Before you begin, you can verify that your environment has been correctly setup after following the steps mentioned in Installation.
There is a simple script in examples that would help you do this verification.
if everything is fine, you will receiver
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AndroidViewClient配置步骤
The
shebang line to invoke
monkeyrunner interpreter if you are using Linux or Mac OS X. Unfortunately this is not available on Windows. Eclipse does not use this line but is needed if you want to simplify the way you are running the scripts from the command line.
Some standard imports
PyDev uses PYTHONPATH while
monkeyrunner ignores it. This snippet adds the components present in
PYTHONPATH to
sys.path and makes them visible to
monkeyrunner.
Following, we need to locate AndroidViewClient which you should have added to the environment. This can be also added in
Eclipse in Run Configurations -> Environment.
ANDROID_VIEW_CLIENT_HOME should point to your AndroidViewClient installation to the parent folder of
src. That is, if you have downloaded
AndroidViewClient in /opt/AndroidViewClient and kept the same structure as the distribution, you should set
ANDROID_VIEW_CLIENT_HOME=/opt/AndroidViewClient/AndroidViewClient
The imports, which will now succeed because sys.path contains the right components
Gets the device's serial number from the command line or default to
emulator-5554.
Connect to the device
Check if the connection was successful. Because
MonkeyRunner.waitForConnection() returns a
MonkeyDevice even when the connection fails we need to go to this extra step to verify it.
1.下载 Android view client
https://github.com/dtmilano/AndroidViewClient 2.解压到本地,然后配置ANDROID_VIEW_CLIENT_HOME
在ubuntu 下打开terminal,然后输入vim ~/.bashrc,添加如下设置
export ANDROID_VIEW_CLIENT_HOME=/home/xxx/monkeyrunner/AndroidViewClient-master/AndroidViewClient
3.打开模拟器,然后执行脚本dump.py
输入命令如下:
cd AndroidViewClient
cd examples
./dump.py
运行结果如下:
/home/xxx/monkeyrunner/AndroidViewClient-master/AndroidViewClient/src/com/dtmilano/android/viewclient.py:1013: UserWarning: Running on emulator but no serial number was specified then 'emulator-5554' is used
warnings.warn("Running on emulator but no serial number was specified then 'emulator-5554' is used")
com.android.internal.policy.impl.PhoneWindow$DecorView NO_ID None
android.widget.FrameLayout id/content None
com.android.launcher2.DragLayer id/drag_layer None
com.android.launcher2.AllApps2D id/all_apps_view None
android.widget.GridView id/all_apps_2d_grid None
com.android.launcher2.AllApps2D$HomeButton id/all_apps_2d_home None
com.android.launcher2.Workspace id/workspace None
com.android.launcher2.CellLayout id/cell1 None
com.android.launcher2.CellLayout id/cell2 None
com.android.launcher2.CellLayout id/cell3 None
com.android.launcher2.LauncherAppWidgetHostView id/0xc0000 None
android.widget.LinearLayout id/0x7f0b0017 None
android.widget.ImageButton id/0x7f0b000d None
android.widget.TextView id/0x7f0b0018
android.widget.ImageButton id/0x7f0b0019 None
com.android.launcher2.LauncherAppWidgetHostView id/0xc0001 None
android.widget.RelativeLayout id/icon None
android.widget.ImageView id/horizontal None
android.widget.RelativeLayout id/vertical None
android.widget.TextView NO_ID Home
android.widget.TextView NO_ID .
android.widget.TextView id/all_apps_view 1
android.widget.ImageView id/all_apps_2d_grid None
android.widget.TextView id/all_apps_2d_home See
android.widget.TextView id/name Touch
com.android.launcher2.CellLayout id/cell4 None
com.android.launcher2.LauncherAppWidgetHostView id/0xd0000 None
android.widget.LinearLayout NO_ID None
android.widget.LinearLayout integer/config_allAppsFadeInTime None
android.widget.TextView integer/config_allAppsFadeOutTime
android.widget.TextView integer/config_allAppsBatchLoadDelay Touch
android.widget.ImageView NO_ID None
android.widget.ImageButton integer/config_allAppsBatchSize None
android.widget.ImageView NO_ID None
android.widget.ImageButton id/0x7f0a0004 None
com.android.launcher2.CellLayout id/cell5 None
android.widget.ImageView id/previous_screen None
android.widget.ImageView id/next_screen None
com.android.launcher2.DeleteZone id/delete_zone None
android.widget.RelativeLayout id/all_apps_button_cluster None
com.android.launcher2.HandleView id/all_apps_button None
android.widget.ImageView id/hotseat_left None
android.widget.ImageView id/hotseat_right None
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Verifying environment setup
Before you begin, you can verify that your environment has been correctly setup after following the steps mentioned in Installation.There is a simple script in examples that would help you do this verification.
$ cd /path/to/androidviewclient $ cd AndroidViewClient $ cd examples $ monkeyrunner check-import.py
if everything is fine, you will receiver
sys.path= ['/opt/android-sdk/tools/lib/monkeyrunner.jar', '/home/user/tmp/test/AndroidViewClient-master/AndroidViewClient/examples', '/opt/android-sdk-linux/tools/lib/Lib', '/opt/android-sdk-linux/tools/lib/jython-standalone-2.5.3.jar/Lib', '__classpath__', '__pyclasspath__/', '/home/user/tmp/test/AndroidViewClient-master/AndroidViewClient/src'] OK
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
AndroidViewClient配置步骤
The
shebang line to invoke
monkeyrunner interpreter if you are using Linux or Mac OS X. Unfortunately this is not available on Windows. Eclipse does not use this line but is needed if you want to simplify the way you are running the scripts from the command line.
Some standard imports
PyDev uses PYTHONPATH while
monkeyrunner ignores it. This snippet adds the components present in
PYTHONPATH to
sys.path and makes them visible to
monkeyrunner.
Following, we need to locate AndroidViewClient which you should have added to the environment. This can be also added in
Eclipse in Run Configurations -> Environment.
ANDROID_VIEW_CLIENT_HOME should point to your AndroidViewClient installation to the parent folder of
src. That is, if you have downloaded
AndroidViewClient in /opt/AndroidViewClient and kept the same structure as the distribution, you should set
ANDROID_VIEW_CLIENT_HOME=/opt/AndroidViewClient/AndroidViewClient
The imports, which will now succeed because sys.path contains the right components
Gets the device's serial number from the command line or default to
emulator-5554.
Connect to the device
Check if the connection was successful. Because
MonkeyRunner.waitForConnection() returns a
MonkeyDevice even when the connection fails we need to go to this extra step to verify it.
相关文章推荐
- MonkeyRunner_Click on a View contains specified text using monkeyrunner and Android ViewClient
- Android之WebViewClient与WebChromeClient的区别
- Android中使用WebView, WebChromeClient和WebViewClient加载网页
- Android---SmartImageView和AsyncHttpClient的应用之《新闻客户端》案例
- android之webview的.setWebViewClient(new WebViewClient()几个方法重写
- Android中WebView的基本配置与填坑记录大全
- Android中WebView,WebViewClient,WebChromeClient区别
- Android之WebViewClient与WebChromeClient的区别
- android的WebView、WebViewClient、WebChromeClient的关系
- MR_Android view client source code(1)
- android WebView(三)WebViewClient
- 关于android WebViewClient的方法解释
- Android自动化工具Monkeyrunner使用(六) —— Eclipse + Jython 环境配置
- android WebView 和 HttpClient cookie同步
- Android: Webview的简单使用,WebViewClient(2)
- android Webview基本配置以及android与js交互
- Github-Client(ANDROID)开源之旅(三) ------ 巧用ViewPagerIndicator
- Github-Client(ANDROID)开源之旅(三) ------ 巧用ViewPagerIndicator
- Android之WebViewClient与WebChromeClient的区别
- android setWebChromeClient和setWebViewClient的使用区别