Can't make a tap on Android device, with ruby

Hello,
I’ve found here that I can use some “touch action” from the appium library.
http://www.rubydoc.info/github/appium/ruby_lib/Appium/TouchAction
I’ve tried “tap” but I’ve got error

my code :

@driver_appium = Appium::Driver.new(capabilities)
@driver = @driver_appium.start_driver
@browser = Watir::Browser.new @driver
@browser.driver.manage.timeouts.implicit_wait = 30

 @op = {
opts: {
'x' => 0.5,
'y' => 0.5,
'fingers' => 1
}}
@driver_appium.tap(@op)

and I have
wrong number of arguments (1 for 0) (ArgumentError)

I’ve tryed to “press” or “long_press” but for that I’ve got
undefined method `press’ for #Appium::Driver:0x007fabb9c45768 (NoMethodError)

So what happen ? Do I have a problem with my lib ? I’ve install all this 3 weeks ago with last version of everything…
Thanks a lot

and I add that when I do
@driver_appium.tap()
(because it told me that number of arg is 0 so I try that…)
I have the error
“no block given (LocalJumpError)”

The code needs to be something like this:

TouchAction.new.tap(x: 50, y:5, count: 3).release

Thanks,
Appium::TouchAction.new.tap( x: 500, y:300, count: 3).release.perform
was ok for me !

Ok, I still have an issue on this.
When I using this:
Appium::TouchAction.new.tap( x: 500, y:300, count: 3).release.perform
in my app, it’s ok I can click where I want.
But when I’m using the same command on Chrome, I have an error
unexpected response, code=404, content-type=“text/plain”
unknown command: session/993c02201fa11528df9de3d9e3ba8998/touch/perform (Selenium::WebDriver::Error::WebDriverError)

Do you know how can I do a tap on Chrome ?
Thanks a lot

The problem is the web context doesn’t know about touch actions. I thought this was fixed in appium though. You could open an issue and ask why touch actions are failing in the web context.

If you’re testing a mobile website, you can use this Ruby gem to perform it: https://github.com/Ricardonacif/touch_action

Thanks, looks good !
Right now I’m using a context change
@driver.set_context(‘NATIVE_APP’)
and then
Appium::TouchAction…

or a script like that, without context changing
@browser.execute_script ‘mobile: tap’, x: element_x_middle, y: element_y_middle

I will try your gem !

Great @Ericzered, let me know if it worked!

Thanks for the answer, below works with 1.6.4-beta as well in arc mode

Appium::TouchAction.new.tap( x:100, y:100, count: 3).release.perform