You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

touch_action

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

touch_action

1.3.3
bundlerRubygems
Version published
Maintainers
1
Created
Source

TouchAction

Build Status Code Climate

Touch Action is a Ruby Gem used to add touch gestures simulation to the Watir-WebDriver, Selenium-WebDriver and Capybara in order to perform automated tests on (mobile and desktops) websites that requires those type of actions. It encapsulates the touch action library of YUI JS. Very useful for example when testing mobile websites using Appium.

Installation

Add this line to your application's Gemfile:

gem 'touch_action'

And then execute:

$ bundle

And then add require 'touch_action' to your spec_helper.rb or wherever you want to use it.

Usage

On the element you want to perform the action, just call touch_action(:name_of_gesture). It currently supports Selenium, Watir-Webdriver and Capybara elements. Here's the example using a Watir element.

  element = @driver.div(:id, 'hit')
  element.touch_action(:swipe)

###Available Gestures

It's currently supporting the gestures bellow. The only required argument is the action symbol, the rest are optional (here it's showing the default options for each action).

  element.touch_action(:flick, axis: 'x', distance: 100,  duration: 50) #flick and swipe are the same 
  
  element.touch_action(:pinch, r1: 50, r2: 100)
  
  element.touch_action(:tap)
  
  element.touch_action(:doubletap)
  
  element.touch_action(:press,  hold: 2000)
  
  element.touch_action(:move, xdist: 70, ydist: -50,  duration: 500)
  
  element.touch_action(:rotate, {rotation: -75})
  

###Capybara and RSpec

To use it with Capybara and Rspec, just do the following:

    it "should tap using capybara", js: true do
        visit('http://mywebsite.com')
        touch_action '#myElement', :tap #it will also accept options here
    end

For more information about how those methods work, please check the YUI Documentation.

Contributing

  • Fork it ( https://github.com/[my-github-username]/touch_action/fork )
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create a new Pull Request

FAQs

Package last updated on 24 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts