Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

API proposal/discussion for touch platform interactions #803

Closed
carhartl opened this Issue · 11 comments

7 participants

@carhartl

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
https://github.com/jonleighton/poltergeist/pull/135/files

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

Element#single_tap

e.g.

find('.tap-me').single_tap

@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:

single_tap
double_tap
long_tap
swipe_left
swipe_right
swipe_up
swipe_down

(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]

@jnicklas
Owner

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

@carhartl

Cool! So would I add these methods as follows?

# Capybara::Driver::Node
def single_tap
  raise NotSupportedByDriverError
end
# Capybara::Node::Element
def single_tap
  synchronize { base.single_tap }
end
@jnicklas
Owner

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.

@carhartl

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.

@jnicklas
Owner

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.

@MITDelian

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

@jnicklas
Owner

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

@glaksmono

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
@twalpole
Collaborator

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.

@twalpole
Collaborator

Closing this as discussion should move over to pr #1289

@twalpole twalpole closed this
@Ricardonacif

Hey, there's this gem I have developed that adds touch gestures support to Capybara. Take a look at https://github.com/Ricardonacif/touch_action .

Thanks,

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.