Class: Webdrone::Ctxt

Inherits:
Object
  • Object
show all
Defined in:
lib/webdrone/ctxt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#a0Object

Returns the value of attribute a0.



9
10
11
# File 'lib/webdrone/ctxt.rb', line 9

def a0
  @a0
end

#current_frameObject

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_tabObject



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_tabObject



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_alertObject



44
45
46
# File 'lib/webdrone/ctxt.rb', line 44

def ignore_alert
  @a0.exec.script 'alert = function(message){return true;};'
end

#with_alertObject



38
39
40
41
42
# File 'lib/webdrone/ctxt.rb', line 38

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
# File 'lib/webdrone/ctxt.rb', line 26

def with_frame(name)
  @framestack << name      
  @a0.driver.switch_to.frame name
  if block_given?
    yield
    @framestack.pop
    @a0.driver.switch_to.default_content
    @framestack.each { |frame| @a0.driver.switch_to.frame frame}
  end
  name
end