Skip to content


Subversion checkout URL

You can clone with
Download ZIP


API proposal/discussion for touch platform interactions #803

carhartl opened this Issue · 11 comments

7 participants


Little bit of background: For a touch platform only web app we're building we're using Capybara for acceptance tests, along with a js driver that is touch capable (now poltergeist, before capybara-webkit - basically any recent webkit based driver supporting touch events could be used). We're not using any click interactions at all, thus I needed to make the capybara js driver touch capable.

Here's a pull request I sent to poltergeist

which contains an initial implementation, so far only for simple, single taps:




@jonleighton in response asked me to start a discussion here as to (hopefully) agree on an API that could be implemented by any capable driver. See teampoltergeist/poltergeist#141

I had further methods in mind to be implement later, just as a proposal:


(The names follow what Zepto.js provides for touch event abstractions.) There are also gesture events I didn't yet think about.

I'd be glad if we could get a discussion going about this and happily help with the implementation whenever required.

[Edit: swipe_bottom -> swipe_down]


It sounds reasonable enough to me. The method names are descriptive and fit their purpose. I'm for it!


Cool! So would I add these methods as follows?

# Capybara::Driver::Node
def single_tap
  raise NotSupportedByDriverError
# Capybara::Node::Element
def single_tap
  synchronize { base.single_tap }

Yes exactly. It would make sense to add tests for them as well. This might be a bit tricky, obviously since none of the drivers in Capybara itself support it.


I am thinking: For Node make sure that the expected exceptions get thrown, for Element set a message expectation on base. But I'll see what's there as well.


The ideal solution, imo would be to have tests for the actual implementation in the Capybara suite. Selenium and RackTest could exclude those tests from their own suites.


Did this ever get made? I'd be interested in contributing to Capybara to help create this API


@MITDelian unfortunately, no. If you'd like to help, that'd be great.


This would be very helpful :+1:

@abotalov abotalov modified the milestone: Capybara 2.3, Capybara 2.2
@abotalov abotalov removed this from the Capybara 2.3 milestone

I've started implementation of a touch api in pr #1289 - currently there are 4 methods single_tap, double_tap, long_press, flick (based on element specific touch methods selenium webdriver provides) -- I'm not sure what useful parameters to flick should be, so feedback is definitely welcome, as are suggestions for any other methods we should have. Please add suggestions/comments over in #1289. I've also added testing of them against android via saucelabs, won't work here yet due to the secure env vars being set for my repo but I'll get them fixed up at some point.


Closing this as discussion should move over to pr #1289

@twalpole twalpole closed this

Hey, there's this gem I have developed that adds touch gestures support to Capybara. Take a look at .


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.