rautomation 2.0.1-x64-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,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::Checkbox", if: SpecHelper.adapter == :win_32 do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ it "#checkbox" do
6
+ expect(window.checkbox(value: "checkBox")).to exist
7
+
8
+ RAutomation::Window.wait_timeout = 0.1
9
+ expect { RAutomation::Window.new(title: "non-existing-window").checkbox(value: "Something") }.
10
+ to raise_exception(RAutomation::UnknownWindowException)
11
+ end
12
+
13
+ it "#set? & #set" do
14
+ checkbox = window.checkbox(value: "checkBox")
15
+ expect(checkbox.set?).to be false
16
+ checkbox.set
17
+ expect(checkbox.set?).to be true
18
+ end
19
+
20
+ it "#value" do
21
+ checkbox = window.checkbox(value: "checkBox")
22
+ expect(checkbox.value).to be == "checkBox"
23
+ end
24
+
25
+ it "#clear" do
26
+ checkbox = window.checkbox(value: "checkBox")
27
+ checkbox.set
28
+ expect(checkbox.set?).to be true
29
+
30
+ checkbox.clear
31
+ expect(checkbox.set?).to be false
32
+ end
33
+
34
+ it "enabled/disabled" do
35
+ expect(window.checkbox(value: "checkBox").enabled?).to be true
36
+ expect(window.checkbox(value: "checkBox").enabled?).to_not be false
37
+
38
+ expect(window.checkbox(value: "checkBoxDisabled").enabled?).to_not be true
39
+ expect(window.checkbox(value: "checkBoxDisabled").enabled?).to be false
40
+ end
41
+
42
+ it "cannot check a disabled checkbox" do
43
+ expect { window.checkbox(value: "checkBoxDisabled").set }.to raise_error(RuntimeError)
44
+ end
45
+
46
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::Label", if: SpecHelper.adapter == :win_32 do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ it "#exist?" do
6
+ expect(window.label(value: "This is a sample text")).to exist
7
+ expect(window.label(value: "This label should not exist")).to_not exist
8
+ end
9
+
10
+ it "#label" do
11
+ expect(window.label(value: "This is a sample text").value).to be == "This is a sample text"
12
+ end
13
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::ListBox", if: SpecHelper.adapter == :win_32 do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ it "#exists" do
6
+ expect(window.list_box(index: 0)).to exist
7
+ end
8
+
9
+ it "#count" do
10
+ expect(window.list_box(index: 0).count).to eq(3)
11
+ end
12
+
13
+ it "lists items" do
14
+ list_box = window.list_box(index: 0)
15
+ expect(list_box.items[0]).to be == "Apple"
16
+ expect(list_box.items[1]).to be == "Orange"
17
+ expect(list_box.items[2]).to be == "Mango"
18
+ end
19
+
20
+ it "#selected?" do
21
+ list_box = window.list_box(index: 0)
22
+ expect(list_box.selected?(2)).to_not be true
23
+ list_box.select(2)
24
+ expect(list_box.selected?(2)).to be true
25
+ end
26
+
27
+ it "#select" do
28
+ list_box = window.list_box(index: 0)
29
+ list_box.select(1)
30
+ expect(list_box.selected?(1)).to be true
31
+ list_box.select(0)
32
+ expect(list_box.selected?(0)).to be true
33
+ list_box.select(2)
34
+ expect(list_box.selected?(2)).to be true
35
+ end
36
+
37
+ it "#strings" do
38
+ list_box = window.list_box(index: 0)
39
+ expect(list_box.strings).to be == ["Apple", "Orange", "Mango"]
40
+ end
41
+ end
@@ -0,0 +1,49 @@
1
+ require "spec_helper"
2
+
3
+ describe "Win32::Mouse", if: SpecHelper.adapter == :win_32 do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ it "#click" do
6
+ popup = RAutomation::Window.new(title: "About")
7
+ expect(popup.present?).to_not be true
8
+
9
+ window.maximize
10
+ mouse = window.mouse
11
+ mouse.move(x: 60, y: 65)
12
+ mouse.click
13
+
14
+ RAutomation::WaitHelper.wait_until {popup.present?}
15
+ end
16
+
17
+ it "#position" do
18
+ mouse = window.mouse
19
+
20
+ mouse.move(x: 13, y: 16)
21
+ expect(mouse.position).to be == {x: 13, y: 16}
22
+ end
23
+
24
+ it "#press/#release" do
25
+ window.maximize
26
+
27
+ text_field = window.text_field(index: 2)
28
+ text_field.set("start string")
29
+ expect(text_field.value).to be == "start string"
30
+
31
+ mouse = window.mouse
32
+ mouse.move(x: 146, y: 125)
33
+ mouse.press
34
+ mouse.move(x: 194)
35
+ mouse.release
36
+ window.send_keys([:control, "c"])
37
+
38
+ text_field.set("new string")
39
+ expect(text_field.value).to be == "new string"
40
+
41
+ mouse.move(x: 146)
42
+ mouse.press
43
+ mouse.move(x: 194)
44
+ mouse.release
45
+ window.send_keys([:control, "v"])
46
+
47
+ expect(text_field.value).to be == "start string"
48
+ end
49
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::RadioButton", if: SpecHelper.adapter == :win_32 do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ it "#exist?" do
6
+ expect(window.radio(value: "Option 1")).to exist
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 "#set? & #set" do
15
+ radio = window.radio(value: "Option 1")
16
+ expect(radio.set?).to_not be true
17
+
18
+ radio.set
19
+ expect(radio.set?).to be true
20
+ end
21
+
22
+ it "enabled/disabled" do
23
+ expect(window.radio(value: "Option 1").enabled?).to be true
24
+ expect(window.radio(value: "Option 1").enabled?).to_not be false
25
+
26
+ expect(window.radio(value: "Option Disabled").enabled?).to_not be true
27
+ expect(window.radio(value: "Option Disabled").enabled?).to be false
28
+ end
29
+
30
+ it "cannot set a disabled radio button" do
31
+ expect { window.radio(value: "Option Disabled").set }.to raise_error(RuntimeError)
32
+ end
33
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::SelectList", if: SpecHelper.adapter == :win_32 do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ it "#select_list" do
6
+ expect(window.select_list(class: /combobox/i, index: 1)).to exist
7
+
8
+ RAutomation::Window.wait_timeout = 0.1
9
+ expect {RAutomation::Window.new(title: "non-existent-window").
10
+ select_list(class: /combobox/i, index: 1)}.
11
+ to raise_exception(RAutomation::UnknownWindowException)
12
+ end
13
+
14
+ it "#options" do
15
+ select_list = window.select_list(class: /combobox/i, index: 1)
16
+ expect(select_list.options.size).to eq(5)
17
+
18
+ expected_options = ["Apple", "Caimito", "Coconut", "Orange", "Passion Fruit"]
19
+ expect(select_list.options.map {|option| option.text}).to be == expected_options
20
+ end
21
+
22
+ it "#selected? & #select" do
23
+ select_list = window.select_list(class: /combobox/i, index: 1)
24
+ expect(select_list.options(text: "Apple")[0].selected?).to_not be true
25
+ expect(select_list.options(text: "Apple")[0].select).to be true
26
+ expect(select_list.options(text: "Apple")[0].selected?).to be true
27
+ end
28
+
29
+ it "#set" do
30
+ select_list = window.select_list(class: /combobox/i, index: 1)
31
+ expect(select_list.options(text: "Apple")[0].selected?).to_not be true
32
+ select_list.set("Apple")
33
+ expect(select_list.options(text: "Apple")[0].selected?).to be true
34
+ end
35
+
36
+ it "#value" do
37
+ select_list = window.select_list(class: /combobox/i, index: 1)
38
+
39
+ #default empty state
40
+ expect(select_list.value).to be == ""
41
+
42
+ select_list.options(text: "Apple")[0].select
43
+ expect(select_list.value).to be == "Apple"
44
+
45
+ select_list.options(text: "Caimito")[0].select
46
+ expect(select_list.value).to be == "Caimito"
47
+ end
48
+
49
+ it "enabled/disabled" do
50
+ expect(window.select_list(class: /combobox/i, index: 1).enabled?).to be true
51
+ expect(window.select_list(class: /combobox/i, index: 1).enabled?).to_not be false
52
+ end
53
+
54
+ it "#option" do
55
+ select_list = window.select_list(class: /combobox/i, index: 1)
56
+
57
+ expect(select_list.option(text: "Apple").selected?).to_not be true
58
+ select_list.option(text: "Apple").set
59
+ expect(select_list.option(text: "Apple").selected?).to be true
60
+ end
61
+
62
+ it "cannot select anything on a disabled select list" do
63
+ expect { window.select_list(id: "comboBoxDisabled").option(text: "Apple").set }.to raise_error(TypeError)
64
+ end
65
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::Table", if: SpecHelper.adapter == :win_32 do
4
+ before :each do
5
+ window = RAutomation::Window.new(title: "MainFormWindow")
6
+ window.button(value: "Data Entry Form").click { RAutomation::Window.new(title: "DataEntryForm").exists? }
7
+ end
8
+
9
+ it "#table" do
10
+ table = RAutomation::Window.new(title: "DataEntryForm").table
11
+ expect(table).to exist
12
+
13
+ RAutomation::Window.wait_timeout = 0.1
14
+ expect {RAutomation::Window.new(title: "non-existent-window").
15
+ table(class: /SysListView32/i)}.
16
+ to raise_exception(RAutomation::UnknownWindowException)
17
+ end
18
+
19
+ it "#select" do
20
+ table = RAutomation::Window.new(title: "DataEntryForm").table
21
+ expect(table.selected?(2)).to_not be true
22
+ table.select(2)
23
+ expect(table.selected?(2)).to be true
24
+ end
25
+
26
+ end
27
+
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::TextField", if: SpecHelper.adapter == :win_32 do
4
+ let(:window) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ it "enabled/disabled" do
6
+ expect(window.text_field(index: 2).enabled?).to be true
7
+ expect(window.text_field(index: 2).enabled?).to_not be false
8
+ end
9
+
10
+ it "cannot set a value to a disabled text field" do
11
+ expect { window.text_field(index: 1).set("abc") }.to raise_error(RuntimeError)
12
+ expect { window.text_field(index: 1).clear }.to raise_error(RuntimeError)
13
+ end
14
+
15
+ it "#send_keys" do
16
+ text_field = window.text_field(index: 2)
17
+ text_field.send_keys("abc")
18
+ expect(text_field.value).to be == "abc"
19
+
20
+ text_field.send_keys([:control, "a"], :backspace)
21
+ expect(text_field.value.empty?).to be true
22
+ end
23
+
24
+ end
@@ -0,0 +1,61 @@
1
+ require "spec_helper"
2
+
3
+ describe "Win32::Window", if: SpecHelper.adapter == :win_32 do
4
+ let(:window) {RAutomation::Window.new(title: /MainFormWindow/i)}
5
+
6
+ context "#send_keys" do
7
+ it "send tab keystrokes to move focus between elements" do
8
+ window.button(value: "&About").focus
9
+ expect(window.button(value: "&About").focused?).to be true
10
+
11
+ window.send_keys(:tab, :tab, :tab)
12
+ button = window.button(value: "Close")
13
+ expect(button).to exist
14
+ expect(button.focused?).to be true
15
+ end
16
+
17
+ it "send arbitrary characters and control keys" do
18
+ text_field = window.text_field(index: 2)
19
+ text_field.focus
20
+ arbitrary_str = "abc123ABChiHI!@#$%^&*()-_+=[{]}\\|;:'\",<.>/?`~"
21
+ window.send_keys(arbitrary_str)
22
+ expect(text_field.value).to be == arbitrary_str
23
+
24
+ window.send_keys(:space, "X")
25
+ expect(text_field.value).to be == "#{arbitrary_str} X"
26
+
27
+ window.send_keys([:control, "a"], :backspace)
28
+ expect(text_field.value.empty?).to be true
29
+ end
30
+ end
31
+
32
+ it "#control" do
33
+ expect(window.control(value: "&About")).to exist
34
+ end
35
+
36
+ it "#controls" do
37
+ expect(window.controls(class: /button/i).size).to eq(13)
38
+ end
39
+
40
+ context "#move" do
41
+ it "width=500, height=400, left=10, top=0" do
42
+ window.move(width: 500, height: 400, left: 10, top: 0)
43
+ coords = window.dimensions
44
+ expect(coords[:width]).to eq(500)
45
+ expect(coords[:height]).to eq(400)
46
+ expect(coords[:left]).to eq(10)
47
+ expect(coords[:top]).to eq(0)
48
+ end
49
+
50
+ it "uses default dimensions if not specified" do
51
+ coords = window.dimensions
52
+ window.move(width: 253, left: 26)
53
+
54
+ new_coords = window.dimensions
55
+ expect(new_coords[:width]).to eq(253)
56
+ expect(new_coords[:left]).to eq(26)
57
+ expect(new_coords[:top]).to eq(coords[:top])
58
+ expect(new_coords[:height]).to eq(coords[:height])
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe RAutomation::Button do
4
+ it "#button" do
5
+ expect(RAutomation::Window.new(title: SpecHelper::DATA[:window1_title]).button(value: "Close")).to exist
6
+
7
+ RAutomation::Window.wait_timeout = 0.1
8
+ expect {RAutomation::Window.new(title: "non-existing-window").button(value: "Something")}.
9
+ to raise_exception(RAutomation::UnknownWindowException)
10
+ end
11
+
12
+ it "#value" do
13
+ expect(RAutomation::Window.new(title: SpecHelper::DATA[:window1_title]).
14
+ button(value: "Close").value).to be == "Close"
15
+
16
+ RAutomation::Window.wait_timeout = 0.1
17
+ expect {RAutomation::Window.new(title: SpecHelper::DATA[:window1_title]).button(value: "non-existent-button").value}.
18
+ to raise_exception(RAutomation::UnknownButtonException)
19
+ end
20
+
21
+ it "#exists?" do
22
+ window = RAutomation::Window.new(title: SpecHelper::DATA[:window1_title])
23
+ expect(window.button(value: "Close")).to exist
24
+ expect(window.button(value: "non-existent-button")).not_to exist
25
+ end
26
+
27
+ it "clicking non-existing button raises exception" do
28
+ window = RAutomation::Window.new(title: SpecHelper::DATA[:window1_title])
29
+ RAutomation::Window.wait_timeout = 0.1
30
+ expect {window.button(value: "non-existent-button").click}.
31
+ to raise_exception(RAutomation::UnknownButtonException)
32
+ end
33
+
34
+ it "#click" do
35
+ window = RAutomation::Window.new(title: SpecHelper::DATA[:window1_title])
36
+
37
+ button = window.button(value: "Close")
38
+ expect(button).to exist
39
+ button.click
40
+
41
+ expect(button).not_to exist
42
+ RAutomation::WaitHelper.wait_until { !window.exists? }
43
+ end
44
+
45
+ it "#click with a block for defining successful click returning false raises a TimeoutError" do
46
+ window = RAutomation::Window.new(title: SpecHelper::DATA[:window1_title])
47
+ RAutomation::Window.wait_timeout = 5
48
+ button = window.button(value: "Close")
49
+ expect {button.click {false}}.
50
+ to raise_exception(RAutomation::WaitHelper::TimeoutError)
51
+
52
+ expect(button).not_to exist
53
+ expect(window).not_to exist
54
+ end
55
+
56
+ it "#click with a block for defining successful click returning true" do
57
+ RAutomation::Window.wait_timeout = 10
58
+ window = RAutomation::Window.new(title: SpecHelper::DATA[:window1_title])
59
+ button = window.button(value: "Close")
60
+ expect(button).to exist
61
+ button.click {|button| !button.exists? && !window.exists?}
62
+
63
+ expect(button).not_to exist
64
+ expect(window).not_to exist
65
+ end
66
+
67
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe RAutomation::Buttons do
4
+
5
+ it "Window#buttons returns all buttons" do
6
+ SpecHelper::navigate_to_simple_elements
7
+
8
+ buttons = RAutomation::Window.new(title: "SimpleElementsForm").buttons
9
+ expect(buttons.size).to eq(2)
10
+ expect(buttons.find_all {|b| b.value == 'button1'}.size).to eq(1)
11
+ end
12
+
13
+ it "Window#buttons with parameters returns all matching buttons" do
14
+ SpecHelper::navigate_to_simple_elements
15
+
16
+ buttons = RAutomation::Window.new(title: "SimpleElementsForm").buttons(value: 'button1')
17
+ expect(buttons.size).to eq(1)
18
+ expect(buttons.first.value).to eq('button1')
19
+ end
20
+
21
+ end
@@ -0,0 +1,128 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'rautomation'
3
+ require 'rspec'
4
+ require 'timeout'
5
+
6
+ module SpecHelper
7
+ # @private
8
+ def adapter
9
+ adapter = ENV["RAUTOMATION_ADAPTER"] && ENV["RAUTOMATION_ADAPTER"].to_sym || RAutomation::Adapter::Helper.default_adapter
10
+
11
+ if RAutomation::Adapter::Helper.supported_for_current_platform?(adapter)
12
+ adapter
13
+ else
14
+ :unsupported_platform
15
+ end
16
+ end
17
+
18
+ def navigate_to_simple_elements
19
+ main_window = RAutomation::Window.new(title: "MainFormWindow")
20
+ main_window.button(value: "Simple Elements").click { RAutomation::Window.new(title: "SimpleElementsForm").present? }
21
+ end
22
+
23
+ module_function :adapter, :navigate_to_simple_elements
24
+
25
+ # Since adapters are different then the windows to be tested
26
+ # might be different also.
27
+ #
28
+ # This constant allows to create input data for specs which could differ between the adapters.
29
+ #
30
+ # There has to be 2 windows:
31
+ # 1) Some random window, which is maximizable, minimizable, close'able and etc.
32
+ # 2) Browser window, which opens up a test.html where JavaScript prompt with a Button and a TextField objects will be shown.
33
+ DATA = {
34
+ # This adapter needs Windows OS with Internet Explorer installed into 'c:\program files\internet explorer'.
35
+ autoit: {
36
+ # Path to some binary, which opens up a window, what can be
37
+ # minimized, maximized, activated, closed and etc.
38
+ window1: "ext\\WindowsForms\\Release\\WindowsForms.exe",
39
+ window2: "notepad",
40
+ window2_title: /notepad/i,
41
+ # Window 1 title, has to be a Regexp.
42
+ window1_title: /FormWindow/i,
43
+ window1_full_title: 'MainFormWindow',
44
+ # Window 1 should have this text on it.
45
+ window1_text: "This is a sample text",
46
+ # When sending ENTER on Window 2, then the window OK button should be pressed and Window 2 should be closed.
47
+ # "A" key
48
+ window1_send_keys: "A",
49
+ proc_after_send_keys: lambda do
50
+ about_box = RAutomation::Window.new(title: /About/i)
51
+ RAutomation::WaitHelper.wait_until {about_box.present?}
52
+ end,
53
+ # Window 1 should have a button with the following text.
54
+ window1_button_text: "&About",
55
+ # Window 1 should have a text field with the specified class name.
56
+ window1_text_field_class: "Edit",
57
+ # Adapter internal method invocation for getting title of window2
58
+ title_proc: lambda {|win| win.WinGetTitle("[TITLE:MainFormWindow]")}
59
+ },
60
+ win_32: {
61
+ # Path to some binary, which opens up a window, what can be
62
+ # minimized, maximized, activated, closed and etc.
63
+ window1: "ext\\WindowsForms\\Release\\WindowsForms.exe",
64
+ window2: "notepad",
65
+ window2_title: /notepad/i,
66
+ # Window 1 title, has to be a Regexp.
67
+ window1_title: /FormWindow/i,
68
+ window1_full_title: 'MainFormWindow',
69
+ # Window 1 should have this text on it.
70
+ window1_text: "This is a sample text",
71
+ # When sending ENTER on Window 2, then the window OK button should be pressed and Window 2 should be closed.
72
+ # "A" key
73
+ window1_send_keys: "A",
74
+ proc_after_send_keys: lambda do
75
+ about_box = RAutomation::Window.new(title: /About/i)
76
+ RAutomation::WaitHelper.wait_until {about_box.present?}
77
+ end,
78
+ # Window 1 should have a button with the following text.
79
+ window1_button_text: "&About",
80
+ # Window 1 should have a text field with the specified class name.
81
+ window1_text_field_class: "Edit",
82
+ # Adapter internal method invocation for getting title of window2
83
+ title_proc: lambda {|win| win.window_title(win.hwnd)}
84
+ },
85
+ #Just copying :win_ffi data for now
86
+ ms_uia: {
87
+ # Path to some binary, which opens up a window, what can be
88
+ # minimized, maximized, activated, closed and etc.
89
+ window1: "ext\\WindowsForms\\Release\\WindowsForms.exe",
90
+ window2: "notepad",
91
+ window2_title: /notepad/i,
92
+ # Window 1 title, has to be a Regexp.
93
+ window1_title: /FormWindow/i,
94
+ window1_full_title: 'MainFormWindow',
95
+ # Window 1 should have this text on it.
96
+ window1_text: "This is a sample text",
97
+ # When sending ENTER on Window 2, then the window OK button should be pressed and Window 2 should be closed.
98
+ # "A" key
99
+ window1_send_keys: "A",
100
+ proc_after_send_keys: lambda do
101
+ about_box = RAutomation::Window.new(title: /About/i)
102
+ RAutomation::WaitHelper.wait_until {about_box.present?}
103
+ end,
104
+ # Window 1 should have a button with the following text.
105
+ window1_button_text: "&About",
106
+ # Window 1 should have a text field with the specified class name.
107
+ window1_text_field_class: "Edit",
108
+ # Adapter internal method invocation for getting title of window2
109
+ title_proc: lambda {|win| win.window_title(win.hwnd)}
110
+ }
111
+ }[adapter]
112
+ end
113
+
114
+
115
+ RSpec.configure do |config|
116
+ config.before(:each) do |example|
117
+ RAutomation::Window.wait_timeout = 15
118
+
119
+ unless example.metadata[:pure_unit]
120
+ @pid1 = IO.popen(SpecHelper::DATA[:window1]).pid
121
+ RAutomation::WaitHelper.wait_until { RAutomation::Window.new(pid: @pid1).present? }
122
+ end
123
+ end
124
+
125
+ config.after(:each) do
126
+ Process.kill(9, @pid1) rescue nil
127
+ end
128
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe RAutomation::TextField do
4
+ let(:main_form) { RAutomation::Window.new(title: "MainFormWindow") }
5
+ let(:text_field) { main_form.text_field(class: /Edit/i, index: 2) }
6
+
7
+ it "#text_field" do
8
+ expect(main_form.text_field(class: /Edit/i, index: 1).exist?).to be true
9
+
10
+ RAutomation::Window.wait_timeout = 0.1
11
+ expect { RAutomation::Window.new(title: "non-existent-window").
12
+ text_field(class: "Edit") }.
13
+ to raise_exception(RAutomation::UnknownWindowException)
14
+ end
15
+
16
+ it "#set" do
17
+ text_field.set"hello!"
18
+
19
+ RAutomation::Window.wait_timeout = 0.1
20
+ expect { main_form.text_field(class: "non-existing-field").set "hello!" }.
21
+ to raise_exception(RAutomation::UnknownTextFieldException)
22
+ end
23
+
24
+ it "#clear" do
25
+ text_field.set "hello!"
26
+ expect(text_field.value).to be == "hello!"
27
+ text_field.clear
28
+ expect(text_field.value.empty?).to be true
29
+
30
+ RAutomation::Window.wait_timeout = 0.1
31
+ expect { main_form.text_field(class: "non-existent-field").clear }.
32
+ to raise_exception(RAutomation::UnknownTextFieldException)
33
+ end
34
+
35
+ it "#value" do
36
+ text_field.set "hello!"
37
+ expect(text_field.value).to be == "hello!"
38
+
39
+ RAutomation::Window.wait_timeout = 0.1
40
+ expect { main_form.text_field(class: "non-existent-field").value }.
41
+ to raise_exception(RAutomation::UnknownTextFieldException)
42
+ end
43
+
44
+ it "#exists?" do
45
+ field = main_form.text_field(class: /Edit/i, index: 1)
46
+ expect(field.exist?).to be true
47
+ expect(main_form.text_field(class: "non-existent-field").exist?).to_not be true
48
+ end
49
+
50
+ it "#hwnd" do
51
+ field = main_form.text_field(class: /Edit/i, index: 1)
52
+ expect(field.hwnd).to be_a(Integer)
53
+
54
+ RAutomation::Window.wait_timeout = 0.1
55
+ expect { main_form.text_field(class: "non-existing-window").hwnd }.
56
+ to raise_exception(RAutomation::UnknownTextFieldException)
57
+ end
58
+
59
+ it "#hwnd locator" do
60
+ field = main_form.text_field(class: /Edit/i, index: 1)
61
+ expect(field.hwnd).to be_a(Integer)
62
+ expect(main_form.text_field(hwnd: field.hwnd).exist?).to be true
63
+ end
64
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe RAutomation::TextFields do
4
+
5
+ it "Window#text_fields returns all text fields" do
6
+ SpecHelper::navigate_to_simple_elements
7
+
8
+ text_fields = RAutomation::Window.new(title: "SimpleElementsForm").text_fields
9
+ expect(text_fields.size).to eq(2)
10
+ expect(text_fields.find_all {|t| t.value == "Enter some text"}.size).to eq(1)
11
+ end
12
+
13
+ it "Window#text_fields with parameters returns all matching text fields" do
14
+ SpecHelper::navigate_to_simple_elements
15
+
16
+ window = RAutomation::Window.new(title: "SimpleElementsForm")
17
+ text_fields = window.text_fields(index: 0)
18
+ expect(text_fields.size).to eq(2)
19
+ expect(text_fields.first.value).to be == "Enter some text"
20
+ end
21
+
22
+ end