Class: Webdrone::Ctxt
- Inherits:
-
Object
- Object
- Webdrone::Ctxt
- Defined in:
- lib/webdrone/ctxt.rb,
lib/webdrone/logg.rb
Instance Attribute Summary collapse
-
#a0 ⇒ Object
readonly
Returns the value of attribute a0.
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_conf(new_config) ⇒ Object
- #with_frame(name) ⇒ Object
Constructor Details
#initialize(a0) ⇒ Ctxt
Returns a new instance of Ctxt.
13 14 15 16 |
# File 'lib/webdrone/ctxt.rb', line 13 def initialize(a0) @a0 = a0 @framestack = [] end |
Instance Attribute Details
#a0 ⇒ Object (readonly)
Returns the value of attribute a0.
11 12 13 |
# File 'lib/webdrone/ctxt.rb', line 11 def a0 @a0 end |
Instance Method Details
#close_tab ⇒ Object
25 26 27 28 29 30 |
# File 'lib/webdrone/ctxt.rb', line 25 def close_tab @a0.driver.close @a0.driver.switch_to.window @a0.driver.window_handles.last rescue StandardError => error Webdrone.report_error(@a0, error) end |
#create_tab ⇒ Object
18 19 20 21 22 23 |
# File 'lib/webdrone/ctxt.rb', line 18 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 StandardError => error Webdrone.report_error(@a0, error) end |
#ignore_alert ⇒ Object
64 65 66 67 68 |
# File 'lib/webdrone/ctxt.rb', line 64 def ignore_alert @a0.exec.script 'alert = function(message){return true;};' rescue StandardError => error Webdrone.report_error(@a0, error) end |
#reset ⇒ Object
49 50 51 52 53 54 |
# File 'lib/webdrone/ctxt.rb', line 49 def reset @a0.driver.switch_to.default_content @framestack = [] rescue StandardError => error Webdrone.report_error(@a0, error) end |
#with_alert ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/webdrone/ctxt.rb', line 56 def with_alert @a0.wait.for do yield @a0.driver.switch_to.alert end rescue StandardError => error Webdrone.report_error(@a0, error) end |
#with_conf(new_config) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/webdrone/ctxt.rb', line 70 def with_conf(new_config) current_config = {} new_config.each do |k, v| current_config[k] = @a0.conf.send k @a0.conf.send "#{k}=", v end yield rescue StandardError => error Webdrone.report_error(@a0, error) ensure current_config.each do |k, v| @a0.conf.send "#{k}=", v end end |
#with_frame(name) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/webdrone/ctxt.rb', line 32 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 StandardError => error Webdrone.report_error(@a0, error) end |