使用appium测试Android app遇到无法启动app的问题

allfex 2017-06-16 09:55:51
各位大神,我在使用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);
...全文
6204 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_44729366 2020-03-19
  • 打赏
  • 举报
回复
有人解决了这个问题吗
fun0 2018-12-17
  • 打赏
  • 举报
回复
我这边发现是小米的神隐模式(电量管控)导致socket不能跟外界通讯 把这个模式关闭即可
Perry_Lee 2018-03-13
  • 打赏
  • 举报
回复
楼主问题解决了吗 我也遇到同样的问题
Renan33 2017-12-18
  • 打赏
  • 举报
回复
楼主解决了么?
  • 打赏
  • 举报
回复
楼主解决了么,我也遇到了这个问题,安卓4.4和5.1可以,但是换了6。0和6.1就遇到这个问题

786

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 非技术区
android小程序微信小程序 技术论坛(原bbs)
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧