twalpole / apparition

Capybara driver for Chrome using CDP
MIT License
363 stars 46 forks source link

Feature request: add a "speed" option for click() #44

Closed Ecco closed 4 years ago

Ecco commented 4 years ago

Hi there!

I don't know if this feature request should go into Capybara or Apparition, but here goes.

I'm testing a webpage which is sensitive to the speed at which a button is clicked. Weird, I know, but well, it's kinda simple actually : we just listen for "mouseup" and "mousedown" events, and act accordingly.

It would be awesome if we could do something like:

find("button").click(speed: 0.5)

and this would yield a 0.5 second pause between down and up in Capybara::Apparition::Mouse#click_at 😄

Ecco commented 4 years ago

FWIF, I've found a workaround by abusing drag_to, which has a customizable delay. Here goes:

button = find("button")
button.drag_to(button, delay: 0.5)

It's a bit weird though, and since drag_to has a delay, maybe it'd make sense to add one to click too?

twalpole commented 4 years ago

This should be proposed for Capybara rather than for a specific driver, and if doing it for click it should also potentially be looked at for double_click, although I'm not really sure how that would actually work.

Ecco commented 4 years ago

Sure! Here goes: teamcapybara/capybara#2324

twalpole commented 4 years ago

Implemented in apparition via 9346705d656a1ab87371b1f340a120033c4fb4c6