Module: RFormUnit::Driver

Included in:
BaseControl, FormTestCase, Keyboard, Mouse, Process
Defined in:
lib/rformunit/driver.rb

Instance Method Summary collapse

Instance Method Details

#close_window(title) ⇒ Object



45
46
47
# File 'lib/rformunit/driver.rb', line 45

def close_window(title)
  driver.WinClose(title)
end

#driverObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rformunit/driver.rb', line 10

def driver
  return @a3 if @a3

  @a3 = WIN32OLE.new('AutoItX3.Control')

  @a3.AutoItSetOption("CaretCoordMode", 0);
  @a3.AutoItSetOption("ColorMode", 1);
  @a3.AutoItSetOption("MouseCoordMode", 0);
  @a3.AutoItSetOption("PixelCoordMode", 0);
  @a3.AutoItSetOption("SendKeyDelay", 15)
  return @a3
end

#focus_window(title) ⇒ Object



41
42
43
# File 'lib/rformunit/driver.rb', line 41

def focus_window(title)
  driver.WinActivate(title)
end

#initObject



6
7
8
# File 'lib/rformunit/driver.rb', line 6

def init
  driver
end

#key_press(keys) ⇒ Object Also known as: press_key

wrapper of keyboard operations



50
51
52
53
# File 'lib/rformunit/driver.rb', line 50

def key_press(keys)
  filtered_keys = keys.gsub("Alt+", "!+").gsub("Ctrl+", "^+")
  RFormUnit::Keyboard.press(filtered_keys)
end

#open_file_dialog(title, filepath) ⇒ Object

standard open file dialog



57
58
59
60
61
62
63
# File 'lib/rformunit/driver.rb', line 57

def open_file_dialog(title, filepath)
  wait_and_focus_window(title)
  dialog = RFormUnit::OpenFileDialog.new(title)
  dialog.enter_filepath(filepath)
  sleep 1
  dialog.click_open
end

#set_autoit_option(key, value) ⇒ Object



23
24
25
26
# File 'lib/rformunit/driver.rb', line 23

def set_autoit_option(key, value)
  init if @a3.nil?
  @a3.AutoItSetOption(key, value)
end

#wait_and_focus_window(title, text = "", timeout = 30) ⇒ Object



33
34
35
# File 'lib/rformunit/driver.rb', line 33

def wait_and_focus_window(title, text="",  timeout=30)
  driver.WinWaitActive(title, text, timeout * 1000)
end

#wait_for_window(win, timeout = 30) ⇒ Object



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

def wait_for_window(win, timeout=30)
  driver.WinWait(win.title, win.text, timeout * 1000)
  win
end

#window_exists?(title) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rformunit/driver.rb', line 37

def window_exists?(title)
  driver.WinExists(title)  >  0
end