What is the preferred Ruby way to swipe on screen for Android Selendroid automation?

Hi all,

The swipe method I was using for Android API >= 18 via :uiautomator was working fine until I attempted to use this in Android API 16. The reason being is because I need to use Selendroid based methods it seems. The only issue with this is that when I use the below function it works but it mentions it is deprecated.

element_to_begin_swipe_on = find_element(:id, "some_id")
driver.touch.flick(element_to_begin_swipe_on, 0, -327, :normal).perform

2017-07-18 14:04:02 WARN Selenium [DEPRECATION] Driver#mouse is deprecated with w3c implementation. Instead use driver.action.<command>.perform

2017-07-18 14:04:02 WARN Selenium [DEPRECATION] Driver#keyboard is deprecated with w3c implementation. Instead use driver.action.<command>.perform

I’ve tried to switch the method to using driver.action.flick but this yields an error mentioning that the method is undefined (perhaps I’m doing this wrong):

[762] pry(main)> driver.action.flick
NoMethodError: undefined method `flick’ for #Selenium::WebDriver::ActionBuilder:0x007fcf19a79280
Did you mean? click
from (pry):376:in __pry __

I’m wondering two things when it comes to writing tests on Selendroid based APIs:

  1. Should I continue to use the driver.touch.flick method for APIs below 18 (which it doesn’t work for API 10) or will it be removed eventually? Not sure what method replaces it, would be helpful if someone could post a working swipe method for Selendroid automation in Ruby as I’m concerned I will use the flick method and then down-the-road be screwed.

  2. Why does the Appium::TouchAction.new.swipe method return an appium server response status of 404 undefined? I feel this should be working even for older API versions but it is not. The below code is what returns a 404 status:

[316] pry(main)> Appium::TouchAction.new.swipe(start_x: 144, start_y: 1634, end_x: 144, end_y: 149, duration: 1000).perform
Selenium::WebDriver::Error::UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: 404 - undefined
from /usr/local/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok’

I tried multiple variations of the swipe method (x and y coordinates, along with removing or adding the duration param) and all of them return a 404.

Capabilities I’m using:

[caps]
platformName = “Android”
platformVersion = “4.1”
automationName = “Selendroid”
deviceName = “Android 4.1 Emulator”
app = “…/…/app-debug.apk”
avd = “Nexus_5X_API_16”
avdArgs = “-no-boot-anim”
rotatable = true
orientation = “PORTRAIT”

Ruby:

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

Appium:

appium 1.6.5

Appium Gem Versions:

appium_console (2.3.0)
appium_lib (9.4.9)