Method: Selenium::WebDriver::PointerActions#click_and_hold

Defined in:
lib/selenium/webdriver/common/interactions/pointer_actions.rb

#click_and_hold(element = nil, button: nil, device: nil) ⇒ ActionBuilder

Clicks (without releasing) in the middle of the given element. This is equivalent to:

driver.action.move_to(element).click_and_hold

Examples:

Clicking and holding on some element


el = driver.find_element(id: "some_id")
driver.action.click_and_hold(el).perform

Parameters:

  • element (Selenium::WebDriver::Element) (defaults to: nil)

    the element to move to and click.

  • device (Symbol || String) (defaults to: nil)

    optional name of the PointerInput device to click with

Returns:



180
181
182
183
184
# File 'lib/selenium/webdriver/common/interactions/pointer_actions.rb', line 180

def click_and_hold(element = nil, button: nil, device: nil)
  move_to(element, device: device) if element
  pointer_down(button || :left, device: device)
  self
end