1、应该是不会重复安装这两个 apk 的,除非你之前安装的 apk 和目前安装的不一样才会安装
2、楼主可以试试注销安装 ui2 apk 的源码,改为启动脚本的时候,代码里面用 adb 安装
直接 id 定位试试,find_element_by_id("我知道了"),不知道楼主 appium 版本是多少的,我厂使用 1.7.2 直接可以通过 id 定位
xpath 是绝对可以找到元素的,楼主可以看看是不是页面有细微的变化或者滑动页面导致 xpath 变化了,一般我厂都是 id 和 xpath 还有 aid,能解决 99% 的定位问题
这个地址要 *** 才行的哦,另外推荐一种方法,bootstrap.jar 的方式
https://testerhome.com/topics/9210
问下楼主安装 libimobiledevice 没有 iproxy 这个功能了,可以告知安装的 libimobiledevice 版本是多少么,我的版本为 HEAD-26373b3_2
应该和 appium 没关系,这个是 adb 做 kill 进程的时候,没有权限,你把这个命令贴到命令行运行一下,看看是不是也是报的这个错误
试试"automationName": "uiautomator2"
这个链接能点么?有点怀疑你这个完美版本的脚本没投入正式使用
def force_stop_server(self, server_name):
"""
强制停止应用进程
:param server_name: 应用进程的package name
:return:
"""
if not server_name:
U.Logging.error("please enter package name")
return
self.shell("am force-stop {0}".format(server_name))
def start_test_instrument(self, package_name, case_name):
"""
启动一个测试程序
:param case_name: 想要执行的测试类
:param package_name: 应用进程的package name
:return:
"""
if not package_name or not case_name:
U.Logging.error("please enter package name or case_name")
return
self.shell("am instrument -w {0}/{1}".format(package_name, case_name))
def restart_ui_server(self):
"""
尝试解决一下问题:
Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: Error: socket hang up
解决方法:
兼容ui2服务启动被杀死的情况,手动重启
:return:
"""
package_name = "io.appium.uiautomator2.server.test"
case_name = "android.support.test.runner.AndroidJUnitRunner"
self.force_stop_server(package_name)
self.start_test_instrument(package_name, case_name)
U.Logging.info("restart ui server success...")
贴下我的解决方案,不知对楼主是否有效
楼主跑 case 有没有遇到 ui2 服务莫名其妙被杀死的情况?
不是我自己杀死的,我这边做的操作就是常规的跑 appium 自动化,脚本在运行一段时间后,有一定几率抛异常,然后我抓了 Automator2 的日志,发现是进程被杀掉了,不知道是 vivo 自己杀死的还是 appium 触发了某个异常之后杀死的
05-04 15:37:22.029 7164 7821 I appium : channel read invoked!
05-04 15:37:22.029 7164 7821 I appium : channel read: POST /wd/hub/session/6a8067ba-9127-4ab2-b8e3-9cc8eb6b4ff9/element
05-04 15:37:22.030 7164 7821 I appium : Find element command
05-04 15:37:22.031 7164 7821 I appium : find element command using 'id' with selector 'com.cmi.jegotrip:id/skip_btn'.
05-04 15:37:22.504 7164 7821 I appium : AppiumResponse: {"sessionId":"6a8067ba-9127-4ab2-b8e3-9cc8eb6b4ff9","status":7,"value":"An element could not be located on the page using the given search parameters."}
05-04 15:37:23.026 7164 7822 I appium : channel read invoked!
05-04 15:37:23.027 7164 7822 I appium : channel read: POST /wd/hub/session/6a8067ba-9127-4ab2-b8e3-9cc8eb6b4ff9/element
05-04 15:37:23.027 7164 7822 I appium : Find element command
05-04 15:37:23.029 7164 7822 I appium : find element command using 'id' with selector 'com.cmi.jegotrip:id/skip_btn'.
05-04 15:37:23.502 7164 7822 I appium : AppiumResponse: {"sessionId":"6a8067ba-9127-4ab2-b8e3-9cc8eb6b4ff9","status":7,"value":"An element could not be located on the page using the given search parameters."}
05-04 15:37:24.024 7164 7825 I appium : channel read invoked!
05-04 15:37:24.024 7164 7825 I appium : channel read: POST /wd/hub/session/6a8067ba-9127-4ab2-b8e3-9cc8eb6b4ff9/element
05-04 15:37:24.025 7164 7825 I appium : Find element command
05-04 15:37:24.026 7164 7825 I appium : find element command using 'id' with selector 'com.cmi.jegotrip:id/skip_btn'.
05-04 15:37:24.516 7164 7825 I appium : AppiumResponse: {"sessionId":"6a8067ba-9127-4ab2-b8e3-9cc8eb6b4ff9","status":7,"value":"An element could not be located on the page using the given search parameters."}
05-04 15:37:29.477 1471 1891 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10850 user=0: from pid 2759
05-04 15:37:29.477 1471 1891 I ActivityManager: Killing 7164:io.appium.uiautomator2.server/u0a850 (adj 0): stop io.appium.uiautomator2.server
05-04 15:37:29.478 1471 1891 W ActivityManager: Crash of app io.appium.uiautomator2.server running instrumentation ComponentInfo{io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner}
05-04 15:37:29.478 1471 1891 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10850 user=0: finished inst
05-04 15:37:29.524 1471 1892 W AppOps : Bad call: specified package io.appium.uiautomator2.server.test under uid 10850 but it is really 10849
更新下 Automator2 被杀死时的日志
Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/a47fd6da-2f85-40a6-a36f-8f613dabf298/element] with body: {"strategy":"id","selector":"com.cmi.jegotrip:id/log_out","context":"","multiple":false}
[MJSONWP] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: Error: socket hang up
at JWProxy.proxy$ (../../../lib/jsonwp-proxy/proxy.js:152:13)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at <anonymous>
[HTTP] <-- POST /wd/hub/session/be37a78e-43a7-402c-9840-4f2554810855/element 500 173 ms - 250
[debug] [UiAutomator2] [UIAutomator2] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:INSTRUMENTATION_RESULT: shortMsg=Process crashed.
1、我的这两个 apk 都安装了
2、手机为 vivo x9
3、系统 7.1.1
看了大家发生的情况,都和我这个不太一样,我的是执行过程中有一段时间是好的,突然就挂掉了, 看日志比较像 Automator2 挂掉了,不知道有人遇到过没
老哥,我也遇到这个问题了,appium 官方说建议我们跟新 adb 或者不用 uiautomator2 作为测试套件,但是不用 uiautomator2 的话 7.0 没法玩了,所以还有别的解决办法没?
mac 系统今天安装 appium 启动的时候,遇到这个错,看社区里面也没人遇到过,自己也没解决,目前所有的包都不是 sudo 安装的,但是启动报这个错