• 井号--coding:utf-8-- 然后要用 test_import.py 的绝对路径来执行,monkeyrunner d://test//test_import.py

  • 环境变量设置 ANDROID_VIEW_CLIENT_HOME 为 D:\MobileSDK\android-sdk-windows\tools\lib\AndroidViewClient\src
    然后 test_import.py 内容为

    # -*- coding: utf-8 -*-
    import sys
    import os
    sys_path = sys.path[0].split(':')
    FOLDER_PATH= sys_path[1]+":"+sys_path[2]
    
    if not os.environ['ANDROID_WRAPEASYMONKEY_HOME']:
            #print os.environ['ANDROID_WRAPEASYMONKEY_HOME']
            print 'the environment ANDROID_WRAPEASYMONKEY_HOME does not exist'
    ANDROID_WRAPEASYMONKEY_HOME = os.environ['ANDROID_WRAPEASYMONKEY_HOME']
    sys.path.append(ANDROID_WRAPEASYMONKEY_HOME)
    
    
    from com.whoistester.android.viewclient import ViewClient
    from com.whoistester.android.wrapEasyMonkey import wrapEasyMonkey
    from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
    from com.android.monkeyrunner.easy import EasyMonkeyDevice
    from com.android.monkeyrunner.easy import By
    from com.android.hierarchyviewerlib.models import ViewNode
    
    print ("start") 
    
    

    代码请用代码块。