Appium Appium 测试用例运行卡在了 app 包安装上了,错误日志好像是说有另外一个 session 在运行,但没有在跑啊

shela2009 · 2016年05月06日 · 最后由 落叶秋心 回复于 2017年02月16日 · 2481 次阅读

Appium 测试用例运行卡在了 app 包安装上了,错误日志好像是说有另外一个 session 在运行所以无法创建 session
以下是日志

C:\Users\qimeng>appium -a 127.0.0.1 -p4723 -U02835ebc2115d2cb
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {"udid":"02835ebc2115d2cb","address":"127.0.0.1"}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"C:\\workspace\\FamilyAppiumTest\\apps\\FamilyEducation_DEV_0428.apk","appPackage":"com.fasthand.familyeducation","appActivity":"com.moduleLogin.welcome.NewWelcomeActivity","browserName":"","unicodeKeyboard":"True","platformName":"Android","deviceName":"02835ebc2115d2cb","version":"5.1.0","resetKeyboard":"True"}}
info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_45)
warn: Converting cap unicodeKeyboard from string to boolean. This might cause unexpected behavior.
warn: Converting cap resetKeyboard from string to boolean. This might cause unexpected behavior.
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : version
info: [debug] Using local app from desired caps: C:\workspace\FamilyAppiumTest\apps\FamilyEducation_DEV_0428.apk
info: [debug] Creating new appium session 234bb751-f1a4-4b62-b5cd-1cd23ee0c9f0
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_45
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\software\android-sdk\tools\adb.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 02835ebc2115d2cb
info: [debug] Setting device id to 02835ebc2115d2cb
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb wait-for-device
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 22
info: Device API level is: 22
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell "getprop persist.sys.language"
info: [debug] Current device persist.sys.language: zh
info: [debug] java -jar "C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\workspace\FamilyAppiumTest\apps\FamilyEducation_DEV_0428.apk" "C:\Users\qimeng\AppData\Local\Temp\com.fasthand.familyeducation" zh
info: [debug] No strings.xml for language 'zh', getting default strings.xml
info: [debug] java -jar "C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\workspace\FamilyAppiumTest\apps\FamilyEducation_DEV_0428.apk" "C:\Users\qimeng\AppData\Local\Temp\com.fasthand.familyeducation"
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb push "C:\\Users\\qimeng\\AppData\\Local\\Temp\\com.fasthand.familyeducation\\strings.json" /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\software\android-sdk\build-tools\22.0.1\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: C:\software\android-sdk\build-tools\22.0.1\aapt.exe dump xmltree C:\workspace\FamilyAppiumTest\apps\FamilyEducation_DEV_0428.apk AndroidManifest.xml
info: [debug] Set app process to: com.fasthand.familyeducation
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for C:\workspace\FamilyAppiumTest\apps\FamilyEducation_DEV_0428.apk.
info: [debug] executing cmd: java -jar C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\workspace\FamilyAppiumTest\apps\FamilyEducation_DEV_0428.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\workspace\FamilyAppiumTest\apps\FamilyEducation_DEV_0428.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from C:\software\android-sdk\build-tools\22.0.1\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: C:\software\android-sdk\build-tools\22.0.1\zipalign.exe -f 4 C:\workspace\FamilyAppiumTest\apps\FamilyEducation_DEV_0428.apk C:\Users\qimeng\AppData\Local\Temp\11646-4128-5e37bk\appium.tmp
info: [debug] MD5 for app is b5dbeed19c62f12c2607b6e2662f870d
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell "ls /data/local/tmp/b5dbeed19c62f12c2607b6e2662f870d.apk"
info: [debug] Getting install status for com.fasthand.familyeducation
info: [debug] Getting device API level
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 22
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell "pm list packages -3 com.fasthand.familyeducation"
info: [debug] App is not installed
info: Installing App
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell "mkdir -p /data/local/tmp/"
info: [debug] Removing any old apks
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell "ls /data/local/tmp/*.apk"
info: [debug] Found an apk we want to keep at /data/local/tmp/b5dbeed19c62f12c2607b6e2662f870d.apk
info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell rm "/data/local/tmp/KinguserV4.8.1B245.apk" && rm "/data/local/tmp/KinguserV4.8.5B255.apk" && rm "/data/local/tmp/cdb96382c6d52f5284d4e2480ff40c66.apk" && rm "/data/local/tmp/mq_1458735647.apk" && rm "/data/local/tmp/mq_1458735681.apk"
info: <-- POST /wd/hub/session - - ms - -
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"C:\\workspace\\FamilyAppiumTest\\apps\\FamilyEducation_DEV_0428.apk","appPackage":"com.fasthand.familyeducation","appActivity":"com.moduleLogin.welcome.NewWelcomeActivity","browserName":"","unicodeKeyboard":"True","platformName":"Android","deviceName":"02835ebc2115d2cb","version":"5.1.0","resetKeyboard":"True"}}
info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_45)
error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress
info: [debug] Error: Requested a new session but one was in progress
    at [object Object].Appium.start (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\lib\appium.js:139:15)
    at exports.createSession (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\lib\server\controller.js:188:16)
    at Layer.handle [as handle_request] (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
    at Route.dispatch (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
    at Layer.handle [as handle_request] (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
    at C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:267:22
    at Function.proto.process_params (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:100:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\lib\server\controller.js:39:7
    at Layer.handle [as handle_request] (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:110:13)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:104:14)
    at Route.dispatch (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\route.js:91:3)
    at Layer.handle [as handle_request] (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
    at C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:267:22
    at Function.proto.process_params (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
    at methodOverride (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\method-override\index.js:79:5)
    at Layer.handle [as handle_request] (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
    at trim_prefix (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:302:13)
    at C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:270:7
    at Function.proto.process_params (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
    at logger (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\morgan\index.js:136:5)
    at Layer.handle [as handle_request] (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\layer.js:82:5)
    at trim_prefix (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:302:13)
    at C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:270:7
    at Function.proto.process_params (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:321:12)
    at next (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\express\lib\router\index.js:261:10)
    at C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\body-parser\lib\read.js:111:5
    at done (C:\Users\qimeng\AppData\Roaming\npm\node_modules\appium\node_modules\body-parser\node_modules\raw-body\index.js:248:14)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Requested a new session but one was in progress)","origValue":"Requested a new session but one was in progress"},"sessionId":"234bb751-f1a4-4b62-b5cd-1cd23ee0c9f0"}
info: <-- POST /wd/hub/session 500 615.653 ms - 250
undefined

eclipse 代码如下

public void setUp() throws Exception {
    // set up appium
    File classpathRoot = new File(System.getProperty("user.dir"));
    // 存放app目录:apps
    File appDir = new File(classpathRoot, "apps");
    File app = new File(appDir, "FamilyEducation_DEV_0428.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("unicodeKeyboard", "True");//支持中文
    capabilities.setCapability("resetKeyboard", "True");//支持中文
    capabilities.setCapability("deviceName","02835ebc2115d2cb");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability(CapabilityType.BROWSER_NAME,"");
    capabilities.setCapability(CapabilityType.VERSION, "5.1.0");
    capabilities.setCapability("app", app.getAbsolutePath());
    capabilities.setCapability("appPackage", "com.fasthand.familyeducation");
    capabilities.setCapability("appActivity", "com.moduleLogin.welcome.NewWelcomeActivity");
    //初始化
    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 
}

开始我以为是因为原来安装的 apk 签名的原因,就把 apk 卸载了,但是还是不行。
Junit 的报错是

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 602.98 seconds
Build info: version: '2.50.0', revision: '1070ace', time: '2016-01-27 18:40:08'
System info: host: 'JQM', ip: '10.0.0.12', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
Driver info: io.appium.java_client.android.AndroidDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
    at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:37)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:161)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:170)
    at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:82)
    at com.fasthand.familyeducation.strategyTest.articleFromHome.setUp(articleFromHome.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

java.lang.NullPointerException
    at com.fasthand.familyeducation.strategyTest.articleFromHome.tearDown(articleFromHome.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

每次运行会卡到这一条日志上:

info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell rm "/data/local/tmp/KinguserV4.8.1B245.apk" && rm "/data/local/tmp/Kinguser
V4.8.5B255.apk" && rm "/data/local/tmp/cdb96382c6d52f5284d4e2480ff40c66.apk" && rm "/data/local/tmp/mq_1458735647.apk" && rm "/data/local/tmp/mq_1458735681.apk"

我没明白为什么会有 Kinguser V4.8.5B255.apk 的日志?

现在依旧不明白原因,只是看到卡到 Kinguser 这里了,猜测可能是之前用 Kingroot 来 root 手机后来把 Kingroot 卸载了出的问题?重新下载了 Kingroot,然后就好了。。。
但是 Kingroot 跟 appium 有什么关系?appium 不是不需要 root 权限吗?

共收到 20 条回复 时间 点赞

session 没有 quit 吧,重启一下 appium server 看看?

—— 来自 TesterHome 官方 安卓客户端

#1 楼 @hyman 因为第一次运行的时候就卡在这里了,我就用 Ctrl+c 给退出了。后来发现这个报错,不知道怎么找到那个 session,就重启了下 eclipse 和 cmd。还是不行

我也经常遇到,直接重启下 appium server 即可解决该问题。

一楼正解,必须 quit 再启动新的 session

quit appium 重启就好了,之前的链接没有断开导致的

#5 楼 @darkmanno6 请问 quit 的命令是什么?

#6 楼 @blue_momo2009 直接 ctrl+c 就好了、然后再输入 appium 启动服务

#7 楼 @darkmanno6 我就是用的 Ctrl+c,还是会报这个错。所以我还以为有别的命令

那这样,打开任务管理器,把 node.exe 这个进程都 kill 了,再重新启动呢

#9 楼 @darkmanno6 其实 ctrl+c 后 node 都自己 kill 了。可是还是报错啊

#9 楼 @darkmanno6 会卡到这一条上

info: [debug] executing cmd: C:\software\android-sdk\tools\adb.exe -s 02835ebc2115d2cb shell rm "/data/local/tmp/KinguserV4.8.1B245.apk" && rm "/data/local/tmp/Kinguser
V4.8.5B255.apk" && rm "/data/local/tmp/cdb96382c6d52f5284d4e2480ff40c66.apk" && rm "/data/local/tmp/mq_1458735647.apk" && rm "/data/local/tmp/mq_1458735681.apk"

不要 capabilities.setCapability("app", app.getAbsolutePath());这个试试咯,手机已经安装 apk 了就不配置试试

试试换一台手机跑或者换一台电脑跑,有可能是手机问题,重启下手机也是备选方案

appium 设置里面有个 override existing session,我一般习惯性的勾选了

在任务管理器里面把 node kill 了就好了,脚本里面用命令 kill 进程

#15 楼 @eurekasaber 没有用,下次启动还是会卡到同一条上

#14 楼 @snowmaster 我使用命令行启动的,不是 appium for windows

driver.quit()

Checking if an update is available
Update not available
Launching Appium server with command: E:\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.android.calculator2","appActivity":".Calculator","platformName":"Android","deviceName":"Android Emulator","platformVersion":"4.4"}}
info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
info: [debug] Creating new appium session 200b90fc-6123-48c3-8632-1a36fcac64e1
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_25
info: [debug] Checking whether adb is present
warn: The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb.
info: [debug] executing cmd: where adb
info: [debug] Using adb from E:\adt\sdk\platform-tools\adb.exe

warn: No app capability, can't parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it's already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: "E:\adt\sdk\platform-tools\adb.exe" devices
info: [debug] 1 device(s) connected
info: Found device emulator-5554
info: [debug] Setting device id to emulator-5554
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: "E:\adt\sdk\platform-tools\adb.exe" -s emulator-5554 wait-for-device
info: [debug] executing cmd: "E:\adt\sdk\platform-tools\adb.exe" -s emulator-5554 shell "echo 'ready'"
info: [debug] Starting logcat capture
error: Logcat capture failed: spawn "E:\adt\sdk\platform-tools\adb.exe" ENOENT
info: [debug] Stopping logcat capture

网上类似的问题特别多,根据网上的解决方法,都不可行,麻烦看下呢

同学我跟你一样,你们怎么解决的呀?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册