calabash / calabash-ios

Calabash for iOS
Other
1.81k stars 369 forks source link

Testing on iOS 10 - waiting and touching elements animating in doesn't work accurately #1298

Closed gbrhaz closed 7 years ago

gbrhaz commented 7 years ago

run_loop: 2.4.1 calabash-cucumber: 0.20.5

I've noticed recently that when you call wait_for_elements_exist and then touch on an element that is animating in, the touch call will try and touch while the animation is progressing. Most of the time this fails, because by the time it's touched the element it seems to have moved on (pure conjecture)?

Is there a solid way with Calabash to "wait" for the animation to complete without invoking sleep? I like to try and keep out as many sleeps as I can because I feel it's hacky. Another solution I came up with is to create a loop, check if the element exists, and then tap on it... and iterate through the loop until the element no longer exists. But because of the animations, Calabash could be tapping on the element multiple times.


Loop solution:

wait_for_elements_exist(element)

    while query(element).any?
      wait_for_elements_exist(element)
      touch(element)
    end
jmoody commented 7 years ago

Use wait_for_none_animating or an explicit 0.4 sleep before the gesture.

This is a classic problem - the view is visible, but it not ready for gestures.

suchikaashyap commented 7 years ago

@gbrhaz we found this issue after the upgrade as well and we changed our methods to use wait_tap instead of the wait and touch combination that you have. It seems to be reliably working for us.

jmoody commented 7 years ago
      def wait_tap(uiquery, options={})
        wait_for_none_animating
        wait_for_element_exists(uiquery, options)
        touch(uiquery, options)
      end