Skip to content

BrowserModule::Interaction

jfinkhaeuser edited this page Dec 17, 2014 · 1 revision

BrowserModule::Interaction

The module provides interaction helpers with the web page.

Clicking

Various browsers at times react differently to using Watir to click an element. Sometimes, the distinction is important - but sometimes it is more important that the element receives a click, no matter what.

The module provides a few simple abstractions for clicking by various methods:

  • elem.click - the basic Watir functionality
  • browser.on_click(elem) - fires an onClick event in the browser instead of using Watir's approach
  • browser.js_click(elem) - clicks the element by injecting JavaScript into the page.
  • browser.click_type(type, elem) - uses the given type to click the element. The type may be one of :method (Watir's functionality), :event or :js.
  • browser.click_types(elem, [types]) - same as click_type, but uses all types provided in the optional second parameter, until one succeeds. If all fail, the function raises an error. The default is to try :method, then :event, then :js.
  • browser.force_click(elem1[, elem1, ...]) - uses the default click types on all the passed elements.