当前位置:   article > 正文

appium_真机测试_No route found. Setting content type to 'text/plain'

no route found. setting content type to 'text/plain

问题描述:

在使用appium进行真机测试的时候,在配置好需要的参数后点击Start Session就出现了问题

 报错如下:

  1. [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":".ui.LauncherUI","appPackage":"com.tencent.mm","deviceName":"ONEPLUS_A6000","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
  2. [BaseDriver] Event 'newSessionRequested' logged at 1547127578106 (21:39:38 GMT+0800 (中国标准时间))
  3. [Appium] Creating new AndroidDriver (v4.8.0) session
  4. [Appium] Capabilities:
  5. [Appium] appActivity: .ui.LauncherUI
  6. [Appium] appPackage: com.tencent.mm
  7. [Appium] deviceName: ONEPLUS_A6000
  8. [Appium] platformName: Android
  9. [Appium] newCommandTimeout: 0
  10. [Appium] connectHardwareKeyboard: true
  11. [BaseDriver] Creating session with MJSONWP desired capabilities: {"appActivity":".ui.Launche...
  12. [BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
  13. [BaseDriver] Session created with session id: 20e1edb0-4925-409e-bbba-989dd2d8bcc3
  14. [AndroidDriver] Java version is: 1.8.0_191
  15. [AndroidDriver] Retrieving device list
  16. [ADB] Trying to find a connected android device
  17. [ADB] Getting connected devices...
  18. [ADB] 1 device(s) connected
  19. [AndroidDriver] Using device: ca0fc03b
  20. [ADB] Setting device id to ca0fc03b
  21. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell getprop ro.build.version.sdk'
  22. [ADB] Current device property 'ro.build.version.sdk': 28
  23. [ADB] Device API level: 28
  24. [AndroidDriver] Consider setting 'automationName' capability to 'uiautomator2' on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
  25. [AndroidDriver] App file was not listed, instead we're going to run com.tencent.mm directly on the device
  26. [AndroidDriver] Checking whether package is present on the device
  27. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell pm list packages com.tencent.mm'
  28. [AndroidDriver] Starting Android session
  29. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b wait-for-device'
  30. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell echo ping'
  31. [AndroidDriver] Pushing settings apk to device...
  32. [ADB] Getting install status for io.appium.settings
  33. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell dumpsys package io.appium.settings'
  34. [ADB] 'io.appium.settings' is installed
  35. [ADB] Getting package info for 'io.appium.settings'
  36. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell dumpsys package io.appium.settings'
  37. [AndroidDriver] Ignored error while installing Appium Settings helper: 'Could not find aapt Please set the ANDROID_HOME environment variable with the Android SDK root directory path.'. Manually uninstalling the application with package id 'io.appium.settings' may help. Expect some Appium features may not work as expected unless this problem is fixed.
  38. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell ps'
  39. [ADB] Device API level: 28
  40. [ADB] Device API level: 28
  41. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
  42. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
  43. [AndroidDriver] Failed to launch settings app: Cannot start the 'io.appium.settings' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command 'C\:\\Android\\adb.exe -P 5037 -s ca0fc03b shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' timed out after 20000ms'; Stderr: ''; Code: 'null'
  44. [ADB] Device API level: 28
  45. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell appops set io.appium.settings android\:mock_location allow'
  46. [Logcat] Starting logcat capture
  47. [ADB] Getting device platform version
  48. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell getprop ro.build.version.release'
  49. [ADB] Current device property 'ro.build.version.release': 9
  50. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell wm size'
  51. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell getprop ro.product.model'
  52. [ADB] Current device property 'ro.product.model': ONEPLUS A6000
  53. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell getprop ro.product.manufacturer'
  54. [ADB] Current device property 'ro.product.manufacturer': OnePlus
  55. [AndroidDriver] No app sent in, not parsing package/activity
  56. [AndroidDriver] No app capability. Assuming it is already on the device
  57. [ADB] Getting install status for com.tencent.mm
  58. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell dumpsys package com.tencent.mm'
  59. [ADB] 'com.tencent.mm' is installed
  60. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell am force-stop com.tencent.mm'
  61. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell pm clear com.tencent.mm'
  62. [AndroidDriver] Performed fast reset on the installed 'com.tencent.mm' application (stop and clear)
  63. [AndroidBootstrap] Watching for bootstrap disconnect
  64. [ADB] Forwarding system: 4724 to device: 4724
  65. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b forward tcp\:4724 tcp\:4724'
  66. [UiAutomator] Starting UiAutomator
  67. [UiAutomator] Moving to state 'starting'
  68. [UiAutomator] Parsing uiautomator jar
  69. [UiAutomator] Found jar name: 'AppiumBootstrap.jar'
  70. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b push 'C:\\Program Files (x86)\\Appium\\resources\\app\\node_modules\\appium-android-driver\\bootstrap\\bin\\AppiumBootstrap.jar' /data/local/tmp/'
  71. [ADB] Attempting to kill all uiautomator processes
  72. [ADB] Getting all processes with uiautomator
  73. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell ps'
  74. [ADB] No 'uiautomator' process has been found
  75. [UiAutomator] Starting UIAutomator
  76. [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","ca0fc03b","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.tencent.mm","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
  77. [UiAutomator] Moving to state 'online'
  78. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
  79. [AndroidBootstrap] Android bootstrap socket is now connected
  80. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell dumpsys window'
  81. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
  82. [AndroidDriver] Screen is locked, trying to unlock
  83. [AndroidDriver] Using app unlock, this is going to be deprecated!
  84. [AndroidDriver] Unlocking screen
  85. [AndroidDriver] Launching .Unlock
  86. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell am start -n io.appium.settings/.Unlock -c android.intent.category.LAUNCHER -a android.intent.action.MAIN -f 0x10200000'
  87. [AndroidBootstrap] Emitting alert message...
  88. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Emitting system alert message
  89. [ADB] Device API level: 28
  90. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell am start -W -n com.tencent.mm/.ui.LauncherUI -S'
  91. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell am start -W -n com.tencent.mm/.ui.LauncherUI -S'
  92. [AndroidDriver] Shutting down Android driver
  93. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell am force-stop com.tencent.mm'
  94. [ADB] Pressing the HOME button
  95. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell input keyevent 3'
  96. [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
  97. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
  98. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
  99. [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
  100. [AndroidBootstrap] Received command result from bootstrap
  101. [UiAutomator] Shutting down UiAutomator
  102. [UiAutomator] Moving to state 'stopping'
  103. [UiAutomator] UiAutomator shut down normally
  104. [UiAutomator] Moving to state 'stopped'
  105. [ADB] Attempting to kill all uiautomator processes
  106. [ADB] Getting all processes with uiautomator
  107. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell ps'
  108. [ADB] No 'uiautomator' process has been found
  109. [UiAutomator] Moving to state 'stopped'
  110. [Logcat] Stopping logcat capture
  111. [ADB] Running 'C:\Android\adb.exe -P 5037 -s ca0fc03b shell am force-stop io.appium.unlock'
  112. [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
  113. [BaseDriver] Event 'newSessionStarted' logged at 1547127664707 (21:41:04 GMT+0800 (中国标准时间))
  114. [MJSONWP] Encountered internal error running command: Error: Cannot start the 'com.tencent.mm' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command 'C\:\\Android\\adb.exe -P 5037 -s ca0fc03b shell am start -W -n com.tencent.mm/.ui.LauncherUI -S' timed out after 20000ms'; Stderr: ''; Code: 'null'
  115. [MJSONWP] at ADB.apkUtilsMethods.startApp (C:\Program Files (x86)\Appium\resources\app\node_modules\appium-adb\lib\tools\apk-utils.js:144:11)
  116. [MJSONWP] at process._tickCallback (internal/process/next_tick.js:68:7)
  117. [HTTP] <-- POST /wd/hub/session 500 86653 ms - 534
  118. [HTTP]
  119. [HTTP] --> DELETE /wd/hub/session
  120. [HTTP] {}
  121. [HTTP] No route found. Setting content type to 'text/plain'
  122. [HTTP] <-- DELETE /wd/hub/session 404 5 ms - 57

 

原因分析:

在度娘找了好久,有说是因为环境配置的问题,和appium和sdk不兼容导致的,但是我的appium值点击Start Session的时候时而成功,时而出错,目测是环境不兼容导致的,还有个原因就是你的手机锁屏了,真正的原因还在寻找。

解决:

无意间发现了一个偏方,就是将所有appium软件关闭,等一两分钟后在打开,重新执行。不行的话就重启

 

重新打开后在执行就成功了,执行结果:

 

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号