@@ -620,58 +620,61 @@ def getViewContainingPointAndTouch(self, x, y):
620620 v = self .findViewContainingPointInTargets (x , y )
621621
622622 if v is None :
623- # FIXME: We can touch by DIP by default if no Views were found
624623 self .hideVignette ()
625- msg = "There are no touchable or clickable views here!"
624+ msg = "There are no explicitly touchable or clickable views here! Touching with [x,y] "
626625 self .toast (msg )
627- return
628- elif self .vc .uiAutomatorHelper :
629- # These operations are only available through uiAutomatorHelper
630- if v == self .vc .navBack :
631- self .pressBack ()
632- return
633- elif v == self .vc .navHome :
634- self .pressHome ()
635- return
636- elif v == self .vc .navRecentApps :
637- self .pressRecentApps ()
638- return
639-
640- clazz = v .getClass ()
641- if clazz == 'android.widget.EditText' :
642- title = "EditText"
643- kwargs = {}
644- if DEBUG :
645- print >> sys .stderr , v
646- if v .isPassword ():
647- title = "Password"
648- kwargs = {'show' : '*' }
649- text = tkSimpleDialog .askstring (title , "Enter text to type into this field" , ** kwargs )
650- self .canvas .focus_set ()
651- if text :
652- self .vc .setText (v , text )
653- else :
654- self .hideVignette ()
655- return
626+ # A partial hack which temporarily toggles touch point
627+ self .toggleTouchPoint ()
628+ self .touchPoint (x , y )
629+ self .toggleTouchPoint ()
656630 else :
657- candidates = [v ]
658-
659- def findBestCandidate (view ):
660- isccf = Culebron .isClickableCheckableOrFocusable (view )
661- cd = view .getContentDescription ()
662- text = view .getText ()
663- if (cd or text ) and not isccf :
664- # because isccf==False this view was not added to the list of targets
665- # (i.e. Settings)
666- candidates .insert (0 , view )
667- return None
668-
669- if not (v .getText () or v .getContentDescription ()) and v .getChildren ():
670- self .vc .traverse (root = v , transform = findBestCandidate , stream = None )
671- if len (candidates ) > 2 :
672- warnings .warn ("We are in trouble, we have more than one candidate to touch" , stacklevel = 0 )
673- candidate = candidates [0 ]
674- self .touchView (candidate , v if candidate != v else None )
631+ if self .vc .uiAutomatorHelper :
632+ # These operations are only available through uiAutomatorHelper
633+ if v == self .vc .navBack :
634+ self .pressBack ()
635+ return
636+ elif v == self .vc .navHome :
637+ self .pressHome ()
638+ return
639+ elif v == self .vc .navRecentApps :
640+ self .pressRecentApps ()
641+ return
642+
643+ clazz = v .getClass ()
644+ if clazz == 'android.widget.EditText' :
645+ title = "EditText"
646+ kwargs = {}
647+ if DEBUG :
648+ print >> sys .stderr , v
649+ if v .isPassword ():
650+ title = "Password"
651+ kwargs = {'show' : '*' }
652+ text = tkSimpleDialog .askstring (title , "Enter text to type into this field" , ** kwargs )
653+ self .canvas .focus_set ()
654+ if text :
655+ self .vc .setText (v , text )
656+ else :
657+ self .hideVignette ()
658+ return
659+ else :
660+ candidates = [v ]
661+
662+ def findBestCandidate (view ):
663+ isccf = Culebron .isClickableCheckableOrFocusable (view )
664+ cd = view .getContentDescription ()
665+ text = view .getText ()
666+ if (cd or text ) and not isccf :
667+ # because isccf==False this view was not added to the list of targets
668+ # (i.e. Settings)
669+ candidates .insert (0 , view )
670+ return None
671+
672+ if not (v .getText () or v .getContentDescription ()) and v .getChildren ():
673+ self .vc .traverse (root = v , transform = findBestCandidate , stream = None )
674+ if len (candidates ) > 2 :
675+ warnings .warn ("We are in trouble, we have more than one candidate to touch" , stacklevel = 0 )
676+ candidate = candidates [0 ]
677+ self .touchView (candidate , v if candidate != v else None )
675678
676679 self .printOperation (None , Operation .SLEEP , Operation .DEFAULT )
677680 self .vc .sleep (5 )
0 commit comments