Closed Marc--Olivier closed 3 years ago
@Marc--Olivier good catch! Thanks for your contribution.
uiautomator dump
is a source of surprises and problems. I would encourage the use of CulebraTester2-public as an alternative backend for AndroidViewClient/culebra.
Let me know if you need any help.
@dtmilano Many thanks for having merged this pull request!
I also noticed that uiautomator dump
was not always working smoothly... Many thanks for the link to https://github.com/dtmilano/CulebraTester2-public, I tried it out, but having to install an alternative back-end was not an option for what I was doing. Still, I am sure I will use this new back-end in a relatively near feature. So many thanks for providing it!
My script uses
AndroidViewClient
but cannot create aViewClient
The script returns the following stack trace:
When I execute the command
adb shell uiautomator dump
on my device a Pocophone X3 with MIUI 12 installed, I get the following result:So
uiautomator
throws an error, but still succeeds to dump the XML. The constructor ofViewClient
callsparser.Parse(receivedXml[start_xml_index:end_xml_index + 1])
Ln 3323, but the XML contained inreceived
cannot be parsed because it still contains parts of the exceptions:start_xml_index = receivedXml.index("<")
will return the first index of '<', which is in the exception (java.io.FileInputStream.<init>
).We fixed the issue by filtering out the exception from the
received
variable Ln 3461:But it would probably be cleaner to replace the value of
start_xml_index = receivedXml.index("<")
withstart_xml_index = receivedXml.index("<?xml")
.@dtmilano What do you think? Would you be interested by a pull request?
Note that this error is similar to two issues in the
scrcpy
project:These issues were fixed by just ignoring the exceptions (see https://github.com/Genymobile/scrcpy/commit/96bd2c974d0fb9765dc4d2978688bb0bbd65cc9f).