dtmilano / AndroidViewClient

Android ViewServer and ADB client
Apache License 2.0
1.63k stars 347 forks source link

xml parsing error #58

Open imiten opened 11 years ago

imiten commented 11 years ago

Hi,

I have been getting xml parsing error (like ExpatError) causing my app to crash. whats the solution ? I found http://code.google.com/p/android/issues/detail?id=35915 is that the reason ?

ERROR: Offending XML: u'ERROR: null root node returned by UiTestAutomationBridge.\r\n'

I am using latest code AndroidViewClient-6cd170e65a8869fd9d5915a984342aa3b8937ce7

Regards,

Miten.

dtmilano commented 11 years ago

It's an UiAutomator error. Instead of returning a valid XML containing the View dump it returns the error message:

'ERROR: null root node returned by UiTestAutomationBridge.\r\n'

Not an AndroidViewClient issue.

imiten commented 11 years ago

I assume its android sdk issue.  Does the link to issue on google forum i provided is correct reference to this prob.  How to avoid this any hint?

Sent from Yahoo! Mail on Android

dtmilano commented 11 years ago

This is probably closer: http://stackoverflow.com/questions/16929129/null-root-node-returned-by-uitestautomationbridge-by-uiautomator

On Mon, Oct 7, 2013 at 12:11 PM, imiten notifications@github.com wrote:

I assume its android sdk issue. Does the link to issue on google forum i provided is correct reference to this prob. How to avoid this any hint?

Sent from Yahoo! Mail on Android

— Reply to this email directly or view it on GitHubhttps://github.com/dtmilano/AndroidViewClient/issues/58#issuecomment-25821966 .

Have you read my blog ? http://dtmilano.blogspot.com android junit tests ui linux cult thin clients

imiten commented 11 years ago

What exception should i catch to identify this issue around dump call other than Exception? I tried ExpatError but it is getting caught.

Sent from Yahoo! Mail on Android

imiten commented 11 years ago

my issue looks similar to your suggestion. it started happening just two days back but surprisingly it affects emulator and any device and not specific to single device and now its so frequent that I started attempting things like try catch and timings/sleeps to see if it could resolve. I think I would also need to do factory reset.

dtmilano commented 11 years ago

This is where you are getting the Expat exception:

        try:
            parserStatus =
parser.Parse(uiautomatorxml.encode(encoding='utf-8', errors='replace'),
True)
        except xml.parsers.expat.ExpatError, ex:
            print >>sys.stderr, "ERROR: Offending XML:\n",
repr(uiautomatorxml)
            raise RuntimeError(ex)

and AndroidViewClient is wrapping it in a RuntimeError() which is the one you can trap.

On Mon, Oct 7, 2013 at 1:16 PM, imiten notifications@github.com wrote:

my issue looks similar to your suggestion. it started happening just two days back and now its so frequent that I started attempting things like try catch and timings/sleeps to see if it could resolve. I think I would also need to do factory reset.

— Reply to this email directly or view it on GitHubhttps://github.com/dtmilano/AndroidViewClient/issues/58#issuecomment-25827110 .

Have you read my blog ? http://dtmilano.blogspot.com android junit tests ui linux cult thin clients

imiten commented 11 years ago

Thank you.  its been able to act as workaround for unexpected null root node from uiautomator.


From: Diego Torres Milano notifications@github.com To: dtmilano/AndroidViewClient AndroidViewClient@noreply.github.com Cc: imiten imiten@yahoo.com Sent: Monday, October 7, 2013 11:13 PM Subject: Re: [AndroidViewClient] xml parsing error (#58)

This is where you are getting the Expat exception:

try: 
parserStatus = 
parser.Parse(uiautomatorxml.encode(encoding='utf-8', errors='replace'), 
True) 
except xml.parsers.expat.ExpatError, ex: 
print >>sys.stderr, "ERROR: Offending XML:\n", 
repr(uiautomatorxml) 
raise RuntimeError(ex) 

and AndroidViewClient is wrapping it in a RuntimeError() which is the one you can trap.

On Mon, Oct 7, 2013 at 1:16 PM, imiten notifications@github.com wrote:

my issue looks similar to your suggestion. it started happening just two days back and now its so frequent that I started attempting things like try catch and timings/sleeps to see if it could resolve. I think I would also need to do factory reset.

— Reply to this email directly or view it on GitHubhttps://github.com/dtmilano/AndroidViewClient/issues/58#issuecomment-25827110 .

Have you read my blog ? http://dtmilano.blogspot.com android junit tests ui linux cult thin clients — Reply to this email directly or view it on GitHub.

knorrium commented 11 years ago

@imiten would you mind sharing what you've done?

Sometimes I fall into the same problem but haven't been able to investigate it further.

imiten commented 11 years ago

Hi knorrium,

I did not notice your question so apologize for delayed reply.

Below is my snippet.

while vc.findViewWithText(u"Logging in\u2026 please wait"): try: vc.dump(window='-1', sleep=2) except RuntimeError as rex:

print >>sys.stderr, "caught RuntimeError login 2"

    vc.dump(window='-1', sleep=10)
  print "Logging in... please wait"
  sys.stdout.flush()

Hi dtmilano,

is there way you can suppress this error you printing and just pass up in RuntimeError so user can determine whether to show in logs.

Regards,

miten.