rautomation 2.0.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +41 -0
  4. data/.rspec +2 -0
  5. data/.yardopts +8 -0
  6. data/CHANGES.md +276 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE +20 -0
  9. data/README.md +142 -0
  10. data/Rakefile +73 -0
  11. data/ext/AutoItX/AutoItX.chm +0 -0
  12. data/ext/AutoItX/AutoItX3.dll +0 -0
  13. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.cpp +30 -0
  14. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj +179 -0
  15. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj.filters +42 -0
  16. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj.user +3 -0
  17. data/ext/IAccessibleDLL/IAccessibleDLL/ReadMe.txt +48 -0
  18. data/ext/IAccessibleDLL/IAccessibleDLL/dllmain.cpp +19 -0
  19. data/ext/IAccessibleDLL/IAccessibleDLL/stdafx.cpp +8 -0
  20. data/ext/IAccessibleDLL/IAccessibleDLL/stdafx.h +22 -0
  21. data/ext/IAccessibleDLL/IAccessibleDLL/table_support.cpp +282 -0
  22. data/ext/IAccessibleDLL/IAccessibleDLL/targetver.h +8 -0
  23. data/ext/IAccessibleDLL/IAccessibleDLL.sln +31 -0
  24. data/ext/IAccessibleDLL/IAccessibleDLL.suo +0 -0
  25. data/ext/IAccessibleDLL/Release/IAccessibleDLL.dll +0 -0
  26. data/ext/UiaDll/RAutomation.UIA/Controls/Clicker.cs +63 -0
  27. data/ext/UiaDll/RAutomation.UIA/Controls/SelectList.cs +116 -0
  28. data/ext/UiaDll/RAutomation.UIA/Controls/Spinner.cs +46 -0
  29. data/ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs +54 -0
  30. data/ext/UiaDll/RAutomation.UIA/Controls/TableControl.cs +132 -0
  31. data/ext/UiaDll/RAutomation.UIA/Controls/TextControl.cs +50 -0
  32. data/ext/UiaDll/RAutomation.UIA/Expander.cs +59 -0
  33. data/ext/UiaDll/RAutomation.UIA/Extensions/Element.cs +166 -0
  34. data/ext/UiaDll/RAutomation.UIA/Extensions/Enumerable.cs +76 -0
  35. data/ext/UiaDll/RAutomation.UIA/Extensions/Property.cs +27 -0
  36. data/ext/UiaDll/RAutomation.UIA/Properties/AssemblyInfo.cs +36 -0
  37. data/ext/UiaDll/RAutomation.UIA/Properties/AutomationProperties.cs +18 -0
  38. data/ext/UiaDll/RAutomation.UIA/RAutomation.UIA.csproj +77 -0
  39. data/ext/UiaDll/Release/RAutomation.UIA.dll +0 -0
  40. data/ext/UiaDll/Release/UiaDll.dll +0 -0
  41. data/ext/UiaDll/UiaDll/ArrayHelper.cpp +14 -0
  42. data/ext/UiaDll/UiaDll/ArrayHelper.h +7 -0
  43. data/ext/UiaDll/UiaDll/AssemblyInfo.cpp +40 -0
  44. data/ext/UiaDll/UiaDll/ControlMethods.cpp +16 -0
  45. data/ext/UiaDll/UiaDll/DynamicAssemblyResolver.cpp +24 -0
  46. data/ext/UiaDll/UiaDll/DynamicAssemblyResolver.h +16 -0
  47. data/ext/UiaDll/UiaDll/Locator.cpp +93 -0
  48. data/ext/UiaDll/UiaDll/Locator.h +55 -0
  49. data/ext/UiaDll/UiaDll/MenuItemSelector.cpp +75 -0
  50. data/ext/UiaDll/UiaDll/MenuItemSelector.h +24 -0
  51. data/ext/UiaDll/UiaDll/MenuMethods.cpp +62 -0
  52. data/ext/UiaDll/UiaDll/ReadMe.txt +38 -0
  53. data/ext/UiaDll/UiaDll/SelectListMethods.cpp +84 -0
  54. data/ext/UiaDll/UiaDll/SpinnerMethods.cpp +61 -0
  55. data/ext/UiaDll/UiaDll/StringHelper.cpp +57 -0
  56. data/ext/UiaDll/UiaDll/StringHelper.h +15 -0
  57. data/ext/UiaDll/UiaDll/StringMethods.cpp +8 -0
  58. data/ext/UiaDll/UiaDll/TabControlMethods.cpp +40 -0
  59. data/ext/UiaDll/UiaDll/TableMethods.cpp +108 -0
  60. data/ext/UiaDll/UiaDll/TextMethods.cpp +25 -0
  61. data/ext/UiaDll/UiaDll/ToggleStateHelper.h +10 -0
  62. data/ext/UiaDll/UiaDll/UiaDll.cpp +216 -0
  63. data/ext/UiaDll/UiaDll/UiaDll.h +13 -0
  64. data/ext/UiaDll/UiaDll/UiaDll.vcxproj +167 -0
  65. data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +110 -0
  66. data/ext/UiaDll/UiaDll/app.ico +0 -0
  67. data/ext/UiaDll/UiaDll/app.rc +0 -0
  68. data/ext/UiaDll/UiaDll/dllmain.cpp +1 -0
  69. data/ext/UiaDll/UiaDll/resource.h +3 -0
  70. data/ext/UiaDll/UiaDll/stdafx.cpp +5 -0
  71. data/ext/UiaDll/UiaDll/stdafx.h +41 -0
  72. data/ext/UiaDll/UiaDll/targetver.h +8 -0
  73. data/ext/UiaDll/UiaDll.sln +57 -0
  74. data/ext/WindowsForms/.nuget/NuGet.Config +6 -0
  75. data/ext/WindowsForms/.nuget/NuGet.exe +0 -0
  76. data/ext/WindowsForms/.nuget/NuGet.targets +136 -0
  77. data/ext/WindowsForms/Release/FizzWare.NBuilder.dll +0 -0
  78. data/ext/WindowsForms/Release/UIA.Extensions.dll +0 -0
  79. data/ext/WindowsForms/Release/WindowsForms.exe +0 -0
  80. data/ext/WindowsForms/WindowsForms/AboutBox.Designer.cs +168 -0
  81. data/ext/WindowsForms/WindowsForms/AboutBox.cs +103 -0
  82. data/ext/WindowsForms/WindowsForms/AboutBox.resx +123 -0
  83. data/ext/WindowsForms/WindowsForms/DataEntryForm.Designer.cs +218 -0
  84. data/ext/WindowsForms/WindowsForms/DataEntryForm.cs +52 -0
  85. data/ext/WindowsForms/WindowsForms/DataEntryForm.resx +120 -0
  86. data/ext/WindowsForms/WindowsForms/DataGridView.Designer.cs +77 -0
  87. data/ext/WindowsForms/WindowsForms/DataGridView.cs +43 -0
  88. data/ext/WindowsForms/WindowsForms/DataGridView.resx +120 -0
  89. data/ext/WindowsForms/WindowsForms/FizzWare.NBuilder.dll +0 -0
  90. data/ext/WindowsForms/WindowsForms/MainFormWindow.Designer.cs +527 -0
  91. data/ext/WindowsForms/WindowsForms/MainFormWindow.cs +109 -0
  92. data/ext/WindowsForms/WindowsForms/MainFormWindow.resx +126 -0
  93. data/ext/WindowsForms/WindowsForms/PersonForm.Designer.cs +119 -0
  94. data/ext/WindowsForms/WindowsForms/PersonForm.cs +34 -0
  95. data/ext/WindowsForms/WindowsForms/PersonForm.resx +120 -0
  96. data/ext/WindowsForms/WindowsForms/Program.cs +21 -0
  97. data/ext/WindowsForms/WindowsForms/Properties/AssemblyInfo.cs +36 -0
  98. data/ext/WindowsForms/WindowsForms/Properties/Resources.Designer.cs +71 -0
  99. data/ext/WindowsForms/WindowsForms/Properties/Resources.resx +117 -0
  100. data/ext/WindowsForms/WindowsForms/Properties/Settings.Designer.cs +30 -0
  101. data/ext/WindowsForms/WindowsForms/Properties/Settings.settings +7 -0
  102. data/ext/WindowsForms/WindowsForms/SimpleElementsForm.Designer.cs +93 -0
  103. data/ext/WindowsForms/WindowsForms/SimpleElementsForm.cs +19 -0
  104. data/ext/WindowsForms/WindowsForms/SimpleElementsForm.resx +120 -0
  105. data/ext/WindowsForms/WindowsForms/UIA.Extensions.dll +0 -0
  106. data/ext/WindowsForms/WindowsForms/ValueMonthCalendar.cs +28 -0
  107. data/ext/WindowsForms/WindowsForms/WindowsForms.csproj +166 -0
  108. data/ext/WindowsForms/WindowsForms/packages.config +4 -0
  109. data/ext/WindowsForms/WindowsForms.sln +46 -0
  110. data/lib/rautomation/adapter/autoit/button.rb +59 -0
  111. data/lib/rautomation/adapter/autoit/locators.rb +22 -0
  112. data/lib/rautomation/adapter/autoit/mouse.rb +38 -0
  113. data/lib/rautomation/adapter/autoit/text_field.rb +70 -0
  114. data/lib/rautomation/adapter/autoit/window.rb +197 -0
  115. data/lib/rautomation/adapter/autoit.rb +8 -0
  116. data/lib/rautomation/adapter/helper.rb +64 -0
  117. data/lib/rautomation/adapter/ms_uia/button.rb +21 -0
  118. data/lib/rautomation/adapter/ms_uia/button_helper.rb +19 -0
  119. data/lib/rautomation/adapter/ms_uia/checkbox.rb +23 -0
  120. data/lib/rautomation/adapter/ms_uia/constants.rb +111 -0
  121. data/lib/rautomation/adapter/ms_uia/control.rb +134 -0
  122. data/lib/rautomation/adapter/ms_uia/functions.rb +279 -0
  123. data/lib/rautomation/adapter/ms_uia/keys.rb +121 -0
  124. data/lib/rautomation/adapter/ms_uia/keystroke_converter.rb +122 -0
  125. data/lib/rautomation/adapter/ms_uia/label.rb +18 -0
  126. data/lib/rautomation/adapter/ms_uia/list_box.rb +46 -0
  127. data/lib/rautomation/adapter/ms_uia/list_item.rb +22 -0
  128. data/lib/rautomation/adapter/ms_uia/locators.rb +23 -0
  129. data/lib/rautomation/adapter/ms_uia/menu.rb +36 -0
  130. data/lib/rautomation/adapter/ms_uia/radio.rb +23 -0
  131. data/lib/rautomation/adapter/ms_uia/select_list.rb +85 -0
  132. data/lib/rautomation/adapter/ms_uia/spinner.rb +31 -0
  133. data/lib/rautomation/adapter/ms_uia/tab_control.rb +46 -0
  134. data/lib/rautomation/adapter/ms_uia/table.rb +140 -0
  135. data/lib/rautomation/adapter/ms_uia/text_field.rb +39 -0
  136. data/lib/rautomation/adapter/ms_uia/uia_dll.rb +428 -0
  137. data/lib/rautomation/adapter/ms_uia/value_control.rb +21 -0
  138. data/lib/rautomation/adapter/ms_uia/window.rb +289 -0
  139. data/lib/rautomation/adapter/ms_uia.rb +27 -0
  140. data/lib/rautomation/adapter/win_32/button.rb +14 -0
  141. data/lib/rautomation/adapter/win_32/button_helper.rb +24 -0
  142. data/lib/rautomation/adapter/win_32/checkbox.rb +14 -0
  143. data/lib/rautomation/adapter/win_32/constants.rb +73 -0
  144. data/lib/rautomation/adapter/win_32/control.rb +86 -0
  145. data/lib/rautomation/adapter/win_32/functions.rb +336 -0
  146. data/lib/rautomation/adapter/win_32/keys.rb +146 -0
  147. data/lib/rautomation/adapter/win_32/label.rb +10 -0
  148. data/lib/rautomation/adapter/win_32/list_box.rb +40 -0
  149. data/lib/rautomation/adapter/win_32/locators.rb +22 -0
  150. data/lib/rautomation/adapter/win_32/mouse.rb +59 -0
  151. data/lib/rautomation/adapter/win_32/password_field.rb +15 -0
  152. data/lib/rautomation/adapter/win_32/radio.rb +11 -0
  153. data/lib/rautomation/adapter/win_32/select_list.rb +97 -0
  154. data/lib/rautomation/adapter/win_32/table.rb +25 -0
  155. data/lib/rautomation/adapter/win_32/text_field.rb +52 -0
  156. data/lib/rautomation/adapter/win_32/window.rb +277 -0
  157. data/lib/rautomation/adapter/win_32.rb +23 -0
  158. data/lib/rautomation/button.rb +55 -0
  159. data/lib/rautomation/element_collections.rb +55 -0
  160. data/lib/rautomation/platform.rb +15 -0
  161. data/lib/rautomation/text_field.rb +60 -0
  162. data/lib/rautomation/version.rb +3 -0
  163. data/lib/rautomation/wait_helper.rb +23 -0
  164. data/lib/rautomation/window.rb +248 -0
  165. data/lib/rautomation.rb +8 -0
  166. data/rautomation.gemspec +52 -0
  167. data/spec/adapter/autoit/mouse_spec.rb +53 -0
  168. data/spec/adapter/autoit/window_spec.rb +17 -0
  169. data/spec/adapter/ms_uia/button_spec.rb +39 -0
  170. data/spec/adapter/ms_uia/checkbox_spec.rb +55 -0
  171. data/spec/adapter/ms_uia/control_spec.rb +88 -0
  172. data/spec/adapter/ms_uia/functions_spec.rb +39 -0
  173. data/spec/adapter/ms_uia/keystroke_converter_spec.rb +48 -0
  174. data/spec/adapter/ms_uia/label_spec.rb +18 -0
  175. data/spec/adapter/ms_uia/list_item_spec.rb +14 -0
  176. data/spec/adapter/ms_uia/listbox_spec.rb +73 -0
  177. data/spec/adapter/ms_uia/radio_spec.rb +39 -0
  178. data/spec/adapter/ms_uia/select_list_spec.rb +118 -0
  179. data/spec/adapter/ms_uia/spinner_spec.rb +44 -0
  180. data/spec/adapter/ms_uia/tab_control_spec.rb +53 -0
  181. data/spec/adapter/ms_uia/table_spec.rb +197 -0
  182. data/spec/adapter/ms_uia/text_field_spec.rb +43 -0
  183. data/spec/adapter/ms_uia/value_control_spec.rb +11 -0
  184. data/spec/adapter/ms_uia/window_spec.rb +81 -0
  185. data/spec/adapter/win_32/button_spec.rb +31 -0
  186. data/spec/adapter/win_32/checkbox_spec.rb +46 -0
  187. data/spec/adapter/win_32/label_spec.rb +13 -0
  188. data/spec/adapter/win_32/listbox_spec.rb +41 -0
  189. data/spec/adapter/win_32/mouse_spec.rb +49 -0
  190. data/spec/adapter/win_32/radio_spec.rb +33 -0
  191. data/spec/adapter/win_32/select_list_spec.rb +65 -0
  192. data/spec/adapter/win_32/table_spec.rb +27 -0
  193. data/spec/adapter/win_32/text_field_spec.rb +24 -0
  194. data/spec/adapter/win_32/window_spec.rb +61 -0
  195. data/spec/button_spec.rb +67 -0
  196. data/spec/buttons_spec.rb +21 -0
  197. data/spec/spec_helper.rb +128 -0
  198. data/spec/text_field_spec.rb +64 -0
  199. data/spec/text_fields_spec.rb +22 -0
  200. data/spec/window_spec.rb +150 -0
  201. data/spec/windows_spec.rb +76 -0
  202. metadata +369 -0
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe "MsUia::ListBox", if: SpecHelper.adapter == :ms_uia do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ let(:label) { window.label(id: "fruitsLabel") }
6
+ let(:list_box) { window.list_box(id: "FruitListBox") }
7
+
8
+ it "#exists" do
9
+ expect(list_box.exist?).to be true
10
+ end
11
+
12
+ it "checks for ListBox class" do
13
+ expect(window.list_box(id: "textField").exist?).to_not be true
14
+ expect(list_box.exist?).to be true
15
+ end
16
+
17
+ it "counts items" do
18
+ expect(list_box.count).to be == 3
19
+ end
20
+
21
+ it "lists items" do
22
+ expect(list_box.items[0].value).to be == "Apple"
23
+ expect(list_box.items[1].value).to be == "Orange"
24
+ expect(list_box.items[2].value).to be == "Mango"
25
+ end
26
+
27
+ it "returns a value" do
28
+ expect(list_box.value).to be == ""
29
+ list_box.select(0)
30
+ expect(list_box.value).to be == "Apple"
31
+ list_box.select(1)
32
+ expect(list_box.value).to be == "Orange"
33
+ list_box.select(2)
34
+ expect(list_box.value).to be == "Mango"
35
+ end
36
+
37
+ it "#selected?" do
38
+ expect(list_box.selected?(2)).to be false
39
+ list_box.select(2)
40
+ expect(list_box.selected?(2)).to be true
41
+ end
42
+
43
+ it "#select" do
44
+ list_box.select(1)
45
+ expect(list_box.selected?(1)).to be true
46
+
47
+ list_box.select(0)
48
+ expect(list_box.selected?(0)).to be true
49
+
50
+ list_box.select(2)
51
+ expect(list_box.selected?(2)).to be true
52
+ end
53
+
54
+ it "#strings" do
55
+ expect(list_box.strings).to be == ["Apple", "Orange", "Mango"]
56
+ end
57
+
58
+ it "fires events when the index changes" do
59
+ ['Apple', 'Orange', 'Mango'].each_with_index do |value, index|
60
+ list_box.select(index)
61
+ expect(label.value).to eq(value)
62
+ end
63
+ end
64
+
65
+ it 'fires events even when the item is not in the current view' do
66
+ window.menu(text: 'File').menu(text: 'Add Some Fruits').open
67
+
68
+ list_box.strings.each_with_index do |value, index|
69
+ list_box.select(index)
70
+ expect(label.value).to eq(value)
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe "MsUia::RadioButton", if: SpecHelper.adapter == :ms_uia do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ it "#exist?" do
6
+ expect(window.radio(value: "Option 1").exist?).to be true
7
+
8
+ RAutomation::Window.wait_timeout = 0.1
9
+ expect {RAutomation::Window.new(title: "non-existent-window").
10
+ radio(value: "Option 1")}.
11
+ to raise_exception(RAutomation::UnknownWindowException)
12
+ end
13
+
14
+ it "check for radio class" do
15
+ expect(window.radio(id: "textField").exist?).to_not be true
16
+ expect(window.radio(id: "radioButton2").exist?).to be true
17
+ end
18
+
19
+
20
+ it "#set? & #set" do
21
+ radio = window.radio(value: "Option 1")
22
+ expect(radio.set?).to_not be true
23
+
24
+ radio.set
25
+ expect(radio.set?).to be true
26
+ end
27
+
28
+ it "enabled/disabled" do
29
+ expect(window.radio(value: "Option 1").enabled?).to be true
30
+ expect(window.radio(value: "Option 1").disabled?).to_not be true
31
+
32
+ expect(window.radio(value: "Option Disabled").enabled?).to_not be true
33
+ expect(window.radio(value: "Option Disabled").disabled?).to be true
34
+ end
35
+
36
+ it "cannot set a disabled radio button" do
37
+ expect { window.radio(value: "Option Disabled").set }.to raise_error(RuntimeError)
38
+ end
39
+ end
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'MsUia::SelectList', if: SpecHelper.adapter == :ms_uia do
4
+ let(:window) { RAutomation::Window.new(title: 'MainFormWindow') }
5
+ let(:fruits_combo) { window.select_list(id: 'FruitsComboBox') }
6
+ let(:fruits_list) { window.select_list(id: 'FruitListBox') }
7
+ let(:fruit_label) { window.label(id: 'fruitsLabel') }
8
+ let(:disabled_combo) { window.select_list(id: 'comboBoxDisabled') }
9
+ let(:about) do
10
+ window.button(value: 'About').click { true }
11
+ about = RAutomation::Window.new(title: 'About')
12
+ end
13
+ let(:multi_fruits) do
14
+ about.tab_control(id: 'tabControl').set 'Multi-Select ListBox'
15
+ about.select_list(id: 'multiFruitListBox')
16
+ end
17
+
18
+ it '#select_list' do
19
+ expect(fruits_combo.exist?).to be true
20
+
21
+ RAutomation::Window.wait_timeout = 0.1
22
+ expect {RAutomation::Window.new(title: 'non-existent-window').
23
+ select_list(class: /COMBOBOX/i)}.
24
+ to raise_exception(RAutomation::UnknownWindowException)
25
+ end
26
+
27
+ it 'check for select list class' do
28
+ expect(window.select_list(id: 'textField').exist?).to_not be true
29
+ expect(fruits_combo.exist?).to be true
30
+ end
31
+
32
+ context 'SelectListOption' do
33
+ it '#selected? & #select' do
34
+ expect(fruits_combo.options(text: 'Apple')[0].selected?).to_not be true
35
+ expect(fruits_combo.options(text: 'Apple')[0].select).to be true
36
+ expect(fruits_combo.options(text: 'Apple')[0].selected?).to be true
37
+ end
38
+
39
+ it '#value' do
40
+
41
+ #default empty state
42
+ expect(fruits_combo.value).to be == ''
43
+
44
+ fruits_combo.options(text: 'Apple')[0].select
45
+ expect(fruits_combo.value).to be == 'Apple'
46
+
47
+ fruits_combo.options(text: 'Caimito')[0].select
48
+ expect(fruits_combo.value).to be == 'Caimito'
49
+ end
50
+
51
+ it 'enabled/disabled' do
52
+ expect(fruits_combo.enabled?).to be true
53
+ expect(fruits_combo.disabled?).to_not be true
54
+
55
+ expect(disabled_combo.enabled?).to_not be true
56
+ expect(disabled_combo.disabled?).to be true
57
+ end
58
+ end
59
+
60
+ it '#select' do
61
+ multi_fruits.select text: /ng/
62
+ expect(multi_fruits.values).to eq(['Orange', 'Mango'])
63
+ end
64
+
65
+ it '#clear' do
66
+ multi_fruits.select # select all
67
+ multi_fruits.clear text: 'Orange'
68
+ expect(multi_fruits.values).to eq(['Apple', 'Mango'])
69
+ end
70
+
71
+ it '#values' do
72
+ expect(multi_fruits.values).to eq([]) # => empty state
73
+
74
+ ['Apple', 'Mango'].each do |value|
75
+ multi_fruits.option(text: value).select
76
+ end
77
+ expect(multi_fruits.values).to eq(['Apple', 'Mango'])
78
+ end
79
+
80
+ it '#option' do
81
+ expect(fruits_combo.option(text: 'Apple').selected?).to_not be true
82
+ fruits_combo.option(index: 0).set
83
+ expect(fruits_combo.option(text: 'Apple').selected?).to be true
84
+ end
85
+
86
+ it '#options' do
87
+ expect(fruits_combo.options.size).to be == 5
88
+ expect(fruits_combo.options.map(&:text)).to eq(['Apple', 'Caimito', 'Coconut', 'Orange', 'Passion Fruit'])
89
+
90
+ expect(fruits_combo.options(text: 'Apple').map(&:text)).to eq ['Apple']
91
+ expect(fruits_combo.options(text: /Ap{2}le/).map(&:text)).to eq ['Apple']
92
+ expect(fruits_combo.options(index: 0).map(&:text)).to eq ['Apple']
93
+ end
94
+
95
+ it 'cannot select anything on a disabled select list' do
96
+ expect { disabled_combo.option(text: 'Apple').set }.to raise_error(RuntimeError)
97
+ end
98
+
99
+ it 'fires change event when the value is set' do
100
+ apple_option = fruits_combo.option(text: 'Apple')
101
+ expect(apple_option.selected?).to_not be true
102
+ apple_option.select
103
+ expect(apple_option.selected?).to be true
104
+
105
+ RAutomation::WaitHelper.wait_until { fruit_label.exist? }
106
+ expect(fruit_label.value).to be == 'Apple'
107
+ end
108
+
109
+ it 'fires change event when the index changes' do
110
+ fruits_combo.options[4].select
111
+ expect(fruits_combo.option(text: 'Passion Fruit').selected?).to be true
112
+ expect(fruit_label.value).to be == 'Passion Fruit'
113
+
114
+ fruits_combo.options[3].select
115
+ expect(fruits_combo.option(text: 'Orange').selected?).to be true
116
+ expect(fruit_label.value).to be == 'Orange'
117
+ end
118
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ include RAutomation::Adapter
4
+
5
+ describe MsUia::Spinner, if: SpecHelper.adapter == :ms_uia do
6
+ let(:main_window) { RAutomation::Window.new(title: 'MainFormWindow') }
7
+ let(:data_entry) { main_window.button(value: 'Data Entry Form').click { window.exist? } }
8
+ let(:window) { RAutomation::Window.new(title: 'DataEntryForm') }
9
+
10
+ subject { window.spinner(id: 'numericUpDown1') }
11
+
12
+ before(:each) do
13
+ data_entry
14
+ end
15
+
16
+ it { should exist }
17
+
18
+ it '#set' do
19
+ subject.set 4.0
20
+ expect(subject.value).to eq(4.0)
21
+ end
22
+
23
+ it '#minimum' do
24
+ expect(subject.minimum).to eq(-100.0)
25
+ end
26
+
27
+ it '#maximum' do
28
+ expect(subject.maximum).to eq(100.0)
29
+ end
30
+
31
+ it 'likes for values to be within range' do
32
+ expect { subject.set(1000.0) }.to raise_error(RuntimeError)
33
+ end
34
+
35
+ it '#increment' do
36
+ subject.set 5.0
37
+ expect(subject.increment).to eq(6.0)
38
+ end
39
+
40
+ it '#decrement' do
41
+ subject.set 5.0
42
+ expect(subject.decrement).to eq(4.0)
43
+ end
44
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ include RAutomation::Adapter
4
+
5
+ describe MsUia::TabControl, if: SpecHelper.adapter == :ms_uia do
6
+ let(:window) { RAutomation::Window.new(title: 'MainFormWindow') }
7
+ let(:about) { RAutomation::Window.new(title: 'About') }
8
+ subject { about.tab_control(id: 'tabControl') }
9
+
10
+ before(:each) do
11
+ window.button(value: 'About').click { true }
12
+ end
13
+
14
+ it { should exist }
15
+
16
+ it '#select' do
17
+ subject.select(1)
18
+ expect(subject.value).to eq('More Info')
19
+ end
20
+
21
+ it '#set' do
22
+ subject.set 'More Info'
23
+ expect(subject.value).to eq('More Info')
24
+ end
25
+
26
+ it 'has tab items' do
27
+ expect(subject.items.count).to eq(3)
28
+ end
29
+
30
+ it 'knows the current tab' do
31
+ expect(subject.value).to eq('Info')
32
+ end
33
+
34
+ context('#items') do
35
+ it 'has text' do
36
+ expect(subject.items.map(&:text)).to eq(['Info', 'More Info', 'Multi-Select ListBox'])
37
+ end
38
+
39
+ it 'has indices' do
40
+ expect(subject.items.map(&:index)).to eq([0, 1, 2])
41
+ end
42
+
43
+ it 'can be selected' do
44
+ subject.items.find {|t| t.text == 'More Info'}.select
45
+ expect(subject.value).to eq('More Info')
46
+ end
47
+
48
+ it 'knows if it is selected' do
49
+ expect(subject.items.first.selected?).to be true
50
+ expect(subject.items.last.selected?).to_not be true
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,197 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'MsUia::Table', if: SpecHelper.adapter == :ms_uia do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ let(:data_entry) { RAutomation::Window.new(title: "DataEntryForm") }
6
+ let(:data_grid_view) { window.button(value: 'Data Grid View').click {true}; RAutomation::Window.new(title: /DataGridView/) }
7
+ let(:large_grid) { data_entry.close; data_grid_view.table(id: 'dataGridView1') }
8
+ let(:table) { data_entry.table(id: "personListView") }
9
+ let(:toggle_multi_select) { data_entry.button(value: 'Toggle Multi').click { true } }
10
+
11
+ before :each do
12
+ window.button(value: "Data Entry Form").click { RAutomation::Window.new(title: "DataEntryForm").exists? }
13
+ end
14
+
15
+ it "#table" do
16
+ expect(table.exist?).to be true
17
+
18
+ RAutomation::Window.wait_timeout = 0.1
19
+ expect {RAutomation::Window.new(title: "non-existent-window").
20
+ table(class: /SysListView32/i)}.
21
+ to raise_exception(RAutomation::UnknownWindowException)
22
+ end
23
+
24
+ it "check for table class" do
25
+ expect(RAutomation::Window.new(title: "DataEntryForm").table(id: "deleteItemButton").exist?).to_not be true
26
+ end
27
+
28
+ it "#strings" do
29
+ table = RAutomation::Window.new(title: "MainFormWindow").table(id: "FruitListBox")
30
+
31
+ expect(table.strings).to be == ["Apple", "Orange", "Mango"]
32
+ end
33
+
34
+ it "#strings with nested elements" do
35
+
36
+ expect(table.strings).to be == [
37
+ ["Name", "Date of birth", "State"],
38
+ ["John Doe", "12/15/1967", "FL"],
39
+ ["Anna Doe", "3/4/1975", ""]
40
+ ]
41
+ end
42
+
43
+ it "#row_count" do
44
+ expect(table.row_count).to eq(2)
45
+ end
46
+
47
+ it '#select' do
48
+ large_grid.select(value: /^FirstName[1-9]$/)
49
+ first_nine = large_grid.rows.take(9)
50
+ expect(first_nine.count).to eq(9)
51
+ expect(first_nine.all?(&:selected?)).to be true
52
+ end
53
+
54
+ it '#clear' do
55
+ first_three = large_grid.rows.take(3)
56
+ next_six = large_grid.rows.take_while { |r| r.index.between?(3, 9) }
57
+ large_grid.select(value: /^FirstName[1-9]$/)
58
+
59
+ large_grid.clear(value: /^FirstName[1-3]$/)
60
+
61
+ expect(first_three.all?(&:selected?)).to be false
62
+ expect(next_six.all?(&:selected?)).to be true
63
+ end
64
+
65
+ it '#selected_rows' do
66
+ large_grid.select(value: /^FirstName[1-5]$/)
67
+ expect(large_grid.selected_rows.map(&:index)).to eq([0, 1, 2, 3, 4])
68
+ end
69
+
70
+ context "#rows" do
71
+ it "has rows" do
72
+ expect(table.rows.size).to eq(2)
73
+ end
74
+
75
+ it 'are quick to find' do
76
+ expect(large_grid.row_count).to eq(51)
77
+
78
+ start = Time.now
79
+ expect(large_grid.row(index: 50).exists?).to be true
80
+ expect((Time.now - start)).to be < 1.5
81
+ end
82
+
83
+ it "have values" do
84
+ expect(table.rows.map(&:value)).to eq(["John Doe", "Anna Doe"])
85
+ end
86
+
87
+ it "values are also text" do
88
+ expect(table.rows.map(&:text)).to eq(["John Doe", "Anna Doe"])
89
+ end
90
+
91
+ it "can be selected" do
92
+ row = table.row(index: 1)
93
+ row.select
94
+ expect(row.selected?).to be true
95
+ end
96
+
97
+ it "can be cleared" do
98
+ row = table.row(index: 1)
99
+ row.select
100
+
101
+ row.clear
102
+ expect(row.selected?).to_not be true
103
+ end
104
+
105
+ it "can select multiple rows" do
106
+ table.rows.each(&:select)
107
+ expect(table.rows.all?(&:selected?)).to be true
108
+ end
109
+
110
+ it "plays nice if the table does not support multiple selections" do
111
+ toggle_multi_select
112
+
113
+ first_row = table.rows.first
114
+ last_row = table.rows.last
115
+
116
+ first_row.select
117
+ last_row.select
118
+
119
+ expect(first_row.selected?).to_not be true
120
+ expect(last_row.selected?).to be true
121
+ end
122
+
123
+ context "locators" do
124
+ it "can locate by text" do
125
+ expect(table.rows(text: "Anna Doe").size).to eq(1)
126
+ end
127
+
128
+ it "can locate by regex" do
129
+ expect(table.rows(text: /Doe/).size).to eq(2)
130
+ end
131
+
132
+ it "can locate by index" do
133
+ expect(table.rows(index: 1).first.text).to eq("Anna Doe")
134
+ end
135
+
136
+ it "an index is also a row" do
137
+ expect(table.rows(row: 1).first.text).to eq("Anna Doe")
138
+ end
139
+ end
140
+
141
+ context "singular row" do
142
+ it "grabs the first by default" do
143
+ expect(table.row.text).to eq("John Doe")
144
+ end
145
+
146
+ it "can haz locators too" do
147
+ expect(table.row(text: "Anna Doe").text).to eq("Anna Doe")
148
+ end
149
+ end
150
+
151
+ context "Row#cells" do
152
+ let(:row) { table.row }
153
+
154
+ it "has cells" do
155
+ expect(row.cells.size).to eq(3)
156
+ end
157
+
158
+ it "cells have values" do
159
+ expect(row.cells.map(&:value)).to eq(["John Doe", "12/15/1967", "FL"])
160
+ end
161
+
162
+ it "values are also text" do
163
+ expect(row.cells.map(&:text)).to eq(["John Doe", "12/15/1967", "FL"])
164
+ end
165
+
166
+ context "locators" do
167
+ it "can locate by text" do
168
+ expect(row.cells(text: "FL").size).to eq(1)
169
+ end
170
+
171
+ it "can locate by regex" do
172
+ expect(row.cells(text: /[JF]/).size).to eq(2)
173
+ end
174
+
175
+ it "can locate by index" do
176
+ expect(row.cells(index: 1).first.text).to eq("12/15/1967")
177
+ end
178
+
179
+ it "an index is also a column" do
180
+ expect(row.cells(column: 1).first.text).to eq("12/15/1967")
181
+ end
182
+ end
183
+
184
+ context "singular cell" do
185
+ it "grabs the first by default" do
186
+ expect(row.cell.text).to eq("John Doe")
187
+ end
188
+
189
+ it "can haz locators too" do
190
+ expect(row.cell(text: "FL").text).to eq("FL")
191
+ end
192
+ end
193
+ end
194
+ end
195
+
196
+ end
197
+
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe "MsUia::TextField", if: SpecHelper.adapter == :ms_uia do
4
+ let(:main_form) { RAutomation::Window.new(title: "MainFormWindow") }
5
+
6
+ it "check for text field class" do
7
+ expect(main_form.text_field(id: "checkBox").exist?).to_not be true
8
+ expect(main_form.text_field(id: "textField").exist?).to be true
9
+ end
10
+
11
+ it "enabled/disabled" do
12
+ expect(main_form.text_field(id: "textField").enabled?).to be true
13
+ expect(main_form.text_field(id: "textField").disabled?).to_not be true
14
+
15
+ expect(main_form.text_field(id: "textBoxDisabled").enabled?).to_not be true
16
+ expect(main_form.text_field(id: "textBoxDisabled").disabled?).to be true
17
+ end
18
+
19
+ it "cannot set a value to a disabled text field" do
20
+ expect { main_form.text_field(id: "textBoxDisabled").set "abc" }.to raise_error(RuntimeError)
21
+
22
+ expect { main_form.text_field(id: "textBoxDisabled").clear }.to raise_error(RuntimeError)
23
+ end
24
+
25
+ it "considers a document control type a text field as well" do
26
+ # cause the .NET framework to be loaded into the process (required to make this fail)
27
+ main_form.select_list(id: "treeView").expand(0)
28
+ expect(main_form.text_field(id: "multiLineTextField").exist?).to be true
29
+ end
30
+
31
+ it "can set the value of a multi line text field" do
32
+ text_field = main_form.text_field(id: "multiLineTextField")
33
+
34
+ # initial
35
+ text_field.set("some dater'")
36
+ expect(text_field.value).to eq("some dater'")
37
+
38
+ # overwrite
39
+ text_field.set("overwrite with this dater'")
40
+ expect(text_field.value).to eq("overwrite with this dater'")
41
+ end
42
+
43
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe "MsUia::ValueControl", if: SpecHelper.adapter == :ms_uia do
4
+ let(:window) { RAutomation::Window.new(title: /MainFormWindow/) }
5
+ let(:value_control) { window.value_control(id: "automatableMonthCalendar1") }
6
+
7
+ it "can set and get values" do
8
+ value_control.set('12/25/2012')
9
+ expect(value_control.value).to eq('12/25/2012')
10
+ end
11
+ end
@@ -0,0 +1,81 @@
1
+ require "spec_helper"
2
+
3
+ describe "MsUia::Window", if: SpecHelper.adapter == :ms_uia do
4
+ let(:window) {RAutomation::Window.new(title: /MainFormWindow/i)}
5
+
6
+ it "move and click" do
7
+ window.maximize
8
+ window.move_mouse(62,46)
9
+ sleep 1
10
+ window.click_mouse
11
+ sleep 1
12
+ end
13
+
14
+ context "#send_keys" do
15
+ it "send tab keystrokes to move focus between elements" do
16
+ window.button(value: "About").focus
17
+ expect(window.button(value: "About").focused?).to be true
18
+
19
+ window.send_keys(:tab, :tab, :tab)
20
+ button = window.button(value: "Close")
21
+ expect(button.exist?).to be true
22
+ expect(button.focused?).to be true
23
+ end
24
+
25
+ it "send arbitrary characters and control keys" do
26
+ text_field = window.text_field(index: 2)
27
+ text_field.focus
28
+ window.send_keys("abc123ABChiHI!")
29
+ expect(text_field.value).to be == "abc123ABChiHI!"
30
+
31
+ window.send_keys(:space, "X")
32
+ expect(text_field.value).to be == "abc123ABChiHI! X"
33
+
34
+ window.send_keys([:control, "a"], :backspace)
35
+ expect(text_field.value.empty?).to be true
36
+ end
37
+ end
38
+
39
+ context "#control" do
40
+ it "by name" do
41
+ expect(window.control(name: "checkBox").exist?).to be true
42
+ end
43
+ end
44
+
45
+ context "menu items" do
46
+ let(:about_box) { RAutomation::Window.new title: "About" }
47
+
48
+ it "can select menu items" do
49
+ window.menu(text: "File").menu(text: "About").open
50
+ RAutomation::WaitHelper.wait_until { about_box.present? }
51
+ end
52
+
53
+ it "can select deep menu items" do
54
+ window.menu(text: "File")
55
+ .menu(text: "Roundabout Way")
56
+ .menu(text: "About").open
57
+ RAutomation::WaitHelper.wait_until { about_box.present? }
58
+ end
59
+
60
+ it "raises when errors occur" do
61
+ expect { window.menu(text: "File").menu(text: "Does Not Exist").open}.to raise_error(RuntimeError)
62
+ end
63
+
64
+ it "indicates if the menu item does not exist" do
65
+ begin
66
+ window.menu(text: "File").menu(text: "Should Not Exist").open
67
+ fail "Should have failed to find the menu item"
68
+ rescue Exception => e
69
+ expect(e.message).to match(/MenuItem with the text "Should Not Exist" does not exist/)
70
+ end
71
+ end
72
+
73
+ it "knows when menu items exist" do
74
+ expect(window.menu(text: "File").menu(text: "About").exists?).to be true
75
+ end
76
+
77
+ it "knows when menu items do not exist" do
78
+ expect(window.menu(text: "File").menu(text: "Missing").exists?).to_not be true
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::Button", if: SpecHelper.adapter == :win_32 do
4
+ it "enabled/disabled" do
5
+ window = RAutomation::Window.new(title: SpecHelper::DATA[:window1_title])
6
+
7
+ expect(window.button(value: "Enabled").enabled?).to be true
8
+ expect(window.button(value: "Enabled").disabled?).to be false
9
+
10
+ expect(window.button(value: "Disabled").enabled?).to be false
11
+ expect(window.button(value: "Disabled").disabled?).to be true
12
+ end
13
+
14
+ it "#focus" do
15
+ button = RAutomation::Window.new(title: SpecHelper::DATA[:window1_title]).button(value: "Enabled")
16
+ expect(button.focused?).to be false
17
+ button.focus
18
+ expect(button.focused?).to be true
19
+ end
20
+
21
+ it "cannot click disabled button" do
22
+ window = RAutomation::Window.new(title: SpecHelper::DATA[:window1_title])
23
+ expect { window.button(value: "Disabled").click }.to raise_error(RuntimeError)
24
+ end
25
+
26
+ it "cannot set focus to disabled button" do
27
+ window = RAutomation::Window.new(title: SpecHelper::DATA[:window1_title])
28
+ expect{ window.button(value: "Disabled").focus }.to raise_error(RuntimeError)
29
+ end
30
+
31
+ end