rautomation 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +30 -24
- data/History.rdoc +10 -0
- data/VERSION +1 -1
- data/ext/UiaDll/UiaDll.suo +0 -0
- data/ext/UiaDll/UiaDll/UiaDll.cpp +19 -0
- data/ext/WindowsForms/bin/WindowsForms.exe +0 -0
- data/ext/WindowsForms/src/WindowsForms/WindowsForms/MainFormWindow.Designer.cs +10 -5
- data/lib/rautomation/adapter/autoit/window.rb +3 -1
- data/lib/rautomation/adapter/ms_uia.rb +1 -0
- data/lib/rautomation/adapter/ms_uia/checkbox.rb +6 -2
- data/lib/rautomation/adapter/ms_uia/control.rb +2 -2
- data/lib/rautomation/adapter/ms_uia/keys.rb +121 -0
- data/lib/rautomation/adapter/ms_uia/radio.rb +4 -0
- data/lib/rautomation/adapter/ms_uia/uia_dll.rb +2 -0
- data/lib/rautomation/adapter/ms_uia/window.rb +28 -16
- data/lib/rautomation/adapter/win_32.rb +1 -0
- data/lib/rautomation/adapter/win_32/password_field.rb +15 -0
- data/lib/rautomation/adapter/win_32/text_field.rb +13 -3
- data/lib/rautomation/adapter/win_32/window.rb +7 -0
- data/rautomation.gemspec +3 -0
- data/spec/adapter/ms_uia/button_spec.rb +5 -5
- data/spec/adapter/ms_uia/window_spec.rb +27 -1
- metadata +60 -6
data/Gemfile.lock
CHANGED
@@ -1,24 +1,30 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
rautomation (0.7.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rspec-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rautomation (0.7.2)
|
5
|
+
ffi
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.1.3)
|
11
|
+
ffi (1.0.11)
|
12
|
+
rake (0.9.2.2)
|
13
|
+
rspec (2.8.0)
|
14
|
+
rspec-core (~> 2.8.0)
|
15
|
+
rspec-expectations (~> 2.8.0)
|
16
|
+
rspec-mocks (~> 2.8.0)
|
17
|
+
rspec-core (2.8.0)
|
18
|
+
rspec-expectations (2.8.0)
|
19
|
+
diff-lcs (~> 1.1.2)
|
20
|
+
rspec-mocks (2.8.0)
|
21
|
+
yard (0.8.3)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
x86-mingw32
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
rake
|
28
|
+
rautomation!
|
29
|
+
rspec (~> 2.3)
|
30
|
+
yard
|
data/History.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.3
|
data/ext/UiaDll/UiaDll.suo
CHANGED
Binary file
|
@@ -349,6 +349,25 @@ extern "C" __declspec ( dllexport ) int RA_GetClassName(IUIAutomationElement *pE
|
|
349
349
|
}
|
350
350
|
}
|
351
351
|
|
352
|
+
extern "C" __declspec ( dllexport ) BOOL RA_GetIsSet(IUIAutomationElement *pElement) {
|
353
|
+
IToggleProvider *pTogglePattern ;
|
354
|
+
HRESULT hr = pElement->GetCurrentPattern(UIA_TogglePatternId, (IUnknown**)&pTogglePattern) ;
|
355
|
+
|
356
|
+
if (FAILED(hr)) {
|
357
|
+
printf("RA_GetIsSet: getCurrentPattern failed 0x%x\r\n") ;
|
358
|
+
return FALSE ;
|
359
|
+
}
|
360
|
+
|
361
|
+
ToggleState RetVal ;
|
362
|
+
hr = pTogglePattern->get_ToggleState(&RetVal) ;
|
363
|
+
if (FAILED(hr)) {
|
364
|
+
printf("RA_GetIsSet: get_ToggleState failed 0x%x\r\n", hr) ;
|
365
|
+
return FALSE ;
|
366
|
+
} else {
|
367
|
+
return RetVal ;
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
352
371
|
extern "C" __declspec ( dllexport ) BOOL RA_GetIsSelected(IUIAutomationElement *pElement) {
|
353
372
|
ISelectionItemProvider *pSelectionPattern ;
|
354
373
|
HRESULT hr = pElement->GetCurrentPattern(UIA_SelectionItemPatternId, (IUnknown**)&pSelectionPattern) ;
|
Binary file
|
@@ -96,9 +96,10 @@
|
|
96
96
|
// checkBox
|
97
97
|
//
|
98
98
|
this.checkBox.AutoSize = true;
|
99
|
+
this.checkBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
99
100
|
this.checkBox.Location = new System.Drawing.Point(142, 105);
|
100
101
|
this.checkBox.Name = "checkBox";
|
101
|
-
this.checkBox.Size = new System.Drawing.Size(
|
102
|
+
this.checkBox.Size = new System.Drawing.Size(80, 18);
|
102
103
|
this.checkBox.TabIndex = 6;
|
103
104
|
this.checkBox.Text = "checkBox";
|
104
105
|
this.checkBox.UseVisualStyleBackColor = true;
|
@@ -131,9 +132,10 @@
|
|
131
132
|
//
|
132
133
|
this.radioButtonDisabled.AutoSize = true;
|
133
134
|
this.radioButtonDisabled.Enabled = false;
|
135
|
+
this.radioButtonDisabled.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
134
136
|
this.radioButtonDisabled.Location = new System.Drawing.Point(188, 28);
|
135
137
|
this.radioButtonDisabled.Name = "radioButtonDisabled";
|
136
|
-
this.radioButtonDisabled.Size = new System.Drawing.Size(
|
138
|
+
this.radioButtonDisabled.Size = new System.Drawing.Size(106, 18);
|
137
139
|
this.radioButtonDisabled.TabIndex = 10;
|
138
140
|
this.radioButtonDisabled.TabStop = true;
|
139
141
|
this.radioButtonDisabled.Text = "Option Disabled";
|
@@ -161,9 +163,10 @@
|
|
161
163
|
// radioButton2
|
162
164
|
//
|
163
165
|
this.radioButton2.AutoSize = true;
|
166
|
+
this.radioButton2.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
164
167
|
this.radioButton2.Location = new System.Drawing.Point(107, 28);
|
165
168
|
this.radioButton2.Name = "radioButton2";
|
166
|
-
this.radioButton2.Size = new System.Drawing.Size(
|
169
|
+
this.radioButton2.Size = new System.Drawing.Size(71, 18);
|
167
170
|
this.radioButton2.TabIndex = 8;
|
168
171
|
this.radioButton2.TabStop = true;
|
169
172
|
this.radioButton2.Text = "Option 2";
|
@@ -173,9 +176,10 @@
|
|
173
176
|
// radioButton1
|
174
177
|
//
|
175
178
|
this.radioButton1.AutoSize = true;
|
179
|
+
this.radioButton1.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
176
180
|
this.radioButton1.Location = new System.Drawing.Point(9, 28);
|
177
181
|
this.radioButton1.Name = "radioButton1";
|
178
|
-
this.radioButton1.Size = new System.Drawing.Size(
|
182
|
+
this.radioButton1.Size = new System.Drawing.Size(71, 18);
|
179
183
|
this.radioButton1.TabIndex = 7;
|
180
184
|
this.radioButton1.TabStop = true;
|
181
185
|
this.radioButton1.Text = "Option 1";
|
@@ -287,9 +291,10 @@
|
|
287
291
|
//
|
288
292
|
this.checkBoxDisabled.AutoSize = true;
|
289
293
|
this.checkBoxDisabled.Enabled = false;
|
294
|
+
this.checkBoxDisabled.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
290
295
|
this.checkBoxDisabled.Location = new System.Drawing.Point(353, 102);
|
291
296
|
this.checkBoxDisabled.Name = "checkBoxDisabled";
|
292
|
-
this.checkBoxDisabled.Size = new System.Drawing.Size(
|
297
|
+
this.checkBoxDisabled.Size = new System.Drawing.Size(121, 18);
|
293
298
|
this.checkBoxDisabled.TabIndex = 12;
|
294
299
|
this.checkBoxDisabled.Text = "checkBoxDisabled";
|
295
300
|
this.checkBoxDisabled.UseVisualStyleBackColor = true;
|
@@ -16,7 +16,9 @@ module RAutomation
|
|
16
16
|
@@autoit = WIN32OLE.new('AutoItX3.Control')
|
17
17
|
rescue WIN32OLERuntimeError
|
18
18
|
dll = File.dirname(__FILE__) + "/../../../../ext/AutoItX/AutoItX3.dll"
|
19
|
-
system("regsvr32.exe /s #{dll.gsub('/', '\\')}")
|
19
|
+
unless system("regsvr32.exe /s #{dll.gsub('/', '\\')}")
|
20
|
+
raise "Start Ruby with administrative rights when using AutoIt adapter for the first time."
|
21
|
+
end
|
20
22
|
@@autoit = WIN32OLE.new('AutoItX3.Control')
|
21
23
|
end
|
22
24
|
end
|
@@ -5,6 +5,7 @@ rescue Gem::LoadError
|
|
5
5
|
end
|
6
6
|
require "ffi"
|
7
7
|
require File.dirname(__FILE__) + "/ms_uia/constants"
|
8
|
+
require File.dirname(__FILE__) + "/ms_uia/keys"
|
8
9
|
require File.dirname(__FILE__) + "/ms_uia/keystroke_converter"
|
9
10
|
require File.dirname(__FILE__) + "/ms_uia/functions"
|
10
11
|
require File.dirname(__FILE__) + "/ms_uia/locators"
|
@@ -7,11 +7,11 @@ module RAutomation
|
|
7
7
|
include ButtonHelper
|
8
8
|
|
9
9
|
def value
|
10
|
-
|
11
|
-
checkbox = UiaDll::element_from_handle(hwnd)
|
10
|
+
checkbox = uia_element
|
12
11
|
|
13
12
|
checkbox_value = FFI::MemoryPointer.new :char, UiaDll::get_name(checkbox, nil) + 1
|
14
13
|
UiaDll::get_name(checkbox, checkbox_value)
|
14
|
+
|
15
15
|
checkbox_value.read_string
|
16
16
|
end
|
17
17
|
|
@@ -19,6 +19,10 @@ module RAutomation
|
|
19
19
|
super && matches_type?(Constants::UIA_CHECKBOX_CONTROL_TYPE)
|
20
20
|
end
|
21
21
|
|
22
|
+
def set?
|
23
|
+
UiaDll::get_is_set(uia_element)
|
24
|
+
end
|
25
|
+
|
22
26
|
alias_method :exists?, :exist?
|
23
27
|
|
24
28
|
end
|
@@ -106,11 +106,11 @@ module RAutomation
|
|
106
106
|
end
|
107
107
|
|
108
108
|
#todo - replace with UIA version
|
109
|
-
def
|
109
|
+
def focused?
|
110
110
|
Functions.has_focus?(hwnd)
|
111
111
|
end
|
112
112
|
|
113
|
-
def
|
113
|
+
def focus
|
114
114
|
assert_enabled
|
115
115
|
uia_control = UiaDll::element_from_handle(hwnd)
|
116
116
|
UiaDll::set_focus(uia_control)
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module RAutomation
|
2
|
+
module Adapter
|
3
|
+
module MsUia
|
4
|
+
class Keys
|
5
|
+
KEYS = {
|
6
|
+
# keycodes from http://msdn.microsoft.com/en-us/library/ms927178.aspx
|
7
|
+
:null => 0x00,
|
8
|
+
:cancel => 0x03,
|
9
|
+
:help => 0x2F,
|
10
|
+
:backspace => 0x08,
|
11
|
+
:tab => 0x09,
|
12
|
+
:clear => 0x0C,
|
13
|
+
:return => 0x0D,
|
14
|
+
:enter => 0x0D,
|
15
|
+
:shift => 0x10,
|
16
|
+
:left_shift => 0xA0,
|
17
|
+
:control => 0x11,
|
18
|
+
:left_control => 0xA2,
|
19
|
+
:alt => 0x12,
|
20
|
+
:left_alt => 0xA4,
|
21
|
+
:pause => 0x13,
|
22
|
+
:escape => 0x1B,
|
23
|
+
:space => 0x20,
|
24
|
+
:page_up => 0x21,
|
25
|
+
:page_down => 0x22,
|
26
|
+
:end => 0x23,
|
27
|
+
:home => 0x24,
|
28
|
+
:left => 0x25,
|
29
|
+
:arrow_left => 0x25,
|
30
|
+
:up => 0x26,
|
31
|
+
:arrow_up => 0x26,
|
32
|
+
:right => 0x27,
|
33
|
+
:arrow_right => 0x27,
|
34
|
+
:down => 0x28,
|
35
|
+
:arrow_down => 0x28,
|
36
|
+
:insert => 0x2D,
|
37
|
+
:delete => 0x2E,
|
38
|
+
:semicolon => 0x3B,
|
39
|
+
:equals => 0x3D,
|
40
|
+
:numpad0 => 0x60,
|
41
|
+
:numpad1 => 0x61,
|
42
|
+
:numpad2 => 0x62,
|
43
|
+
:numpad3 => 0x63,
|
44
|
+
:numpad4 => 0x64,
|
45
|
+
:numpad5 => 0x65,
|
46
|
+
:numpad6 => 0x66,
|
47
|
+
:numpad7 => 0x67,
|
48
|
+
:numpad8 => 0x68,
|
49
|
+
:numpad9 => 0x69,
|
50
|
+
:multiply => 0x6A,
|
51
|
+
:add => 0x6B,
|
52
|
+
:separator => 0x6C,
|
53
|
+
:subtract => 0x6D,
|
54
|
+
:decimal => 0x6E,
|
55
|
+
:divide => 0x6F,
|
56
|
+
:f1 => 0x70,
|
57
|
+
:f2 => 0x71,
|
58
|
+
:f3 => 0x72,
|
59
|
+
:f4 => 0x73,
|
60
|
+
:f5 => 0x74,
|
61
|
+
:f6 => 0x75,
|
62
|
+
:f7 => 0x76,
|
63
|
+
:f8 => 0x77,
|
64
|
+
:f9 => 0x78,
|
65
|
+
:f10 => 0x79,
|
66
|
+
:f11 => 0x7A,
|
67
|
+
:f12 => 0x7B,
|
68
|
+
}
|
69
|
+
|
70
|
+
SPECIAL_KEYS = {
|
71
|
+
"!" => 0x31,
|
72
|
+
"@" => 0x32,
|
73
|
+
"#" => 0x33,
|
74
|
+
"$" => 0x34,
|
75
|
+
"%" => 0x35,
|
76
|
+
"^" => 0x36,
|
77
|
+
"&" => 0x37,
|
78
|
+
"*" => 0x38,
|
79
|
+
"(" => 0x39,
|
80
|
+
")" => 0x30,
|
81
|
+
"_" => 0x2D,
|
82
|
+
"+" => 0x3D,
|
83
|
+
"{" => 0x5B,
|
84
|
+
"}" => 0x5D,
|
85
|
+
":" => 0x3B,
|
86
|
+
"\"" => 0x27,
|
87
|
+
"|" => 0x5C,
|
88
|
+
"?" => 0x2F,
|
89
|
+
">" => 0x2E,
|
90
|
+
"<" => 0x2C
|
91
|
+
}
|
92
|
+
|
93
|
+
def self.[](key)
|
94
|
+
KEYS[key] or raise "unsupported key #{key.inspect}"
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.encode(keys)
|
98
|
+
keys.reduce([]) do |converted, key|
|
99
|
+
if key.is_a?(Symbol)
|
100
|
+
converted << Keys[key]
|
101
|
+
elsif key.is_a?(Array)
|
102
|
+
converted << (key.map {|k| encode([k])} << Keys[:null]).flatten
|
103
|
+
else # key is a string
|
104
|
+
converted += encode_str(key)
|
105
|
+
end
|
106
|
+
converted
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.encode_str(keys)
|
111
|
+
keys.to_s.split("").map do |key|
|
112
|
+
key =~ /[a-z]/ ? key.upcase.unpack("c")[0] :
|
113
|
+
key =~ /[A-Z]/ || SPECIAL_KEYS[key] ? [Keys[:shift], SPECIAL_KEYS[key] || key.unpack("c")[0], Keys[:null]] :
|
114
|
+
key.unpack("c")[0]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -48,6 +48,8 @@ module RAutomation
|
|
48
48
|
[:pointer, :pointer], :int
|
49
49
|
attach_function :get_is_selected, :RA_GetIsSelected,
|
50
50
|
[:pointer], :bool
|
51
|
+
attach_function :get_is_set, :RA_GetIsSet,
|
52
|
+
[:pointer], :bool
|
51
53
|
attach_function :select, :RA_Select,
|
52
54
|
[:pointer], :int
|
53
55
|
attach_function :set_value, :RA_Set_Value,
|
@@ -135,32 +135,35 @@ module RAutomation
|
|
135
135
|
sleep 1
|
136
136
|
end
|
137
137
|
|
138
|
-
#todo - replace with UIA version if possible
|
139
138
|
# Activates the window and sends keys to it.
|
140
139
|
#
|
141
|
-
#
|
140
|
+
# @example
|
141
|
+
# RAutomation::Window.new(:title => //).send_keys "hello!"
|
142
|
+
# RAutomation::Window.new(:title => //).send_keys [:control, "a"], "world!"
|
143
|
+
# Refer to {Keys::KEYS} for all the special keycodes.
|
142
144
|
# @see RAutomation::Window#send_keys
|
143
|
-
def send_keys(
|
144
|
-
|
145
|
-
KeystrokeConverter.convert(keys[0]).each do |key|
|
145
|
+
def send_keys(args)
|
146
|
+
Keys.encode(args).each do |arg|
|
146
147
|
wait_until do
|
147
148
|
activate
|
148
149
|
active?
|
149
150
|
end
|
150
|
-
press_key key
|
151
|
-
|
152
|
-
if key == Constants::VK_LSHIFT
|
153
|
-
shift_pressed = true
|
154
|
-
next
|
155
|
-
end
|
156
151
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
152
|
+
if arg.is_a?(Array)
|
153
|
+
arg.reduce([]) do |pressed_keys, k|
|
154
|
+
if k == Keys[:null]
|
155
|
+
pressed_keys.each {|pressed_key| release_key pressed_key}
|
156
|
+
pressed_keys = []
|
157
|
+
else
|
158
|
+
pressed_keys << press_key(k)
|
159
|
+
end
|
160
|
+
pressed_keys
|
161
|
+
end
|
162
|
+
else
|
163
|
+
send_key arg
|
162
164
|
end
|
163
165
|
end
|
166
|
+
sleep 1
|
164
167
|
end
|
165
168
|
|
166
169
|
#todo - replace with UIA version
|
@@ -353,11 +356,20 @@ module RAutomation
|
|
353
356
|
|
354
357
|
def press_key key
|
355
358
|
Functions.send_key(key, 0, 0, nil)
|
359
|
+
key
|
356
360
|
end
|
357
361
|
|
358
362
|
def release_key key
|
359
363
|
Functions.send_key(key, 0, Constants::KEYEVENTF_KEYUP, nil)
|
364
|
+
key
|
360
365
|
end
|
366
|
+
|
367
|
+
def send_key key
|
368
|
+
press_key key
|
369
|
+
release_key key
|
370
|
+
key
|
371
|
+
end
|
372
|
+
|
361
373
|
end
|
362
374
|
end
|
363
375
|
end
|
@@ -10,7 +10,7 @@ module RAutomation
|
|
10
10
|
|
11
11
|
# @see RAutomation::TextField#set
|
12
12
|
def set(text)
|
13
|
-
|
13
|
+
assert_enabled
|
14
14
|
|
15
15
|
wait_until do
|
16
16
|
hwnd = Functions.control_hwnd(@window.hwnd, @locators)
|
@@ -18,13 +18,13 @@ module RAutomation
|
|
18
18
|
@window.active? &&
|
19
19
|
focus &&
|
20
20
|
Functions.set_control_text(hwnd, text) &&
|
21
|
-
|
21
|
+
set?(text)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
# @see RAutomation::TextField#clear
|
26
26
|
def clear
|
27
|
-
|
27
|
+
assert_enabled
|
28
28
|
set ""
|
29
29
|
end
|
30
30
|
|
@@ -36,6 +36,16 @@ module RAutomation
|
|
36
36
|
focus
|
37
37
|
@window.send_keys(keys)
|
38
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def set?(text)
|
43
|
+
value == text
|
44
|
+
end
|
45
|
+
|
46
|
+
def assert_enabled
|
47
|
+
raise "Cannot set value on a disabled text field" if disabled?
|
48
|
+
end
|
39
49
|
end
|
40
50
|
end
|
41
51
|
end
|
@@ -177,6 +177,8 @@ module RAutomation
|
|
177
177
|
Functions.close_window(hwnd)
|
178
178
|
end
|
179
179
|
|
180
|
+
# Retrieves the {Mouse} object for automating mouse movements and clicks
|
181
|
+
# @raise [UnknownWindowException] if the window doesn't exist.
|
180
182
|
def mouse
|
181
183
|
@container.wait_until_present
|
182
184
|
Mouse.new(self)
|
@@ -206,6 +208,11 @@ module RAutomation
|
|
206
208
|
Label.new(self, locator)
|
207
209
|
end
|
208
210
|
|
211
|
+
def password_field(locator)
|
212
|
+
@container.wait_until_present
|
213
|
+
PasswordField.new(self, locator)
|
214
|
+
end
|
215
|
+
|
209
216
|
def control(locator={})
|
210
217
|
@container.wait_until_present
|
211
218
|
Control.new(self, locator)
|
data/rautomation.gemspec
CHANGED
@@ -19,6 +19,9 @@ RAutomation provides:
|
|
19
19
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
+
s.add_runtime_dependency("ffi")
|
22
23
|
s.add_development_dependency("rspec", "~>2.3")
|
24
|
+
s.add_development_dependency("rake")
|
25
|
+
s.add_development_dependency("yard")
|
23
26
|
end
|
24
27
|
|
@@ -20,12 +20,12 @@ describe "MsUia::Button", :if => SpecHelper.adapter == :ms_uia do
|
|
20
20
|
window.button(:id => "disabledButton").should_not be_enabled
|
21
21
|
end
|
22
22
|
|
23
|
-
it "#
|
23
|
+
it "#focus" do
|
24
24
|
button = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).button(:id => "enabledButton")
|
25
|
-
button.should_not
|
25
|
+
button.should_not be_focused
|
26
26
|
|
27
|
-
button.
|
28
|
-
button.should
|
27
|
+
button.focus
|
28
|
+
button.should be_focused
|
29
29
|
end
|
30
30
|
|
31
31
|
it "cannot click disabled button" do
|
@@ -35,7 +35,7 @@ describe "MsUia::Button", :if => SpecHelper.adapter == :ms_uia do
|
|
35
35
|
|
36
36
|
it "cannot set focus to disabled button" do
|
37
37
|
window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
|
38
|
-
lambda { window.button(:id => "disabledButton").
|
38
|
+
lambda { window.button(:id => "disabledButton").focus }.should raise_error
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "MsUia::Window", :if => SpecHelper.adapter == :ms_uia do
|
4
|
+
let(:window) {RAutomation::Window.new(:title => /MainFormWindow/i)}
|
4
5
|
|
5
6
|
|
6
7
|
|
7
8
|
it "move and click" do
|
8
|
-
window = RAutomation::Window.new(:title => /MainFormWindow/i)
|
9
|
+
#window = RAutomation::Window.new(:title => /MainFormWindow/i)
|
9
10
|
window.maximize
|
10
11
|
window.move_mouse(62,46)
|
11
12
|
sleep 1
|
@@ -14,6 +15,31 @@ describe "MsUia::Window", :if => SpecHelper.adapter == :ms_uia do
|
|
14
15
|
|
15
16
|
end
|
16
17
|
|
18
|
+
context "#send_keys" do
|
19
|
+
it "send tab keystrokes to move focus between elements" do
|
20
|
+
window.button(:value => "&About").focus
|
21
|
+
window.button(:value => "&About").should be_focused
|
22
|
+
|
23
|
+
window.send_keys(:tab, :tab, :tab)
|
24
|
+
button = window.button(:value => "Close")
|
25
|
+
button.should exist
|
26
|
+
button.should be_focused
|
27
|
+
end
|
28
|
+
|
29
|
+
it "send arbitrary characters and control keys" do
|
30
|
+
text_field = window.text_field(:index => 1)
|
31
|
+
text_field.focus
|
32
|
+
window.send_keys "abc123ABChiHI!"
|
33
|
+
text_field.value.should == "abc123ABChiHI!"
|
34
|
+
|
35
|
+
window.send_keys :space, "X"
|
36
|
+
text_field.value.should == "abc123ABChiHI! X"
|
37
|
+
|
38
|
+
window.send_keys [:control, "a"], :backspace
|
39
|
+
text_field.value.should be_empty
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
17
43
|
=begin
|
18
44
|
it "control by focus" do
|
19
45
|
window = RAutomation::Window.new(:title => /MainFormWindow/i)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rautomation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ffi
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: rspec
|
16
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
19
35
|
- - ~>
|
@@ -21,7 +37,44 @@ dependencies:
|
|
21
37
|
version: '2.3'
|
22
38
|
type: :development
|
23
39
|
prerelease: false
|
24
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: yard
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
25
78
|
description: ! "RAutomation is a small and easy to use library for helping out to
|
26
79
|
automate windows and their controls\nfor automated testing.\n\nRAutomation provides:\n*
|
27
80
|
Easy to use and user-friendly API (inspired by Watir http://www.watir.com)\n* Cross-platform
|
@@ -107,7 +160,6 @@ files:
|
|
107
160
|
- ext/WindowsForms/src/WindowsForms/WindowsForms/SimpleElementsForm.cs
|
108
161
|
- ext/WindowsForms/src/WindowsForms/WindowsForms/SimpleElementsForm.resx
|
109
162
|
- ext/WindowsForms/src/WindowsForms/WindowsForms/WindowsForms.csproj
|
110
|
-
- ext/WindowsForms/src/WindowsForms/WindowsForms/bin/Release/WindowsForms.exe
|
111
163
|
- lib/rautomation.rb
|
112
164
|
- lib/rautomation/adapter/autoit.rb
|
113
165
|
- lib/rautomation/adapter/autoit/button.rb
|
@@ -123,6 +175,7 @@ files:
|
|
123
175
|
- lib/rautomation/adapter/ms_uia/constants.rb
|
124
176
|
- lib/rautomation/adapter/ms_uia/control.rb
|
125
177
|
- lib/rautomation/adapter/ms_uia/functions.rb
|
178
|
+
- lib/rautomation/adapter/ms_uia/keys.rb
|
126
179
|
- lib/rautomation/adapter/ms_uia/keystroke_converter.rb
|
127
180
|
- lib/rautomation/adapter/ms_uia/label.rb
|
128
181
|
- lib/rautomation/adapter/ms_uia/list_box.rb
|
@@ -146,6 +199,7 @@ files:
|
|
146
199
|
- lib/rautomation/adapter/win_32/list_box.rb
|
147
200
|
- lib/rautomation/adapter/win_32/locators.rb
|
148
201
|
- lib/rautomation/adapter/win_32/mouse.rb
|
202
|
+
- lib/rautomation/adapter/win_32/password_field.rb
|
149
203
|
- lib/rautomation/adapter/win_32/radio.rb
|
150
204
|
- lib/rautomation/adapter/win_32/select_list.rb
|
151
205
|
- lib/rautomation/adapter/win_32/table.rb
|
@@ -208,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
262
|
version: '0'
|
209
263
|
requirements: []
|
210
264
|
rubyforge_project:
|
211
|
-
rubygems_version: 1.8.
|
265
|
+
rubygems_version: 1.8.24
|
212
266
|
signing_key:
|
213
267
|
specification_version: 3
|
214
268
|
summary: Automate windows and their controls through user-friendly API with Ruby
|