How to doubleclick in Selenium

When removing the w3c option from Selenium, this workaround was deprecated. The working Monkeypacth would be session.driver.browser.action.double_click(self.native).perform, but Capybara Elements nowadays support the double_click method natively, so the Monkeypatch can be removed entirely!

Put the attached file into features/support/.

Example usage:

When /^I open the task named "(.+?)"$/ do |task_name|
  task = page.all('.task').detect do |t|
    t.find('.label').text.downcase == task_name.downcase
  end
  
  task.double_click
end

Note: only Selenium understands doubleclicks.\
Credits: the attached Capybara issue discussion.

Dominik Schöler About 10 years ago