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
-
#click ⇒ Object
(also: #click_no_wait)
click the element.
-
#click_and_attach ⇒ Celerity::Browser
Click the element and return a new Browser instance with the resulting page.
-
#double_click ⇒ Object
double click the element (Celerity only).
-
#download ⇒ IO
Click the element and just return the content as IO.
-
#right_click ⇒ Object
right click the element (Celerity only).
Instance Method Details
#click ⇒ Object Also known as: click_no_wait
click the element
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/celerity/clickable_element.rb', line 8 def click assert_exists_and_enabled # There is an issue when javascript exceptions is turned # on and Celerity tries to click on a object inside of # an iframe. htmlUnit raises a ScriptException when invoking # jsxFunction_close, then celerity raises a NativeException. # # The clicking action never takes place, so our automated tests # cannot continue. # # Remember the javascript exception setting, turn it off, # click the object, and restore the setting. setting = @browser.javascript_exceptions @browser.javascript_exceptions = false rescue_status_code_exception { @object.click } @browser.javascript_exceptions = setting end |
#click_and_attach ⇒ Celerity::Browser
Click the element and return a new Browser instance with the resulting page. This is useful for elements that trigger popups when clicked.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/celerity/clickable_element.rb', line 52 def click_and_attach assert_exists_and_enabled browser = Browser.new(@browser..dup) browser.webclient.( @browser.webclient. ) # hirobumi: we do want cookies as well. @browser.disable_event_listener do rescue_status_code_exception { browser.page = @object.click } end browser end |
#double_click ⇒ Object
double click the element (Celerity only)
31 32 33 34 |
# File 'lib/celerity/clickable_element.rb', line 31 def double_click assert_exists_and_enabled rescue_status_code_exception { @object.dblClick } end |
#download ⇒ IO
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.
73 74 75 76 77 78 |
# File 'lib/celerity/clickable_element.rb', line 73 def download assert_exists_and_enabled @browser.disable_event_listener do @object.click.getWebResponse.getContentAsStream.to_io end end |
#right_click ⇒ Object
right click the element (Celerity only)
40 41 42 43 |
# File 'lib/celerity/clickable_element.rb', line 40 def right_click assert_exists_and_enabled rescue_status_code_exception { @object.rightClick } end |