Open Lujiax opened 7 years ago
which version of your uiautomator?
pip show uiautomator
2017-02-21 18:10 GMT+08:00 Lujiax notifications@github.com:
Hi xiaocong: when I run my testcases,vivo phone repeatedly installed apk(app-uiautomator.apk、app-uiautomator- test.apk). vivo ROM:Funtouch OS_2.5.1 Android 5.1.1 Is it a problem with the vivo system? or How can I optimize the init file. Thanks.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xiaocong/uiautomator/issues/199, or mute the thread https://github.com/notifications/unsubscribe-auth/ACR5-vOpQmI1a465PL5VlW5-McOxuG_rks5rergGgaJpZM4MHHMx .
-- BAO HONGBIN
Hi @hongbinbao: uiautomator Version: 0.2.6 . Thanks.
update adb/uiautomator and have a try: adb: 1.0.36 uiautomator: 0.2.7
2017-02-22 10:00 GMT+08:00 Lujiax notifications@github.com:
Hi @hongbinbao https://github.com/hongbinbao: uiautomator Version: 0.2.6 . Thanks.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xiaocong/uiautomator/issues/199#issuecomment-281544495, or mute the thread https://github.com/notifications/unsubscribe-auth/ACR5-nxop5UibSvNX-aUOgSKK2Ym97GEks5re5bTgaJpZM4MHHMx .
-- BAO HONGBIN
@hongbinbao Thanks, It is still not resolved. 而且我不太理解为什么总有异常,而走jsonrpc_wrap中server.start的逻辑;(uiautomator init文件)。
Same to me. Using adb v1.0.36, adb server also crash
On vivo X7, every time I start to run the code below, test-api and uiautomator are required to be re-installed.
# 自动点击安装
def protect(device):
while True:
d = Device(device)
confirm_ele = [d(textContains="安装"), d(textContains="确定"), d(textContains="允许"), d(textContains="继续安装")]
for el in confirm_ele:
if el.exists:
el.click()
sleep(1)
logger.info('Protect @{} over.'.format(device))
if __name__ == '__main__':
protect('5d35ea1a') # Replace this to your device id
pass
adb log is as below:
03-09 17:06:13.635 30812-30958/? D/UIAutomatorStub: URI: /jsonrpc/0, Method: POST, Header: {content-length=200, remote-addr=127.0.0.1, accept-encoding=identity, host=localhost:9009, http-client-ip=127.0.0.1, content-type=application/json}, params, {NanoHttpd.QUERY_STRING=null}, files: {postData={"params": [{"childOrSiblingSelector": [], "mask": 2, "textContains": "\u7ee7\u7eed\u5b89\u88c5", "childOrSibling": []}], "jsonrpc": "2.0", "method": "exist", "id": "ac62d1ee700976530c088611de10c22a"}}
03-09 17:06:39.445 30812-31018/? D/UIAutomatorStub: URI: /jsonrpc/0, Method: POST, Header: {content-length=188, remote-addr=127.0.0.1, accept-encoding=identity, host=localhost:9009, http-client-ip=127.0.0.1, content-type=application/json}, params, {NanoHttpd.QUERY_STRING=null}, files: {postData={"params": [{"childOrSiblingSelector": [], "mask": 2, "textContains": "\u5b89\u88c5", "childOrSibling": []}], "jsonrpc": "2.0", "method": "exist", "id": "14327b2060ef3410d56783a6dbe8ee28"}}
03-09 17:06:39.475 30812-31018/? W/JsonRpcServer: Error in JSON-RPC Service
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.googlecode.jsonrpc4j.JsonRpcServer.invoke(JsonRpcServer.java:513)
at com.googlecode.jsonrpc4j.JsonRpcServer.handleObject(JsonRpcServer.java:384)
at com.googlecode.jsonrpc4j.JsonRpcServer.handleNode(JsonRpcServer.java:293)
at com.googlecode.jsonrpc4j.JsonRpcServer.handle(JsonRpcServer.java:230)
at com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:97)
at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:331)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:953)
at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:208)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalStateException: UiAutomation not connected!
at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:914)
at android.app.UiAutomation.getRootInActiveWindow(UiAutomation.java:413)
at android.support.test.uiautomator.UiAutomatorBridge.getRootInActiveWindow(UiAutomatorBridge.java:82)
at android.support.test.uiautomator.QueryController.getRootNode(QueryController.java:170)
at android.support.test.uiautomator.UiDevice.hasObject(UiDevice.java:145)
at android.support.test.uiautomator.Until$2.apply(Until.java:55)
at android.support.test.uiautomator.Until$2.apply(Until.java:52)
at android.support.test.uiautomator.WaitMixin.wait(WaitMixin.java:40)
at android.support.test.uiautomator.WaitMixin.wait(WaitMixin.java:34)
at android.support.test.uiautomator.UiDevice.wait(UiDevice.java:181)
at com.github.uiautomator.stub.AutomatorServiceImpl.exist(AutomatorServiceImpl.java:697)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.googlecode.jsonrpc4j.JsonRpcServer.invoke(JsonRpcServer.java:513)
at com.googlecode.jsonrpc4j.JsonRpcServer.handleObject(JsonRpcServer.java:384)
at com.googlecode.jsonrpc4j.JsonRpcServer.handleNode(JsonRpcServer.java:293)
at com.googlecode.jsonrpc4j.JsonRpcServer.handle(JsonRpcServer.java:230)
at com.github.uiautomator.stub.AutomatorHttpServer.serve(AutomatorHttpServer.java:97)
at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:331)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:953)
at fi.iki.elonen.NanoHTTPD$1$1.run(NanoHTTPD.java:208)
at java.lang.Thread.run(Thread.java:818)
03-09 17:06:40.745 1398-2351/? I/VivoADBInstallDialog: packagePath is : /data/local/tmp/app-uiautomator.apk
03-09 17:06:40.755 1398-2351/? I/VivoADBInstallDialog: sPackagePath is : /data/local/tmp/app-uiautomator.apk
03-09 17:06:40.755 1398-2351/? I/PackageManager: packageName:com.github.uiautomator appName:uiautomator isNotAllowUnknownSource:false warnResult:2
03-09 17:06:40.775 1398-1398/? I/VivoADBInstallDialog: get sPackagePath is : /data/local/tmp/app-uiautomator.apk
03-09 17:06:41.035 1398-1398/? I/VivoADBInstallDialog: get sPackagePath is : /data/local/tmp/app-uiautomator.apk
03-09 17:06:41.035 1398-1398/? I/VivoADBInstallDialog: scanning file path is : /data/local/tmp/app-uiautomator.apk
03-09 17:06:41.035 2717-2717/? I/VirusScanService: filePath is : /data/local/tmp/app-uiautomator.apk
03-09 17:06:41.035 2717-2717/? D/VirusScanService: packageName is : com.github.uiautomator
03-09 17:06:41.045 2717-2717/? D/ScanUtil: >>>>>>>>>addVirusPackage>>>>>>>>>>>>packageName = com.github.uiautomator
03-09 17:06:41.335 2717-31046/? D/VirusScanService: pkgname= com.github.uiautomator virustype= 0
03-09 17:06:41.335 2717-31046/? D/VirusScanService: packageName = com.github.uiautomator ,certMD5 = FE1248ECBD398EFE6749D38DC475719E
03-09 17:06:42.355 2717-31046/? I/QScannerManagerV2: cloudAnalyse: com.github.uiautomator, category: 0 - 0
03-09 17:06:42.355 1398-1398/? I/VivoADBInstallDialog: get sPackagePath is : /data/local/tmp/app-uiautomator.apk
This is caused directly by the method AutomatorServer.start()
which invokes AutomatorServer.push()
or AutomatorServer.install()
. And AutomatorServer.start()
is invoked by AutomatorServer.jsonrpc_wrap()
which is used everywhere such like ele.exists()
. My suggestion is that you install the apks and push the jars manually and modify the AutomatorServer.start()
in __init__.py
as below:
def start(self, timeout=5):
# if self.sdk_version() < 18:
# files = self.push()
# cmd = list(itertools.chain(
# ["shell", "uiautomator", "runtest"],
# files,
# ["-c", "com.github.uiautomatorstub.Stub"]
# ))
# else:
# self.install()
# cmd = ["shell", "am", "instrument", "-w",
# "com.github.uiautomator.test/android.support.test.runner.AndroidJUnitRunner"]
if self.sdk_version() < 18:
files = list(self.__jar_files.keys())
cmd = list(itertools.chain(
["shell", "uiautomator", "runtest"],
files,
["-c", "com.github.uiautomatorstub.Stub"]
))
else:
cmd = ["shell", "am", "instrument", "-w",
"com.github.uiautomator.test/android.support.test.runner.AndroidJUnitRunner"]
self.uiautomator_process = self.adb.cmd(*cmd)
self.adb.forward(self.local_port, self.device_port)
while not self.alive and timeout > 0:
time.sleep(0.1)
timeout -= 0.1
if not self.alive:
raise IOError("RPC server not started!")
fixed in my fork version atx-uiautomator
I write a piece of code to fix this. Call this method before your install. Don't forget to put *.jar
and *.apk
in lib
folder.
def uiauto_install(device):
proc = subprocess.Popen("adb -s {} shell pm list packages".format(device), stdout=subprocess.PIPE)
result = proc.communicate()[0]
if "package:com.github.uiautomator" in result:
logger.info("{}: package:com.github.uiautomator package detected.".format(device))
return
else:
logger.info("{}: package:com.github.uiautomator package missing, installing.".format(device))
proc = subprocess.Popen("adb -s {} install -r -d {}".format(device, "lib/app-uiautomator.apk"))
proc.communicate()
proc = subprocess.Popen("adb -s {} install -r -d {}".format(device, "lib/app-uiautomator-test.apk"))
proc.communicate()
proc = subprocess.Popen("adb -s {} push {} /data/local/tmp".format(device, "lib/uiautomator-stub.jar"))
proc.communicate()
proc = subprocess.Popen("adb -s {} push {} /data/local/tmp".format(device, "lib/bundle.jar"))
proc.communicate()
logger.info("{}: package:com.github.uiautomator package missing, install over.".format(device))
Hi xiaocong: when I run my testcases,vivo phone repeatedly installed apk(app-uiautomator.apk、app-uiautomator- test.apk). vivo ROM:Funtouch OS_2.5.1 Android 5.1.1 Is it a problem with the vivo system? or How can I optimize the init file. Thanks.