xiaocong / uiautomator

Python wrapper of Android uiautomator test tool.
MIT License
2.04k stars 644 forks source link

I can see '\u200e' being added to the beginning and the end of the text I am looking for using textMatches . #294

Open ancan-netizen opened 4 years ago

ancan-netizen commented 4 years ago

I want to connect to a bluetooth device, there are 2 devices with similar name. The names are abc123 and deabc123. I would like to connect with abc123, so I would like to give textMatches to abc123, if I do so I get the bellow error

Traceback (most recent call last): File "", line 1, in File "C:\Users\Desktop\handset\uiautomator__init.py", line 80, in call return self.func(*args, **kwargs) File "C:\Users\Desktop\handset\uiautomator__init__.py", line 883, in _click return self.jsonrpc.click(self.selector) File "C:\Users\Desktop\handset\uiautomator\init.py", line 355, in wrapper return _method_obj(*args, **kwargs) File "C:\Users\Desktop\handset\uiautomator\init.py", line 140, in call__ "%s: %s" % (jsonresult["error"]["data"], jsonresult["error"]["message"]) uiautomator.JsonRPCError: JsonRPC Error code: -32002, Message: {'exceptionTypeName': 'android.support.test.uiautomator.UiObjectNotFoundException', 'message': 'UiSelector[CLASS=android.widget.TextView, TEXT_REGEX=abc123, RESOURCE_ID=android:id/title]'}: UiSelector[CLASS=android.widget.TextView, TEXT_REGEX=abc123, RESOURCE_ID=android:id/title]

and if I use textContains it matches with the device which appears first on the page, so sometimes with abc123 and other times with deabc123

JSON call: {'jsonrpc': '2.0', 'method': 'getText', 'id': 'd529221e5f66c0037e0f5f8d13435a68', 'params': ({'mask': 2097170, 'childOrSibling': [], 'childOrSiblingSelector': [], 'textContains': 'abc123', 'className': 'android.widget.TextView', 'resourceId': 'android:id/title'},)} JSON result: {'jsonrpc': '2.0', 'id': 'd529221e5f66c0037e0f5f8d13435a68', 'result': '\u200deabc123\u200e'}

Kindly help with this. Thanking in advance

hongbinbao commented 3 years ago

what's your android SDK version?