Home > QA, Test Automation > Swipe and Drag – Calabash iOS and Android

Swipe and Drag – Calabash iOS and Android

Hi guys !!
I am writing examples of swipe and drag on mobile devices with calabash today. Some methods that you can use to test, these drags have the same action as the swipe. (If for some reason the swipe don’t work)
  def swipe_page_to_left
    performAction('swipe', 'left')

  def swipe_page_to_right
    performAction('swipe', 'right')

  def scroll_to_right
    performAction('drag', 90, 0, 50, 50, 50)

  def scroll_to_left
    performAction('drag', 0, 90, 50, 50, 50)

def scroll_to_up
   performAction('drag', 88, 80, 90, 90, 5)

 def scroll_to_down
    performAction('drag', 70, 10, 80, 0, 3)

Change to down, left or right:


If you have some question or suggest just write below !
Thank you 🙂
  1. aman
    September 22, 2014 at 11:58 am

    how would you scroll over a specific element for android?

    • September 22, 2014 at 1:18 pm

      Hi Aman,

      I used to use drag. But you need to know the position on the screen to use the same x and y.
      performAction(‘drag’, 90, 0, 50, 50, 50)
      performAction(‘swipe’, ‘left’)

      For IOS you can use:
      scroll(“element_query“, :right)
      swipe :left, {:’swipe-delta’ => {:horizontal => {:dx => 375, :dy => 0}}}

      and change the x, y and the direction that you want swipe.

      Let me know if it worked.

  2. Kapil
    June 23, 2015 at 1:04 pm

    Scrolling down with drag isn’t working for me. I need to pull down the application screen by more than half length of the device.

    • June 24, 2015 at 8:26 am

      Hi Kapil, did you try drag with a huge percentage of the page ? I know that swipe it won’t work for you either, should work with drag only.

  3. Rodrigo
    November 17, 2017 at 5:15 pm

    Hi Rafaela, do you know the syntax to select a strong swipe? Sometimes the default swipe is not enough.


    • Rodrigo
      November 17, 2017 at 5:16 pm

      for iOS

      • Rodrigo
        November 17, 2017 at 5:19 pm

        Already found the way. I leave an example:

        swipe(:left,:query => “SPWebView”,:force => :strong)

        Thanks for your tips!

      • November 24, 2017 at 12:26 pm

        Hi Rodrigo thanks for posting the answer once you found it ! Really appreciated that 🙂 Thank you !

  1. September 30, 2014 at 10:50 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: