Class: RFormUnit::Window

Inherits:
BaseControl show all
Defined in:
lib/rformunit/window.rb

Direct Known Subclasses

OpenFileDialog, SaveasFileDialog

Instance Attribute Summary collapse

Attributes inherited from BaseControl

#control_id, #parent_win

Instance Method Summary collapse

Methods inherited from BaseControl

#click, #is_enabled?, #is_visible?, #send_text, #set_text

Methods included from Driver

#close_window, #driver, #focus_window, #init, #key_press, #open_file_dialog, #set_autoit_option, #wait_and_focus_window, #wait_for_window, #window_exists?

Constructor Details

#initialize(title, text = '', timeout = 10) ⇒ Window

Returns a new instance of Window.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rformunit/window.rb', line 10

def initialize(title, text = '', timeout = 10)      
  # for some windows, the title might change depends when it is invoked
  if title.class == Array 
    title.each { |a_title| 
      @title = a_title
      @text = text if text        
      result = driver.WinWaitActive(@title, @text, timeout)
      return if result != 0
    }
    raise "timeout while waiting for window: #{self.to_s}" 
  end
  
  @title = title
  @text = text if text
  result = driver.WinWaitActive(@title, @text, timeout)
  raise "timeout while waiting for window: #{self.to_s}" if result == 0    
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



8
9
10
# File 'lib/rformunit/window.rb', line 8

def text
  @text
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/rformunit/window.rb', line 8

def title
  @title
end

Instance Method Details

#button(button_id) ⇒ Object

a list



94
95
96
# File 'lib/rformunit/window.rb', line 94

def button(button_id)
  RFormUnit::Button.new(self, button_id)
end

#click_button(btn_id) ⇒ Object



48
49
50
# File 'lib/rformunit/window.rb', line 48

def click_button(btn_id)
  Button.new(self, btn_id).click
end

#closeObject



32
33
34
# File 'lib/rformunit/window.rb', line 32

def close
  driver.WinClose(@title, @text)
end

#exists?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/rformunit/window.rb', line 36

def exists?
  driver.WinExists(@title, @text)
end

#focusObject



28
29
30
# File 'lib/rformunit/window.rb', line 28

def focus
  driver.WinActivate(@title, @text)
end

#focus_control(ctrl_id) ⇒ Object



64
65
66
# File 'lib/rformunit/window.rb', line 64

def focus_control(ctrl_id)
  BaseControl.new(self, ctrl_id).focus
end

#get_control_text(ctrl_id) ⇒ Object



72
73
74
# File 'lib/rformunit/window.rb', line 72

def get_control_text(ctrl_id)
  BaseControl.new(self, ctrl_id).get_text
end

#get_textObject



40
41
42
# File 'lib/rformunit/window.rb', line 40

def get_text
  driver.WinGetText(@title, @text)
end

#hide_dropdown(combo_id) ⇒ Object



58
59
60
61
62
# File 'lib/rformunit/window.rb', line 58

def hide_dropdown(combo_id)
  combo = ComboBox.new(self, combo_id)
  combo.hide_dropdown
  combo
end

#pixel_color(x, y) ⇒ Object Also known as: pixel_colour, get_pixel_colour, get_pixel_color



81
82
83
# File 'lib/rformunit/window.rb', line 81

def pixel_color(x,y)
  driver.PixelGetColor(x,y)
end

#send_control_text(ctrl_id, text) ⇒ Object



68
69
70
# File 'lib/rformunit/window.rb', line 68

def send_control_text(ctrl_id, text)
  BaseControl.new(self, ctrl_id).send_text(text)
end

#set_control_text(control_id, new_text) ⇒ Object



44
45
46
# File 'lib/rformunit/window.rb', line 44

def set_control_text(control_id, new_text)
  BaseControl.new(self, control_id).set_text(new_text)
end

#show_dropdown(combo_id) ⇒ Object



52
53
54
55
56
# File 'lib/rformunit/window.rb', line 52

def show_dropdown(combo_id)
  combo = ComboBox.new(self, combo_id)
  combo.show_dropdown
  combo
end

#statusbar_textObject

Not fully verified yet



77
78
79
# File 'lib/rformunit/window.rb', line 77

def statusbar_text
  driver.StatusbarGetText(@title)
end

#to_sObject



89
90
91
# File 'lib/rformunit/window.rb', line 89

def to_s
  "Window{title => '#{@title}', text=>'#{@text}'}"
end