Method: Selenium::WebDriver::PointerActions#click

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

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

Clicks in the middle of the given element. Equivalent to:

driver.action.move_to(element).click

When no element is passed, the current mouse position will be clicked.

Examples:

Clicking on an element


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

Clicking at the current mouse position


driver.action.click.perform

Parameters:

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

    An optional element to click.

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

    optional name of the PointerInput device with the button that will be clicked

Returns:



226
227
228
229
230
231
# File 'lib/selenium/webdriver/common/interactions/pointer_actions.rb', line 226

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