uiautomator icon indicating copy to clipboard operation
uiautomator copied to clipboard

JsonRPCError: JsonRPC Error code: -32002, Message: UiSelector[TEXT=Phone]

Open henrydeng opened this issue 10 years ago • 13 comments

when I run this "d2(text="Phone").click() " to click the Phone icon in idle. it can launch the dial pad. but after the end of the script ,below exception throw

d2(text="Phone").click()

File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomator__init__.py", line 79, in call return self.func(args, *kwargs) File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomator__init.py", line 1090, in click return self.jsonrpc.click(self.selector) File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomator__init_.py", line 445, in wrapper return _method_obj(args, *kwargs) File "C:\Python27\lib\site-packages\uiautomator-0.1.32-py2.7.egg\uiautomator__init.py", line 131, in call raise JsonRPCError(jsonresult["error"]["code"], jsonresult["error"]["message"]) JsonRPCError: JsonRPC Error code: -32002, Message: UiSelector[TEXT=Phone]

henrydeng avatar Jul 24 '14 05:07 henrydeng

It looks like uiautomator could not find the text 'Phone'. Could you please check it using uiautomatorviewer? Thanks.

xiaocong avatar Jul 24 '14 10:07 xiaocong

the Uiautomator Viewer can find the text 'Phone', and the code is working, it can click the phone icon. but after the end of the script, it throw this error.

henrydeng avatar Jul 25 '14 07:07 henrydeng

JsonRPC Error code: -32002 means the UiObject not found. It caused by either the UiObject not found, or something wrong with the uiautomator service. Could you please dump the screen in case of the error? Thank you very much.

xiaocong avatar Jul 27 '14 16:07 xiaocong

I met the same problem ( -32002 error)

button=device(descriptionContains='answer')
if button.exists:
    button.click()

the button.exists test pass but the click does not

have you managed to answer an incoming call with uiautomator ? it seems to be the problem for me , anything else just works fine thanks for your great job.

cocoon-project avatar Jul 28 '14 16:07 cocoon-project

You can dump the XML using dump() function to check what all are elements available in the screen if element is not found

siva-kranthi avatar Jul 29 '14 16:07 siva-kranthi

@cocoon-project Could you dump the screen and attach it on the comment. Thank you.

xiaocong avatar Aug 05 '14 08:08 xiaocong

他不是很稳定,随机的就会报这个错误,我做了一个改写,如果报这个错的时候,就再去找,这样改减低了发生的几率,但是仍然会发生。 @xiaocong 能有一劳永逸的修改方式么?我的case跑挂了现在最大的问题就是这个。

exctype is <class 'autotest.utils.uiautomator.JsonRPCError'>

exc value is JsonRPC Error code: -32002, Message: UiSelector[RESOURCE_ID=com.android.camera2:id/recording_time]

C:\Users\yongga1x\Documents\OTCAuto\OTCTest\autotest\base\OTCTest.py line: 190 in run

testMethod()

C:\Users\yongga1x\Documents\OTCAuto\OTCTest\autotest\case\video\VideoPlayBackLongTime.py line: 62 in runTest

status,message = camera_impl.capture_video_camera_initial_page(self.data.get("waittime"))

C:\Users\yongga1x\Documents\OTCAuto\OTCTest\autotest\action\CameraAction.py line: 426 in capture_video_camera_initial_page

text = self.d(resourceId="com.android.camera2:id/recording_time").text.split(":")

C:\Users\yongga1x\Documents\OTCAuto\OTCTest\autotest\utils\uiautomator.py line: 868 in getattr

info = self.info

C:\Users\yongga1x\Documents\OTCAuto\OTCTest\autotest\utils\uiautomator.py line: 879 in info

return self.jsonrpc.objInfo(self.selector)

C:\Users\yongga1x\Documents\OTCAuto\OTCTest\autotest\utils\uiautomator.py line: 495 in wrapper

return _method_obj(_args, *_kwargs)

C:\Users\yongga1x\Documents\OTCAuto\OTCTest\autotest\utils\uiautomator.py line: 166 in call

raise JsonRPCError(jsonresult["error"]["code"], jsonresult["error"]["message"])

nostmabole avatar Aug 13 '14 05:08 nostmabole

@xiaocong 我也遇到的类型的问题,发现遇到这样的问题后,脚本已经报错停止了。但是在命令行里面执行:adb shell uiautomator runtest uiautomator-stub.jar bundle.jar -c com.github.uiautomatorstub.Stub
会出错,提示java.net.BindException: bind failed: EADDRINUSE (Address already in use),是否和这个有关呢?

完整的adb错误提示: C:\Users\xxx\Desktop>adb shell uiautomator runtest uiautomator-stub.jar bundle.jar -c com.github.uiautomatorstub. Stub INSTRUMENTATION_STATUS: current=1 INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner INSTRUMENTATION_STATUS: class=com.github.uiautomatorstub.Stub INSTRUMENTATION_STATUS: stream= com.github.uiautomatorstub.Stub: INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: test=testUIAutomatorStub INSTRUMENTATION_STATUS_CODE: 1 INSTRUMENTATION_STATUS: current=1 INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner INSTRUMENTATION_STATUS: class=com.github.uiautomatorstub.Stub INSTRUMENTATION_STATUS: stream= Error in testUIAutomatorStub: java.net.BindException: bind failed: EADDRINUSE (Address already in use) at libcore.io.IoBridge.bind(IoBridge.java:89) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:150) at java.net.ServerSocket.bind(ServerSocket.java:318) at java.net.ServerSocket.bind(ServerSocket.java:281) at fi.iki.elonen.NanoHTTPD.start(NanoHTTPD.java:155) at com.github.uiautomatorstub.Stub.setUp(Stub.java:27) at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:144) at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:87) at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:90) at com.android.commands.uiautomator.Launcher.main(Launcher.java:83) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243) at dalvik.system.NativeStart.main(Native Method) Caused by: libcore.io.ErrnoException: bind failed: EADDRINUSE (Address already in use) at libcore.io.Posix.bind(Native Method) at libcore.io.ForwardingOs.bind(ForwardingOs.java:40) at libcore.io.IoBridge.bind(IoBridge.java:87) ... 17 more

INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stack=java.net.BindException: bind failed: EADDRINUSE (Address already in use) at libcore.io.IoBridge.bind(IoBridge.java:89) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:150) at java.net.ServerSocket.bind(ServerSocket.java:318) at java.net.ServerSocket.bind(ServerSocket.java:281) at fi.iki.elonen.NanoHTTPD.start(NanoHTTPD.java:155) at com.github.uiautomatorstub.Stub.setUp(Stub.java:27) at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:144) at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:87) at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:90) at com.android.commands.uiautomator.Launcher.main(Launcher.java:83) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243) at dalvik.system.NativeStart.main(Native Method) Caused by: libcore.io.ErrnoException: bind failed: EADDRINUSE (Address already in use) at libcore.io.Posix.bind(Native Method) at libcore.io.ForwardingOs.bind(ForwardingOs.java:40) at libcore.io.IoBridge.bind(IoBridge.java:87) ... 17 more

INSTRUMENTATION_STATUS: test=testUIAutomatorStub INSTRUMENTATION_STATUS_CODE: -1 INSTRUMENTATION_STATUS: stream= Test results for WatcherResultPrinter=.E Time: 0.061

FAILURES!!! Tests run: 1, Failures: 0, Errors: 1

INSTRUMENTATION_STATUS_CODE: -1

C:\Users\xxx\Desktop>

hao1032 avatar Mar 10 '15 08:03 hao1032

@cocoon-project hi,Have you resolved the problem? i met the same question and i don't know how to resolve it

leaphan avatar Jan 19 '18 08:01 leaphan

I have run into this issue intermittently as well, where a UI element is indeed on the screen, but the find fails.

barneywilliams avatar Jan 19 '18 13:01 barneywilliams

@barneywilliams i can find the UI element,but can not click it

leaphan avatar Jan 22 '18 02:01 leaphan

Any update on this issue? Facing similar issue with Android N

AfreenShaha avatar Jun 25 '18 08:06 AfreenShaha

Any update on this issue? Facing similar issue with Android O

Joycetcl avatar Dec 24 '18 08:12 Joycetcl