Code given in Ruby for swipe gesture trows error

Hello,
After recording the steps for a simple onboarding with swipe gesture in AN device, the code in Ruby throws me an error when I tried to run it in Visual Code.

def test_OnBoarding_DANSwipe
    @driver.swipe 852, 1465, 0, 1468, 355
    @driver.swipe 852, 1465, 0, 1468, 355
    @driver.find_element(:xpath, "//*[@id='iconNext']").click
    @driver.find_element(:xpath, "//*[@id='permission_allow_button']").click
end

ArgumentError: wrong number of arguments (given 5, expected 1)

I am really new with the programming language and in general with programming so I am not sure what is failing and why.

Also tried a different approach modifying the steps on AppiumStudio and got a different error when running the code that AppiumStudio provided me:

def test_OnBoardingANtest
@driver.execute_script(“seetest:client.elementSwipe(“xpath=//[@id=‘viewPager’]", “Right”, 2000)")
@driver.execute_script("seetest:client.elementSwipe("xpath=//
[@id=‘viewPager’]”, “Right”, 2000)”)
@driver.find_element(:xpath, “//[@id=‘iconNext’]").click
@driver.find_element(:xpath, "//
[@id=‘permission_allow_button’]”).click
end

Selenium::WebDriver::Error::JavascriptError: javascript error (javascript error. Could not find a method ‘elementSwipe’ matching with 3 parameters)

I would appreciate your help as I don’t understand if I am missing some library or if I need to modify the code somehow.

So was the elementSwipe code generated in Appium Studio ?

Element swipe actually takes more parameters

See - https://docs.experitest.com/display/TE/SeeTest+Client++-+ElementSwipe

Yes it was generated by AppiumStudio for the selection of the step in the action options:
FindElement and Swipe(Element, Direction, Time)
Swipe the screen in a given direction

  • Element - Select Element
  • Direction - Direction to swipe
  • Time - Swipe overall time

Is there some example of it for Ruby? I see all the other supported languages but Ruby.

Are you sure its ElementSwipe ? what happens if you use

def test_Untitled
@driver.execute_script(“seetest:client.swipe(”", 0, 500)")
end

I get generated code as seetest:client.swipe rather than @driver.swipe 852, 1465, 0, 1468, 355 in Ruby code

This is what i am doing and what i am getting from Appium Studio

I am recording the swipe gesture in the computer (twice), with the mouse in the mirror open device and what Appium studio returns to me in code is on the second image.

I will come back to you after discussing as i think there is a problem with generated Ruby code related to Swipe

1 Like

Thank you very much!