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

def initialize(a0)
  @a0 = a0
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



20
21
22
23
# File 'lib/webdrone/ctxt.rb', line 20

def close_tab
  @a0.driver.close
  @a0.driver.switch_to.window @a0.driver.window_handles.last
end

#create_tab ⇒ Object



15
16
17
18
# File 'lib/webdrone/ctxt.rb', line 15

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



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

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

#with_alert ⇒ Object



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

def with_alert
  @a0.wait.for do
    yield @a0.driver.switch_to.alert
  end
end

#with_frame(name) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/webdrone/ctxt.rb', line 25

def with_frame(name)
  old_frame = @current_frame
  @a0.driver.switch_to.frame name
  @current_frame = name
  if block_given?
    yield
    @a0.driver.switch_to.parent_frame
    @current_frame = old_frame
  end
  @current_frame
end