python 2.7 - AndroidViewClient: How to check if "Id/Text/Image" exist before touch it? -


how can check if exist id/text before touch it?

i trying this:

# class=android.widget.imageview com_evernote___id_close = vc.findviewbyidorraise("com.evernote:id/close") if not com_evernote___id_close:    vc.sleep(1) else:    com_evernote___id_close.touch() 

after login on evernote. shows info. if exits want close if not script continue executing.

and when not exist shows error:

  file "/usr/local/lib/python2.7/dist-packages/androidviewclient-11.0.10-py2.7.egg/com/dtmilano/android/viewclient.py", line 3352, in findviewbyidorraise raise viewnotfoundexception("id", viewid, root) com.dtmilano.android.viewclient.viewnotfoundexception: couldn't find view id='com.evernote:id/close' in tree root=root 

if don't want raise exception if view not found use viewclient.findviewbyid() instead of viewclient.findviewbyidorraise(). check if returned values not none. simple!


Comments

Popular posts from this blog

multithreading - Exception in Application constructor -

React Native allow user to reorder elements in a scrollview list -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -