calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

Cannot query text inside UIScrollView #1315

Closed patrick-silvera closed 7 years ago

patrick-silvera commented 7 years ago

Hello, I'm trying to search for text inside an UIScrollView. Storyboard hierarchy is:

View
----UIScrollView
--------UILabel
----FooterView

Calabash tree command returns this

[UIWindow] 
  [UILayoutContainerView]   
    [UINavigationTransitionView]     
      [UIViewControllerWrapperView]       
        [UIView] [id:intro_eula]         
          [UIScrollView]           
          [FooterView] 

Queries for id/text/mark of the UILabel returns an empty array. On the other hand, other interaction like scrolling does work.

Environment: calabash-ios 0.20.5 ruby 2.3.0 iOS 10.2.1

jmoody commented 7 years ago

Can you show a picture?

Have you tried:

query("all * marked:'your mark'")
patrick-silvera commented 7 years ago

Thanks it works with this query, I did not know about the "all" keyword. Is this the expected behavior? Here is a screenshot of the storyboard: storyboard

jmoody commented 7 years ago

Is this the expected behavior?

Maybe. Calabash use a heuristic to determine what is "visible". In general, the rule is that the middle of the view must be visible. The middle of the view might not be visible for several reasons:

  1. The middle point is off the screen.
  2. The middle point is behind another view.

We added the "all" keyword to handle cases like yours: view is visible to a human, but the heuristic is failing.

UIScrollView and its subclasses are special cases in the LPServer - you might have bumped into on of these special cases. I would have to investigate to tell you exactly what is happening.

patrick-silvera commented 7 years ago

You're right, the middle point of the UILabel is not visible because in my case the text is very long (term of use) and there's a lot of scroll. When I reduce the text size, so there's still some scroll but the middle point is visible without scrolling, query without "all" keyword works.

I'm OK with your workaround, I let you close this issue or leave it open if you want to investigate.