Module: Celerity::ClickableElement

Included in:
Image, InputElement, Label, Link, NonControlElement, Option, Table, TableCell, TableElement, TableRow
Defined in:
lib/celerity/clickable_element.rb,
lib/celerity/watir_compatibility.rb

Instance Method Summary collapse

Instance Method Details

#clickObject Also known as: click_no_wait

click the element



8
9
10
11
# File 'lib/celerity/clickable_element.rb', line 8

def click
  assert_exists_and_enabled
  rescue_status_code_exception { @container.update_page(@object.click) }
end

#click_and_attachCelerity::Browser

Click the element and return a new Browser instance with the resulting page. This is useful for elements that trigger popups when clicked.

Returns:



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/celerity/clickable_element.rb', line 38

def click_and_attach
  assert_exists_and_enabled
  browser = Browser.new(@browser.options.dup)
  browser.webclient.set_cookie_manager(
    @browser.webclient.get_cookie_manager
  ) # hirobumi: we do want cookies as well.

  rescue_status_code_exception { browser.update_page(@object.click) }

  browser
end

#double_clickObject

double click the element (Celerity only)



17
18
19
20
# File 'lib/celerity/clickable_element.rb', line 17

def double_click
  assert_exists_and_enabled
  rescue_status_code_exception { @container.update_page(@object.dblClick) }
end

#downloadIO

Click the element and just return the content as IO. Current page stays unchanged. This can be used to download content that normally isn’t rendered in a browser.

Returns:

  • (IO)


57
58
59
60
# File 'lib/celerity/clickable_element.rb', line 57

def download
  assert_exists_and_enabled
  @object.click.getWebResponse.getContentAsStream.to_io
end

#right_clickObject

right click the element (Celerity only)



26
27
28
29
# File 'lib/celerity/clickable_element.rb', line 26

def right_click
  assert_exists_and_enabled
  rescue_status_code_exception { @container.update_page(@object.rightClick) }
end