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
21 22 23 24 |
# File 'lib/webdrone/ctxt.rb', line 21 def close_tab @a0.driver.close @a0.driver.switch_to.window @a0.driver.window_handles.last end |
#create_tab ⇒ Object
16 17 18 19 |
# 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 end |
#ignore_alert ⇒ Object
52 53 54 |
# File 'lib/webdrone/ctxt.rb', line 52 def ignore_alert @a0.exec.script 'alert = function(message){return true;};' end |
#reset ⇒ Object
41 42 43 44 |
# File 'lib/webdrone/ctxt.rb', line 41 def reset @a0.driver.switch_to.default_content @ramestack = [] end |
#with_alert ⇒ Object
46 47 48 49 50 |
# File 'lib/webdrone/ctxt.rb', line 46 def with_alert @a0.wait.for do yield @a0.driver.switch_to.alert end end |
#with_frame(name) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/webdrone/ctxt.rb', line 26 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 end |