Skip to content

Double click doesn't actually double click #529

Closed

Description

@lfdebrux

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

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.

Activity

  1. lfdebrux commented on Mar 28, 2025

    @lfdebrux
    Author

    After a little experimenting, I found I could get the behaviour I expected with

    def double_click(node)
      x, y = node.find_position
      mouse = node.page.mouse
      mouse.move(x:, y:)
      mouse.down
      mouse.up
      sleep(0.05)
      mouse.down
      mouse.up
    end
    
  2. route commented on May 10, 2025

    @route
    Member

    This is incorrect example, it's 2 single clicks with sleep between them rather than double click.
    There's a test for double click #533
    There's no mistake here in count: 2 this is how double click is sent using CDP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions