-
-
Notifications
You must be signed in to change notification settings - Fork 155
Description
Describe the bug
I'm using Ferrum via Cuprite and Capybara to test what happens when a HTML form submit button is double clicked on.
However, the behaviour that Ferrum does for Node#click(mode: double) doesn't seem to be treated by the submit button in the same way a human double clicking would, instead it is seen as a single click.
To Reproduce
The following simple web app and browser automation script demonstrate the problem:
# click_count_server.rb
require 'sinatra'
globals = { click_count: 0 }
get '/' do
globals[:click_count] = 0
<<~HTML
<form method="post">
<button id="clickCount">Click</button>
</form>
HTML
end
post '/' do
globals[:click_count] += 1
sleep 0.1
<<~HTML
<form method="post">
<button id="clickCount">Click count: #{globals[:click_count]}</button>
</form>
HTML
end
require 'ferrum'
browser = Ferrum::Browser.new
browser.go_to('http://localhost:4567')
browser.at_css('button#clickCount').click(mode: double)
Node#click(mode: double) on a submit button results in the button being clicked once when double click with a mouse by a human would result in the button being clicked twice.
Expected behavior
I would expect Node#click(mode: double) to result in two clicks being registered by the submit button.
Screenshots
Kapture.2025-03-28.at.14.41.19.mp4
Desktop (please complete the following information):
- OS: macOS
- Browser [Chrome Version 134.0.6998.166 (Official Build) (arm64)]
- Version [v 0.15]
Additional context
I think the problem may be in
Lines 76 to 79 in b727708
| when :double | |
| page.mouse.move(x: x, y: y) | |
| page.mouse.down(modifiers: modifiers, count: 2) | |
| page.mouse.up(modifiers: modifiers, count: 2) |
I would expect each mouse.down to be followed by a mouse.up before the next mouse.down, but it looks like instead what happens is two mouse.down events followed by two mouse.up events.