rautomation 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +34 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +24 -0
- data/History.rdoc +21 -0
- data/LICENSE +1 -1
- data/README.rdoc +8 -7
- data/Rakefile +22 -32
- data/VERSION +1 -1
- data/ext/UiaDll/Release/UiaDll.dll +0 -0
- data/ext/UiaDll/UiaDll.suo +0 -0
- data/ext/UiaDll/UiaDll/UiaDll.cpp +236 -10
- data/lib/rautomation/adapter/autoit/locators.rb +1 -1
- data/lib/rautomation/adapter/autoit/text_field.rb +10 -1
- data/lib/rautomation/adapter/autoit/window.rb +50 -23
- data/lib/rautomation/adapter/helper.rb +6 -6
- data/lib/rautomation/adapter/ms_uia.rb +22 -0
- data/lib/rautomation/adapter/{win_ffi → ms_uia}/button.rb +3 -2
- data/lib/rautomation/adapter/ms_uia/button_helper.rb +25 -0
- data/lib/rautomation/adapter/ms_uia/checkbox.rb +27 -0
- data/lib/rautomation/adapter/{win_ffi → ms_uia}/constants.rb +20 -5
- data/lib/rautomation/adapter/ms_uia/control.rb +180 -0
- data/lib/rautomation/adapter/{win_ffi → ms_uia}/functions.rb +24 -26
- data/lib/rautomation/adapter/ms_uia/keystroke_converter.rb +122 -0
- data/lib/rautomation/adapter/{win_ffi → ms_uia}/label.rb +3 -2
- data/lib/rautomation/adapter/ms_uia/list_box.rb +91 -0
- data/lib/rautomation/adapter/ms_uia/list_item.rb +49 -0
- data/lib/rautomation/adapter/ms_uia/locators.rb +23 -0
- data/lib/rautomation/adapter/{win_ffi → ms_uia}/radio.rb +2 -2
- data/lib/rautomation/adapter/{win_ffi → ms_uia}/select_list.rb +41 -7
- data/lib/rautomation/adapter/ms_uia/table.rb +86 -0
- data/lib/rautomation/adapter/{win_ffi → ms_uia}/text_field.rb +5 -4
- data/lib/rautomation/adapter/ms_uia/uia_dll.rb +62 -0
- data/lib/rautomation/adapter/ms_uia/window.rb +364 -0
- data/lib/rautomation/adapter/win_32.rb +21 -0
- data/lib/rautomation/adapter/win_32/button.rb +14 -0
- data/lib/rautomation/adapter/{win_ffi → win_32}/button_helper.rb +1 -1
- data/lib/rautomation/adapter/win_32/checkbox.rb +14 -0
- data/lib/rautomation/adapter/win_32/constants.rb +68 -0
- data/lib/rautomation/adapter/{win_ffi → win_32}/control.rb +30 -23
- data/lib/rautomation/adapter/win_32/functions.rb +313 -0
- data/lib/rautomation/adapter/win_32/keys.rb +121 -0
- data/lib/rautomation/adapter/win_32/label.rb +10 -0
- data/lib/rautomation/adapter/win_32/list_box.rb +40 -0
- data/lib/rautomation/adapter/{win_ffi → win_32}/locators.rb +2 -2
- data/lib/rautomation/adapter/win_32/radio.rb +11 -0
- data/lib/rautomation/adapter/win_32/select_list.rb +97 -0
- data/lib/rautomation/adapter/win_32/table.rb +22 -0
- data/lib/rautomation/adapter/win_32/text_field.rb +42 -0
- data/lib/rautomation/adapter/{win_ffi → win_32}/window.rb +79 -62
- data/lib/rautomation/element_collections.rb +9 -1
- data/lib/rautomation/window.rb +17 -9
- data/rautomation.gemspec +24 -0
- data/spec/adapter/autoit/window_spec.rb +71 -0
- data/spec/adapter/{win_ffi → ms_uia}/button_spec.rb +1 -1
- data/spec/adapter/{win_ffi → ms_uia}/checkbox_spec.rb +9 -3
- data/spec/adapter/ms_uia/control_spec.rb +28 -0
- data/spec/adapter/ms_uia/keystroke_converter_spec.rb +50 -0
- data/spec/adapter/{win_ffi → ms_uia}/label_spec.rb +2 -2
- data/spec/adapter/ms_uia/list_item_spec.rb +14 -0
- data/spec/adapter/{win_ffi → ms_uia}/listbox_spec.rb +18 -5
- data/spec/adapter/{win_ffi → ms_uia}/radio_spec.rb +3 -1
- data/spec/adapter/ms_uia/select_list_spec.rb +109 -0
- data/spec/adapter/{win_ffi → ms_uia}/table_spec.rb +12 -1
- data/spec/adapter/{win_ffi → ms_uia}/text_field_spec.rb +2 -1
- data/spec/adapter/ms_uia/window_spec.rb +89 -0
- data/spec/adapter/win_32/button_spec.rb +30 -0
- data/spec/adapter/win_32/checkbox_spec.rb +48 -0
- data/spec/adapter/win_32/label_spec.rb +15 -0
- data/spec/adapter/win_32/listbox_spec.rb +42 -0
- data/spec/adapter/win_32/radio_spec.rb +32 -0
- data/spec/adapter/{win_ffi → win_32}/select_list_spec.rb +16 -16
- data/spec/adapter/win_32/table_spec.rb +28 -0
- data/spec/adapter/win_32/text_field_spec.rb +24 -0
- data/spec/adapter/{win_ffi → win_32}/window_spec.rb +19 -14
- data/spec/button_spec.rb +1 -0
- data/spec/buttons_spec.rb +4 -4
- data/spec/spec_helper.rb +30 -4
- data/spec/text_field_spec.rb +6 -7
- data/spec/window_spec.rb +12 -0
- data/spec/windows_spec.rb +19 -0
- metadata +116 -97
- data/lib/rautomation/adapter/win_ffi.rb +0 -21
- data/lib/rautomation/adapter/win_ffi/checkbox.rb +0 -19
- data/lib/rautomation/adapter/win_ffi/keystroke_converter.rb +0 -67
- data/lib/rautomation/adapter/win_ffi/list_box.rb +0 -60
- data/lib/rautomation/adapter/win_ffi/ms_uia/uia_dll.rb +0 -36
- data/lib/rautomation/adapter/win_ffi/table.rb +0 -57
- data/spec/adapter/win_ffi/keystroke_converter_spec.rb +0 -47
@@ -1,6 +1,9 @@
|
|
1
1
|
module RAutomation
|
2
2
|
# @private
|
3
3
|
module ElementCollections
|
4
|
+
class UnsupportedLocatorException < RuntimeError
|
5
|
+
end
|
6
|
+
|
4
7
|
# Creates collection classes and methods for elements.
|
5
8
|
# @param [Array<Symbol>] elements for which to create collection classes
|
6
9
|
# and methods.
|
@@ -15,6 +18,11 @@ module RAutomation
|
|
15
18
|
include Enumerable
|
16
19
|
|
17
20
|
def initialize(window, locators)
|
21
|
+
if locators[:hwnd] || locators[:pid]
|
22
|
+
raise UnsupportedLocatorException,
|
23
|
+
":hwnd or :pid in " + locators.inspect + " are not supported for #{adapter_class}::#{class_name_plural}"
|
24
|
+
end
|
25
|
+
|
18
26
|
@window = window
|
19
27
|
@locators = locators
|
20
28
|
end
|
@@ -38,7 +46,7 @@ module RAutomation
|
|
38
46
|
|
39
47
|
class_eval %Q{
|
40
48
|
def #{element}(locators = {})
|
41
|
-
#{class_name_plural}.new(@window, locators)
|
49
|
+
#{adapter_class}::#{class_name_plural}.new(@window || self, locators)
|
42
50
|
end
|
43
51
|
}
|
44
52
|
end
|
data/lib/rautomation/window.rb
CHANGED
@@ -15,12 +15,13 @@ module RAutomation
|
|
15
15
|
has_many :windows, :buttons, :text_fields
|
16
16
|
|
17
17
|
class << self
|
18
|
+
# @param locators (see #initialize)
|
18
19
|
# @return [Windows] all windows.
|
19
|
-
def windows
|
20
|
-
Windows.new(nil,
|
20
|
+
def windows(locators = {})
|
21
|
+
Windows.new(nil, locators)
|
21
22
|
end
|
22
23
|
end
|
23
|
-
|
24
|
+
|
24
25
|
# Retrieves all windows with similar locators to the current window.
|
25
26
|
# @param locators (see #initialize)
|
26
27
|
# @return [Windows] all windows matching current window's _locators_ if no
|
@@ -63,7 +64,7 @@ module RAutomation
|
|
63
64
|
# @param [Hash] locators locators for the window.
|
64
65
|
def initialize(locators)
|
65
66
|
@adapter = locators.delete(:adapter) || ENV["RAUTOMATION_ADAPTER"] && ENV["RAUTOMATION_ADAPTER"].to_sym || default_adapter
|
66
|
-
@window = Adapter.const_get(normalize(@adapter)).const_get(:Window).new(locators)
|
67
|
+
@window = Adapter.const_get(normalize(@adapter)).const_get(:Window).new(self, locators)
|
67
68
|
end
|
68
69
|
|
69
70
|
class << self
|
@@ -105,6 +106,13 @@ module RAutomation
|
|
105
106
|
@window.title
|
106
107
|
end
|
107
108
|
|
109
|
+
# @return [Array<String>] all {Window} class names in a sorted array.
|
110
|
+
# @raise [UnknownWindowException] if the window doesn't exist.
|
111
|
+
def class_names
|
112
|
+
wait_until_present
|
113
|
+
@window.class_names
|
114
|
+
end
|
115
|
+
|
108
116
|
# Activates the Window, e.g. brings it to the top of other windows.
|
109
117
|
def activate
|
110
118
|
@window.activate
|
@@ -179,7 +187,7 @@ module RAutomation
|
|
179
187
|
|
180
188
|
# Sends keyboard keys to the window. Refer to specific {Adapter} documentation for all possible values.
|
181
189
|
# @raise [UnknownWindowException] if the window doesn't exist.
|
182
|
-
def send_keys(keys)
|
190
|
+
def send_keys(*keys)
|
183
191
|
wait_until_present
|
184
192
|
@window.send_keys(keys)
|
185
193
|
end
|
@@ -194,7 +202,7 @@ module RAutomation
|
|
194
202
|
# @note Refer to specific {Adapter} documentation for possible _locator_ parameters.
|
195
203
|
# @param [Hash] locators for the {Button}.
|
196
204
|
# @raise [UnknownWindowException] if the window doesn't exist.
|
197
|
-
def button(locators)
|
205
|
+
def button(locators={})
|
198
206
|
wait_until_present
|
199
207
|
Button.new(@window, locators)
|
200
208
|
end
|
@@ -202,7 +210,7 @@ module RAutomation
|
|
202
210
|
# Retrieves {TextField} on the window.
|
203
211
|
# @note Refer to specific {Adapter} documentation for possible _locators_ parameters.
|
204
212
|
# @raise [UnknownWindowException] if the window doesn't exist.
|
205
|
-
def text_field(locators)
|
213
|
+
def text_field(locators={})
|
206
214
|
wait_until_present
|
207
215
|
TextField.new(@window, locators)
|
208
216
|
end
|
@@ -212,8 +220,6 @@ module RAutomation
|
|
212
220
|
@window.send(name, *args)
|
213
221
|
end
|
214
222
|
|
215
|
-
private
|
216
|
-
|
217
223
|
def wait_until_present
|
218
224
|
WaitHelper.wait_until {present?}
|
219
225
|
rescue WaitHelper::TimeoutError
|
@@ -226,6 +232,8 @@ module RAutomation
|
|
226
232
|
raise UnknownWindowException, "Window with locator #{@window.locators.inspect} doesn't exist!"
|
227
233
|
end
|
228
234
|
|
235
|
+
private
|
236
|
+
|
229
237
|
def normalize adapter
|
230
238
|
adapter.to_s.split("_").map {|word| word.capitalize}.join
|
231
239
|
end
|
data/rautomation.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = %q{rautomation}
|
4
|
+
s.version = File.read("VERSION").strip
|
5
|
+
s.authors = [%q{Jarmo Pertman}]
|
6
|
+
s.email = %q{jarmo.p@gmail.com}
|
7
|
+
s.description = %q{RAutomation is a small and easy to use library for helping out to automate windows and their controls
|
8
|
+
for automated testing.
|
9
|
+
|
10
|
+
RAutomation provides:
|
11
|
+
* Easy to use and user-friendly API (inspired by Watir http://www.watir.com)
|
12
|
+
* Cross-platform compatibility
|
13
|
+
* Easy extensibility - with small scripting effort it's possible to add support for not yet
|
14
|
+
supported platforms or technologies}
|
15
|
+
s.homepage = %q{http://github.com/jarmo/RAutomation}
|
16
|
+
s.summary = %q{Automate windows and their controls through user-friendly API with Ruby}
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency("rspec", "~>2.3")
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "AutoIt::Window", :if => SpecHelper.adapter == :autoit do
|
4
|
+
|
5
|
+
it "mouse clicking" do
|
6
|
+
window = RAutomation::Window.new(:title => "MainFormWindow")
|
7
|
+
|
8
|
+
popup = RAutomation::Window.new(:title => "About")
|
9
|
+
popup.exist?.should == false
|
10
|
+
|
11
|
+
window.maximize
|
12
|
+
window.move_mouse(60, 45)
|
13
|
+
window.click_mouse
|
14
|
+
|
15
|
+
sleep 0.1
|
16
|
+
|
17
|
+
popup = RAutomation::Window.new(:title => "About")
|
18
|
+
popup.exist?.should == true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "mouse position" do
|
22
|
+
window = RAutomation::Window.new(:title => "MainFormWindow")
|
23
|
+
|
24
|
+
window.move_mouse(1, 1)
|
25
|
+
window.mouse_position.should_not == [100, 100]
|
26
|
+
|
27
|
+
window.move_mouse(100, 100)
|
28
|
+
window.mouse_position.should == [100, 100]
|
29
|
+
end
|
30
|
+
|
31
|
+
it "mouse press/release" do
|
32
|
+
window = RAutomation::Window.new(:title => "MainFormWindow")
|
33
|
+
window.maximize
|
34
|
+
|
35
|
+
text_field = window.text_field(:name => "textField")
|
36
|
+
text_field.set("start string")
|
37
|
+
text_field.value.should == "start string"
|
38
|
+
|
39
|
+
window.move_mouse(146, 103)
|
40
|
+
window.press_mouse
|
41
|
+
window.move_mouse(194, 103)
|
42
|
+
window.release_mouse
|
43
|
+
|
44
|
+
window.send_keys("^c")
|
45
|
+
|
46
|
+
text_field.set("new string")
|
47
|
+
text_field.value.should == "new string"
|
48
|
+
|
49
|
+
window.move_mouse(146, 103)
|
50
|
+
window.press_mouse
|
51
|
+
window.move_mouse(194, 103)
|
52
|
+
window.release_mouse
|
53
|
+
window.send_keys("^v")
|
54
|
+
|
55
|
+
text_field.value.should == "start string"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "#method_missing" do
|
59
|
+
window = RAutomation::Window.new(:title => "MainFormWindow")
|
60
|
+
|
61
|
+
window.MouseMove(1, 1)
|
62
|
+
position = [window.MouseGetPosX, window.MouseGetPosY]
|
63
|
+
position.should_not == [100, 100]
|
64
|
+
|
65
|
+
window.MouseMove(100, 100)
|
66
|
+
position = [window.MouseGetPosX, window.MouseGetPosY]
|
67
|
+
|
68
|
+
position.should == [100, 100]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "MsUia::Button", :if => SpecHelper.adapter == :ms_uia do
|
4
4
|
it "find by id" do
|
5
5
|
window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
|
6
6
|
window.button(:id => "aboutButton").should exist
|
@@ -1,16 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "MsUia::Checkbox", :if => SpecHelper.adapter == :ms_uia do
|
4
4
|
it "#checkbox" do
|
5
5
|
RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBox").should exist
|
6
6
|
|
7
7
|
RAutomation::Window.wait_timeout = 0.1
|
8
|
-
expect {RAutomation::Window.new(:title => "non-existing-window").checkbox(:value => "Something")}.
|
9
|
-
|
8
|
+
expect { RAutomation::Window.new(:title => "non-existing-window").checkbox(:value => "Something") }.
|
9
|
+
to raise_exception(RAutomation::UnknownWindowException)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "check for checkbox class" do
|
13
13
|
RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "textField").should_not exist
|
14
|
+
RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "checkBox").should exist
|
14
15
|
end
|
15
16
|
|
16
17
|
|
@@ -22,6 +23,11 @@ describe "WinFfi::Checkbox", :if => SpecHelper.adapter == :win_ffi do
|
|
22
23
|
checkbox.should be_set
|
23
24
|
end
|
24
25
|
|
26
|
+
it "#value" do
|
27
|
+
checkbox = RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "checkBox")
|
28
|
+
checkbox.value.should == "checkBox"
|
29
|
+
end
|
30
|
+
|
25
31
|
it "#clear" do
|
26
32
|
checkbox = RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBox")
|
27
33
|
checkbox.set
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
|
4
|
+
describe "MsUia::Control", :if => SpecHelper.adapter == :ms_uia do
|
5
|
+
|
6
|
+
it "control coordinates", :special => false do
|
7
|
+
window = RAutomation::Window.new(:title => /MainFormWindow/i)
|
8
|
+
|
9
|
+
window.maximize
|
10
|
+
control = window.control(:id => "radioButtonReset")
|
11
|
+
control.bounding_rectangle.should be_all {|coord| coord.between?(200, 400)}
|
12
|
+
end
|
13
|
+
|
14
|
+
it "control process id", :special => true do
|
15
|
+
window = RAutomation::Window.new(:title => /MainFormWindow/i)
|
16
|
+
|
17
|
+
control = window.control(:id => "radioButtonReset")
|
18
|
+
control.new_pid.should == @pid1
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has a class" do
|
22
|
+
window = RAutomation::Window.new(:title => /MainFormWindow/i)
|
23
|
+
|
24
|
+
control = window.control(:id => "radioButtonReset")
|
25
|
+
control.control_class.should =~ /WindowsForms10.BUTTON.app.0.2bf8098_r1[0-9]_ad1/
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'rautomation'
|
3
|
+
require 'rspec'
|
4
|
+
|
5
|
+
describe "KeystrokeConverter", :if => SpecHelper.adapter == :ms_uia do
|
6
|
+
|
7
|
+
it "converts plain ASCII" do
|
8
|
+
codes = RAutomation::Adapter::MsUia::KeystrokeConverter.convert("abc")
|
9
|
+
converted_keys = convert_keys "abc"
|
10
|
+
codes.should == converted_keys
|
11
|
+
end
|
12
|
+
|
13
|
+
it "uses caps lock for entering downcase keys" do
|
14
|
+
codes = RAutomation::Adapter::MsUia::KeystrokeConverter.convert("aBc")
|
15
|
+
converted_keys = convert_keys "abc"
|
16
|
+
converted_keys = converted_keys.insert(1, RAutomation::Adapter::MsUia::Constants::VK_LSHIFT)
|
17
|
+
codes.should == converted_keys
|
18
|
+
end
|
19
|
+
|
20
|
+
it "converts special keys" do
|
21
|
+
codes = RAutomation::Adapter::MsUia::KeystrokeConverter.convert("{tab}a{backspace}b{enter}c {left}d{right}ee{down}f{up}g{unsupported}{home}{end}{delete}")
|
22
|
+
expected_codes = [
|
23
|
+
RAutomation::Adapter::MsUia::Constants::VK_TAB,
|
24
|
+
convert_keys("a"),
|
25
|
+
RAutomation::Adapter::MsUia::Constants::VK_BACK,
|
26
|
+
convert_keys("b"),
|
27
|
+
RAutomation::Adapter::MsUia::Constants::VK_RETURN,
|
28
|
+
convert_keys("c"),
|
29
|
+
RAutomation::Adapter::MsUia::Constants::VK_SPACE,
|
30
|
+
RAutomation::Adapter::MsUia::Constants::VK_LEFT,
|
31
|
+
convert_keys("d"),
|
32
|
+
RAutomation::Adapter::MsUia::Constants::VK_RIGHT,
|
33
|
+
convert_keys("ee"),
|
34
|
+
RAutomation::Adapter::MsUia::Constants::VK_DOWN,
|
35
|
+
convert_keys("f"),
|
36
|
+
RAutomation::Adapter::MsUia::Constants::VK_UP,
|
37
|
+
convert_keys("g"),
|
38
|
+
convert_keys("unsupported"),
|
39
|
+
RAutomation::Adapter::MsUia::Constants::VK_HOME,
|
40
|
+
RAutomation::Adapter::MsUia::Constants::VK_END,
|
41
|
+
RAutomation::Adapter::MsUia::Constants::VK_DELETE
|
42
|
+
].flatten
|
43
|
+
codes.should == expected_codes
|
44
|
+
end
|
45
|
+
|
46
|
+
def convert_keys keys
|
47
|
+
keys.split("").map { |k| k.upcase.unpack("c")[0] }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "MsUia::Label", :if => SpecHelper.adapter == :ms_uia do
|
4
4
|
it "#exist?" do
|
5
5
|
window = RAutomation::Window.new(:title => "MainFormWindow")
|
6
6
|
|
@@ -10,9 +10,9 @@ describe "WinFfi::Label", :if => SpecHelper.adapter == :win_ffi do
|
|
10
10
|
|
11
11
|
it "check for label class" do
|
12
12
|
RAutomation::Window.new(:title => "MainFormWindow").label(:id => "textField").should_not exist
|
13
|
+
RAutomation::Window.new(:title => "MainFormWindow").label(:id => "label1").should exist
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
16
|
it "#label" do
|
17
17
|
window = RAutomation::Window.new(:title => "MainFormWindow")
|
18
18
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "MsUia::ListItem", :if => SpecHelper.adapter == :ms_uia do
|
4
|
+
|
5
|
+
it "#exists" do
|
6
|
+
RAutomation::Window.new(:title => "MainFormWindow").list_item(:value => "Apple").should exist
|
7
|
+
RAutomation::Window.new(:title => "MainFormWindow").list_item(:value => "This is a sample text").should_not exist
|
8
|
+
end
|
9
|
+
|
10
|
+
it "#value" do
|
11
|
+
RAutomation::Window.new(:title => "MainFormWindow").list_item(:value => "Apple").value.should == "Apple"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "MsUia::ListBox", :if => SpecHelper.adapter == :ms_uia do
|
4
4
|
|
5
5
|
it "#exists" do
|
6
6
|
RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox").should exist
|
7
7
|
end
|
8
8
|
|
9
|
-
it "
|
9
|
+
it "checks for ListBox class" do
|
10
10
|
RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "textField").should_not exist
|
11
|
+
RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox").should exist
|
11
12
|
end
|
12
13
|
|
13
14
|
it "counts items" do
|
@@ -17,11 +18,23 @@ describe "WinFfi::ListBox", :if => SpecHelper.adapter == :win_ffi do
|
|
17
18
|
|
18
19
|
it "lists items" do
|
19
20
|
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
20
|
-
|
21
|
-
list_box.items[
|
22
|
-
list_box.items[
|
21
|
+
|
22
|
+
list_box.items[0].value.should == "Apple"
|
23
|
+
list_box.items[1].value.should == "Orange"
|
24
|
+
list_box.items[2].value.should == "Mango"
|
23
25
|
end
|
24
26
|
|
27
|
+
it "returns a value" do
|
28
|
+
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
29
|
+
|
30
|
+
list_box.value.should == ""
|
31
|
+
list_box.select(0)
|
32
|
+
list_box.value.should == "Apple"
|
33
|
+
list_box.select(1)
|
34
|
+
list_box.value.should == "Orange"
|
35
|
+
list_box.select(2)
|
36
|
+
list_box.value.should == "Mango"
|
37
|
+
end
|
25
38
|
|
26
39
|
it "#selected?" do
|
27
40
|
list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "MsUia::RadioButton", :if => SpecHelper.adapter == :ms_uia do
|
4
|
+
|
4
5
|
it "#exist?" do
|
5
6
|
RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option 1").should exist
|
6
7
|
|
@@ -12,6 +13,7 @@ describe "WinFfi::RadioButton", :if => SpecHelper.adapter == :win_ffi do
|
|
12
13
|
|
13
14
|
it "check for radio class" do
|
14
15
|
RAutomation::Window.new(:title => "MainFormWindow").radio(:id => "textField").should_not exist
|
16
|
+
RAutomation::Window.new(:title => "MainFormWindow").radio(:id => "radioButton2").should exist
|
15
17
|
end
|
16
18
|
|
17
19
|
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "MsUia::SelectList", :if => SpecHelper.adapter == :ms_uia do
|
4
|
+
it "#select_list" do
|
5
|
+
RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox").should exist
|
6
|
+
|
7
|
+
RAutomation::Window.wait_timeout = 0.1
|
8
|
+
expect {RAutomation::Window.new(:title => "non-existent-window").
|
9
|
+
select_list(:class => /COMBOBOX/i)}.
|
10
|
+
to raise_exception(RAutomation::UnknownWindowException)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "check for select list class" do
|
14
|
+
RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "textField").should_not exist
|
15
|
+
RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox").should exist
|
16
|
+
end
|
17
|
+
|
18
|
+
it "#options" do
|
19
|
+
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
|
20
|
+
select_list.options.size.should == 5
|
21
|
+
|
22
|
+
expected_options = ["Apple", "Caimito", "Coconut", "Orange", "Passion Fruit"]
|
23
|
+
select_list.options.map {|option| option.text}.should == expected_options
|
24
|
+
end
|
25
|
+
|
26
|
+
it "#selected? & #select" do
|
27
|
+
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
|
28
|
+
select_list.options(:text => "Apple")[0].should_not be_selected
|
29
|
+
select_list.options(:text => "Apple")[0].select.should be_true
|
30
|
+
select_list.options(:text => "Apple")[0].should be_selected
|
31
|
+
end
|
32
|
+
|
33
|
+
it "#set" do
|
34
|
+
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
|
35
|
+
select_list.options(:text => "Apple")[0].should_not be_selected
|
36
|
+
select_list.set("Apple")
|
37
|
+
select_list.options(:text => "Apple")[0].should be_selected
|
38
|
+
end
|
39
|
+
|
40
|
+
it "#value" do
|
41
|
+
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
|
42
|
+
|
43
|
+
#default empty state
|
44
|
+
select_list.value.should == ""
|
45
|
+
|
46
|
+
select_list.options(:text => "Apple")[0].select
|
47
|
+
select_list.value.should == "Apple"
|
48
|
+
|
49
|
+
select_list.options(:text => "Caimito")[0].select
|
50
|
+
select_list.value.should == "Caimito"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "enabled/disabled" do
|
54
|
+
RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox").should be_enabled
|
55
|
+
RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox").should_not be_disabled
|
56
|
+
|
57
|
+
RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "comboBoxDisabled").should_not be_enabled
|
58
|
+
RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "comboBoxDisabled").should be_disabled
|
59
|
+
end
|
60
|
+
|
61
|
+
it "#option" do
|
62
|
+
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
|
63
|
+
|
64
|
+
select_list.option(:text => "Apple").should_not be_selected
|
65
|
+
select_list.option(:text => "Apple").set
|
66
|
+
select_list.option(:text => "Apple").should be_selected
|
67
|
+
end
|
68
|
+
|
69
|
+
it "cannot select anything on a disabled select list" do
|
70
|
+
select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "comboBoxDisabled")
|
71
|
+
|
72
|
+
lambda { select_list.option(:text => "Apple").set }.should raise_error
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# it "control by focus" do
|
77
|
+
# window = RAutomation::Window.new(:title => /MainFormWindow/i)
|
78
|
+
#
|
79
|
+
# button = window.button(:value => "Reset")
|
80
|
+
# button.set_focus
|
81
|
+
#
|
82
|
+
# element = window.get_focused_element
|
83
|
+
# type =button.get_current_control_type(element)
|
84
|
+
# puts "type :#{type}"
|
85
|
+
|
86
|
+
# box1 = another_button.bounding_rectangle
|
87
|
+
# box2 = button.bounding_rectangle
|
88
|
+
#
|
89
|
+
#
|
90
|
+
# puts "#{box1}"
|
91
|
+
# puts "#{box2}"
|
92
|
+
#
|
93
|
+
# sleep 10
|
94
|
+
# box1.should == box2
|
95
|
+
# end
|
96
|
+
|
97
|
+
# it "fires change event when selected" do
|
98
|
+
#
|
99
|
+
# select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
|
100
|
+
#
|
101
|
+
# select_list.option(:text => "Apple").should_not be_selected
|
102
|
+
# select_list.set("Apple")
|
103
|
+
# select_list.option(:text => "Apple").should be_selected
|
104
|
+
#
|
105
|
+
# label = RAutomation::Window.new(:title => "MainFormWindow").label(:id => "fruitsLabel")
|
106
|
+
# sleep 1
|
107
|
+
# label.value.should == "Apple"
|
108
|
+
# end
|
109
|
+
end
|