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 { @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
49
50
# 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.

  @browser.disable_event_listener do
    rescue_status_code_exception { browser.page = @object.click }
  end

  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 { @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)

59
60
61
62
63
64
# File 'lib/celerity/clickable_element.rb', line 59

def download
  assert_exists_and_enabled
  @browser.disable_event_listener do
    @object.click.getWebResponse.getContentAsStream.to_io
  end
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 { @object.rightClick }
end