51Testing软件测试论坛

标题: 使用appium测试Android app遇到无法启动app的问题 [打印本页]

作者: maplee    时间: 2017-6-16 09:44
标题: 使用appium测试Android app遇到无法启动app的问题
各位大神,我在使用appium进行安卓app自动化测试的时候,遇到一个问题,
就是只有在手机重启之后的10~15分钟之内,app可以正常运行,
而超过这个时间,我无法再启动app,即使等很久,看起来好像是在手机端的appium.uiautomator2.server暂停运行了,所以没有相应?
这个时候,我只有重启手机,才能恢复正常,但是同样,超过10~15分钟,又无法连接了,各位大神有遇到这种情况,或者给点帮助的么?

无法连接的时候,ADB log 如下:

[UiAutomator2] Starting uiautomator2 server v0.1.5 with cmd: am,instrument,-w,io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner
[UiAutomator2] running command...
adb -s 33c535c8 shell am instrument -w io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner...
[UiAutomator2] Waiting up to 20000ms for UiAutomator2 to be online...
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: Error: Trying to proxy a session command without session id
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","33c535c8","shell","am","force-stop","com.dashang.tiangou"]
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","33c535c8","forward","--remove","tcp:8200"]
[MJSONWP] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: Error: read ECONNRESET
    at JWProxy.proxy$ (../../../lib/jsonwp-proxy/proxy.js:153:13)
    at tryCatch (C:\Program Files\nodejs\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Program Files\nodejs\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Program Files\nodejs\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (C:\Program Files\nodejs\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)



我的系统环境如下:

Appium Version : 1.6.5
Java-Client: 5.0.0-BETA5
Selenium-java:3.4.0
JDK: jdk1.8.0_112
Android: 6.0.1

代码配置如下:

       DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability("deviceName", appDeviceName);
        capabilities.setCapability("platformVersion", appPlatFormVersion);
        capabilities.setCapability("app", apk.getAbsolutePath());
        capabilities.setCapability("appActivity", activityName);
        capabilities.setCapability("platformName", "android");
        capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
        capabilities.setCapability(AndroidMobileCapabilityType.APP_WAIT_ACTIVITY, "com.dashang.*");
        capabilities.setCapability("autoGrantPermissions", "true");

        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

作者: jingzizx    时间: 2017-6-17 09:58
帮顶
作者: finismundi    时间: 2017-10-4 17:15
我也遇到了这个问题,请问楼主解决了没呀




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2