Swipe perform not working Appium 1.3.5

Our swipe action is defined as:

def swipe(start_x, start_y, end_x, end_y)
  action = Appium::TouchAction.new.press(x: start_x, y: start_y).wait(10).move_to(x: end_x, y:  end_y).wait(50).  release(x: end_x, x: end_y)

When calling swipe, it gets stuck and I have to force quit. This is the stack trace

   end of file reached
 # /Users/kusi/.rvm/gems/ruby-2.1.5/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'
 # /Users/kusi/.rvm/gems/ruby-2.1.5/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
 # /Users/kusi/.rvm/gems/ruby-2.1.5/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
 # /Users/kusi/.rvm/gems/ruby-2.1.5/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/bridge.rb:640:in `raw_execute'
 # /Users/kusi/.rvm/gems/ruby-2.1.5/gems/selenium-webdriver-2.45.0/lib/selenium/webdriver/remote/bridge.rb:618:in `execute'
 # /Users/kusi/.rvm/gems/ruby-2.1.5/gems/appium_lib-5.0.1/lib/appium_lib/device/device.rb:355:in `touch_actions'
 # /Users/kusi/.rvm/gems/ruby-2.1.5/gems/appium_lib-5.0.1/lib/appium_lib/device/touch_actions.rb:120:in `perform'
 # /Users/kusi/.rvm/gems/ruby-2.1.5/gems/appium-android-4.0.47/lib/appium_android/screen.rb:60:in `swipe'

Any reason why this could be failing?


Has probably nothing to do, but I think your function should be

def swipe(start_x, start_y, end_x, end_y)
    action = Appium::TouchAction.new.press(x: start_x, y: start_y).wait(1000).move_to(x: end_x, y:  end_y).release()

Have you tried to run swipe on console (arc)?

Thanks, that works!
I’ll post here again if there are any more problems with this

Can u give the same swipe in Java Code …

Its almost exactly the same. Just replace for java methods, p.e. move_to is moveTo in java and so on…

So I added this function, but how do I call it? It isn’t working for me. I have it setup as:

def swipe(start_x, start_y, end_x, end_y):
action = TouchAction.new.press(start_x, start_y).wait(1000).move_to(end_x, end_y).release()

and I call it in my test case as:

Swipe 205 500 206 800

You have arc installed? If yes go for it and run this first:

Appium::TouchAction.new.press(x: 205, y: 500).wait(1000).move_to(x: 206, y:  800).release().perform

Are you sure you have correct coordinates?

What is arc? Do I need it? I am using Appium & Python for my tests…

Actually I am now trying this:

def swipe(self, start_x, start_y, end_x, end_y, duration):
action = TouchAction(self)
.press(x=start_x, y=start_y)
.move_to(x=end_x, y=end_y)
return self

And I am calling it by:

Swipe 200 200 200 400 1000

But it is still not working. However, I feel like I am closer now then with what I was doing before. I hope you can help!