Android mobile gestures in Sauce Labs not working with Ruby

Mobile gestures don’t appear to work on Sauce Labs with ruby/appium_lib libraries. I can perform the gestures fine locally on both a real android device or emulator. I contacted SL support and they too were unable to perform a mobile gesture on their platform using ruby/appium_lib. The error they received was “Trying to relay to Se2: <type ‘exceptions.TypeError’> pop() takes at most 1 argument (2 given)”. The support agent was, however able to perform a mobile gesture using a Python script.

I even tried to POST the gesture directly to the selenium API on SL but the action times out just as the appium_lib method (below) does. Below are the two methods I’ve tried and were unsuccessful. I’d appreciate any feedback or help on this as I’m unable to use Sauce Labs for a good portion of my regression tests. Thanks.

http longPress post:
SeleniumAPI.post("/session/c1af81ed-cb21-4e21-8536-372581dfd1d7/touch/perform", body: [{ action:“longPress”, options:{x: 153, y: 338, duration:2000 }},{ action: “release” }].to_json)

appium_lib long_press:
Appium::TouchAction.new.long_press(x: 153, y: 338, :fingers => 1, :duration => 2000).release.perform

What desired capabilities are you using? I suspect that the appium-version cap is not set correctly.

Thanks for the reply! I’m using 1.2.1 appium version but I’ve also tried using 1.2.2 and 1.2.3 in SL but get the same results. Below are the caps I’m using to connect to SL. Definitely appreciate the help or feedback. thanks.

    caps: {
      server_url:          "http://#{$sauce_user}:#{$sauce_key}@ondemand.saucelabs.com:80/wd/hub",
      :'appium-version' => "1.2.1",
      platformName:        "Android",
      platformVersion:     "4.4",
      deviceName:          "Android Emulator",
      app:                 "sauce-storage:myapp.apk",
      appWaitActivity:     "my-activity", 
      deviceType:          "phone"   
    },
    appium_lib: {
      wait: 300
    }
  }

That’s strange. Your caps look correct. I’ve opened an issue.

https://github.com/appium/ruby_lib/issues/283

We’re working on a new CI setup so that Sauce Labs specific problems are detected. I’m not sure why it would work locally and fail on Sauce.

I’m currently not able to use Sauce Labs either due to bugs. Hopefully a future version of appium will fix this.

Ok. So I finally was able to do a long_press gesture on SL. I had to format the POST I was using to mimic what the python library does. Not sure what they do is correct or not but I can wrap this POST into a method and use as a work around until it’s fixed in appium (or wherever the issue may lie). Thanks for the help!

ruby_lib does: (doesn’t work in SL)
json_body: [{ action:“longPress”, options:{x: 153, y: 338, duration:2000 }},{ action: “release” }].to_json)

python does: (works in SL)
json_body:{ actions:[{action:“longPress”,options:{x: 153, y: 338, duration: 2000}}] }.to_json)

Did you try this Ruby?

 Appium::TouchAction.new.long_press(x: 153, y: 338, duration: 2000).perform

It uses the following JSON

[{"action":"longPress","options":{"x":153,"y":338,"duration":2000}}]

Yeah, that doesn’t work either. Looks like it wont work unless the body has “actions:[{action:“longPress”…” Def strange it works locally fine.

I’m having some very similar issues. Swipe works perfectly fine for me locally, but fails to execute at all on SauceLabs.

Has there been any update to this?

I think this pull request will fix the problem:

The next Ruby binding release will include it.