Class: Webdrone::Ctxt
- Inherits:
-
Object
- Object
- Webdrone::Ctxt
- Defined in:
- lib/webdrone/ctxt.rb
Instance Attribute Summary collapse
-
#a0 ⇒ Object
Returns the value of attribute a0.
-
#current_frame ⇒ Object
Returns the value of attribute current_frame.
Instance Method Summary collapse
- #close_tab ⇒ Object
- #create_tab ⇒ Object
- #ignore_alert ⇒ Object
-
#initialize(a0) ⇒ Ctxt
constructor
A new instance of Ctxt.
- #reset ⇒ Object
- #with_alert ⇒ Object
- #with_frame(name) ⇒ Object
Constructor Details
#initialize(a0) ⇒ Ctxt
Returns a new instance of Ctxt.
11 12 13 14 |
# File 'lib/webdrone/ctxt.rb', line 11 def initialize(a0) @a0 = a0 @framestack = [] end |
Instance Attribute Details
#a0 ⇒ Object
Returns the value of attribute a0.
9 10 11 |
# File 'lib/webdrone/ctxt.rb', line 9 def a0 @a0 end |
#current_frame ⇒ Object
Returns the value of attribute current_frame.
9 10 11 |
# File 'lib/webdrone/ctxt.rb', line 9 def current_frame @current_frame end |
Instance Method Details
#close_tab ⇒ Object
23 24 25 26 27 28 |
# File 'lib/webdrone/ctxt.rb', line 23 def close_tab @a0.driver.close @a0.driver.switch_to.window @a0.driver.window_handles.last rescue => exception Webdrone.report_error(@a0, exception, Kernel.caller_locations) end |
#create_tab ⇒ Object
16 17 18 19 20 21 |
# File 'lib/webdrone/ctxt.rb', line 16 def create_tab @a0.exec.script "function a0_ctx_create_tab() { var w = window.open(); w.document.open(); w.document.write('A0 CTXT CREATE TAB'); w.document.close(); } a0_ctx_create_tab();" @a0.driver.switch_to.window @a0.driver.window_handles.last rescue => exception Webdrone.report_error(@a0, exception, Kernel.caller_locations) end |
#ignore_alert ⇒ Object
62 63 64 65 66 |
# File 'lib/webdrone/ctxt.rb', line 62 def ignore_alert @a0.exec.script 'alert = function(message){return true;};' rescue => exception Webdrone.report_error(@a0, exception, Kernel.caller_locations) end |
#reset ⇒ Object
47 48 49 50 51 52 |
# File 'lib/webdrone/ctxt.rb', line 47 def reset @a0.driver.switch_to.default_content @ramestack = [] rescue => exception Webdrone.report_error(@a0, exception, Kernel.caller_locations) end |
#with_alert ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/webdrone/ctxt.rb', line 54 def with_alert @a0.wait.for do yield @a0.driver.switch_to.alert end rescue => exception Webdrone.report_error(@a0, exception, Kernel.caller_locations) end |
#with_frame(name) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/webdrone/ctxt.rb', line 30 def with_frame(name) @framestack << name @a0.driver.switch_to.frame name if block_given? begin yield ensure @framestack.pop @a0.driver.switch_to.default_content @framestack.each { |frame| @a0.driver.switch_to.frame frame} end end name rescue => exception Webdrone.report_error(@a0, exception, Kernel.caller_locations) end |