环境:Mac , Appium 1.7.1 ,python
前提:使用 Appium 进行 Android 自动化测试过程中,有部分页面进入过程需要很多操作步骤,所以采取了 Appium 的 start_activity 方法,直接跳转
问题:部分页面不存在直接进入的 Activity ,但是可以通过 Scheme 跳转的方式进入,问题是进入页面,但是存在报错,提示 Activity never started
代码如下

from action.PageAction import *

driver = open_app()
print 'open app finish'
driver.start_activity('com.autohome.usedcar', 'com.autohome.usedcar.uccontent.MainTabActivity') #进入首页,正常执行
print 'start maintab finish'

scheme_url = 'usedcar://scheme.che168.com/salecar?param=%7bc2bState%3a0%7d'
driver.start_activity('com.autohome.usedcar', 'com.autohome.usedcar.uccarlist.SchemeActivity', optional_intent_arguments=scheme_url) #进入发车页
print 'SchemeActivity'
[debug] [ADB] Getting connected devices...[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/zhangbingwei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","MZJZFQS8WOFEP7Q4","shell","dumpsys","window","windows"]
[debug] [ADB] Found package: 'com.autohome.usedcar' and fully qualified activity name : 'com.autohome.usedcar.FragmentRootActivity'
[debug] [ADB] Incorrect package and activity. Retrying.[debug] [ADB] Getting focused package and activity
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/zhangbingwei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","MZJZFQS8WOFEP7Q4","shell","dumpsys","window","windows"]
[debug] [ADB] Found package: 'com.autohome.usedcar' and fully qualified activity name : 'com.autohome.usedcar.FragmentRootActivity'
[debug] [ADB] Incorrect package and activity. Retrying.[debug] [ADB] Getting focused package and activity
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/zhangbingwei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","MZJZFQS8WOFEP7Q4","shell","dumpsys","window","windows"]
[debug] [ADB] Found package: 'com.autohome.usedcar' and fully qualified activity name : 'com.autohome.usedcar.FragmentRootActivity'
[debug] [ADB] Incorrect package and activity. Retrying.[error] [ADB] Error: Error occured while starting App. Original error: 'com.autohome.usedcar.uccarlist.SchemeActivity' never started
    at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-support/lib/logging.js:63:13)
    at ADB.callee$0$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/lib/tools/apk-utils.js:101:9)
    at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
 Error: Error occured while starting App. Original error: 'com.autohome.usedcar.uccarlist.SchemeActivity' never started
    at Object.wrappedLogger.errorAndThrow (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-support/lib/logging.js:63:13)
    at ADB.callee$0$0$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/lib/tools/apk-utils.js:101:9)
    at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)


↙↙↙阅读原文可查看相关链接,并与作者交流