rdp-rautomation 0.6.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/.document +5 -0
  2. data/.rspec +2 -0
  3. data/.yardopts +6 -0
  4. data/History.rdoc +103 -0
  5. data/LICENSE +20 -0
  6. data/README.rdoc +114 -0
  7. data/Rakefile +43 -0
  8. data/VERSION +1 -0
  9. data/ext/AutoItX/AutoItX.chm +0 -0
  10. data/ext/AutoItX/AutoItX3.dll +0 -0
  11. data/ext/IAccessibleDLL/IAccessibleDLL.sln +20 -0
  12. data/ext/IAccessibleDLL/IAccessibleDLL.suo +0 -0
  13. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.cpp +30 -0
  14. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj +102 -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/Release/IAccessibleDLL.dll +0 -0
  24. data/ext/ListViewExplorer/ListViewExplorer.sln +20 -0
  25. data/ext/ListViewExplorer/ListViewExplorer.suo +0 -0
  26. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.cpp +174 -0
  27. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj +95 -0
  28. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj.filters +42 -0
  29. data/ext/ListViewExplorer/ListViewExplorer/ListViewExplorer.vcxproj.user +3 -0
  30. data/ext/ListViewExplorer/ListViewExplorer/ReadMe.txt +40 -0
  31. data/ext/ListViewExplorer/ListViewExplorer/stdafx.cpp +8 -0
  32. data/ext/ListViewExplorer/ListViewExplorer/stdafx.h +17 -0
  33. data/ext/ListViewExplorer/ListViewExplorer/table_support.cpp +250 -0
  34. data/ext/ListViewExplorer/ListViewExplorer/table_support.h +2 -0
  35. data/ext/ListViewExplorer/ListViewExplorer/targetver.h +8 -0
  36. data/ext/UiaDll/Release/UiaDll.dll +0 -0
  37. data/ext/UiaDll/UiaDll.sln +20 -0
  38. data/ext/UiaDll/UiaDll.suo +0 -0
  39. data/ext/UiaDll/UiaDll/ReadMe.txt +48 -0
  40. data/ext/UiaDll/UiaDll/UiaDll.cpp +205 -0
  41. data/ext/UiaDll/UiaDll/UiaDll.vcxproj +104 -0
  42. data/ext/UiaDll/UiaDll/UiaDll.vcxproj.filters +42 -0
  43. data/ext/UiaDll/UiaDll/dllmain.cpp +39 -0
  44. data/ext/UiaDll/UiaDll/globals.h +3 -0
  45. data/ext/UiaDll/UiaDll/stdafx.cpp +8 -0
  46. data/ext/UiaDll/UiaDll/stdafx.h +19 -0
  47. data/ext/UiaDll/UiaDll/targetver.h +8 -0
  48. data/ext/WindowsForms/bin/WindowsForms.exe +0 -0
  49. data/ext/WindowsForms/src/WindowsForms/WindowsForms.sln +20 -0
  50. data/ext/WindowsForms/src/WindowsForms/WindowsForms.suo +0 -0
  51. data/ext/WindowsForms/src/WindowsForms/WindowsForms/AboutBox.Designer.cs +80 -0
  52. data/ext/WindowsForms/src/WindowsForms/WindowsForms/AboutBox.cs +103 -0
  53. data/ext/WindowsForms/src/WindowsForms/WindowsForms/AboutBox.resx +120 -0
  54. data/ext/WindowsForms/src/WindowsForms/WindowsForms/DataEntryForm.Designer.cs +187 -0
  55. data/ext/WindowsForms/src/WindowsForms/WindowsForms/DataEntryForm.cs +46 -0
  56. data/ext/WindowsForms/src/WindowsForms/WindowsForms/DataEntryForm.resx +120 -0
  57. data/ext/WindowsForms/src/WindowsForms/WindowsForms/MainFormWindow.Designer.cs +377 -0
  58. data/ext/WindowsForms/src/WindowsForms/WindowsForms/MainFormWindow.cs +78 -0
  59. data/ext/WindowsForms/src/WindowsForms/WindowsForms/MainFormWindow.resx +120 -0
  60. data/ext/WindowsForms/src/WindowsForms/WindowsForms/PersonForm.Designer.cs +119 -0
  61. data/ext/WindowsForms/src/WindowsForms/WindowsForms/PersonForm.cs +34 -0
  62. data/ext/WindowsForms/src/WindowsForms/WindowsForms/PersonForm.resx +120 -0
  63. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Program.cs +21 -0
  64. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/AssemblyInfo.cs +36 -0
  65. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/Resources.Designer.cs +71 -0
  66. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/Resources.resx +117 -0
  67. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/Settings.Designer.cs +30 -0
  68. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/Settings.settings +7 -0
  69. data/ext/WindowsForms/src/WindowsForms/WindowsForms/SimpleElementsForm.Designer.cs +93 -0
  70. data/ext/WindowsForms/src/WindowsForms/WindowsForms/SimpleElementsForm.cs +19 -0
  71. data/ext/WindowsForms/src/WindowsForms/WindowsForms/SimpleElementsForm.resx +120 -0
  72. data/ext/WindowsForms/src/WindowsForms/WindowsForms/WindowsForms.csproj +123 -0
  73. data/ext/WindowsForms/src/WindowsForms/WindowsForms/bin/Release/WindowsForms.exe +0 -0
  74. data/lib/rautomation.rb +6 -0
  75. data/lib/rautomation/adapter/autoit.rb +5 -0
  76. data/lib/rautomation/adapter/autoit/button.rb +59 -0
  77. data/lib/rautomation/adapter/autoit/locators.rb +22 -0
  78. data/lib/rautomation/adapter/autoit/text_field.rb +61 -0
  79. data/lib/rautomation/adapter/autoit/window.rb +184 -0
  80. data/lib/rautomation/adapter/helper.rb +20 -0
  81. data/lib/rautomation/adapter/win_ffi.rb +21 -0
  82. data/lib/rautomation/adapter/win_ffi/button.rb +25 -0
  83. data/lib/rautomation/adapter/win_ffi/button_helper.rb +24 -0
  84. data/lib/rautomation/adapter/win_ffi/checkbox.rb +19 -0
  85. data/lib/rautomation/adapter/win_ffi/constants.rb +94 -0
  86. data/lib/rautomation/adapter/win_ffi/control.rb +79 -0
  87. data/lib/rautomation/adapter/win_ffi/functions.rb +333 -0
  88. data/lib/rautomation/adapter/win_ffi/keystroke_converter.rb +67 -0
  89. data/lib/rautomation/adapter/win_ffi/label.rb +21 -0
  90. data/lib/rautomation/adapter/win_ffi/list_box.rb +60 -0
  91. data/lib/rautomation/adapter/win_ffi/locators.rb +22 -0
  92. data/lib/rautomation/adapter/win_ffi/ms_uia/uia_dll.rb +36 -0
  93. data/lib/rautomation/adapter/win_ffi/radio.rb +19 -0
  94. data/lib/rautomation/adapter/win_ffi/select_list.rb +87 -0
  95. data/lib/rautomation/adapter/win_ffi/table.rb +57 -0
  96. data/lib/rautomation/adapter/win_ffi/text_field.rb +52 -0
  97. data/lib/rautomation/adapter/win_ffi/window.rb +226 -0
  98. data/lib/rautomation/button.rb +55 -0
  99. data/lib/rautomation/element_collections.rb +47 -0
  100. data/lib/rautomation/text_field.rb +60 -0
  101. data/lib/rautomation/wait_helper.rb +23 -0
  102. data/lib/rautomation/window.rb +234 -0
  103. data/spec/adapter/win_ffi/button_spec.rb +41 -0
  104. data/spec/adapter/win_ffi/checkbox_spec.rb +48 -0
  105. data/spec/adapter/win_ffi/keystroke_converter_spec.rb +47 -0
  106. data/spec/adapter/win_ffi/label_spec.rb +21 -0
  107. data/spec/adapter/win_ffi/listbox_spec.rb +52 -0
  108. data/spec/adapter/win_ffi/radio_spec.rb +37 -0
  109. data/spec/adapter/win_ffi/select_list_spec.rb +66 -0
  110. data/spec/adapter/win_ffi/table_spec.rb +39 -0
  111. data/spec/adapter/win_ffi/text_field_spec.rb +23 -0
  112. data/spec/adapter/win_ffi/window_spec.rb +43 -0
  113. data/spec/button_spec.rb +68 -0
  114. data/spec/buttons_spec.rb +21 -0
  115. data/spec/spec_helper.rb +96 -0
  116. data/spec/text_field_spec.rb +65 -0
  117. data/spec/text_fields_spec.rb +22 -0
  118. data/spec/window_spec.rb +122 -0
  119. data/spec/windows_spec.rb +55 -0
  120. metadata +207 -0
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe "WinFfi::Checkbox", :if => SpecHelper.adapter == :win_ffi do
4
+ it "#checkbox" do
5
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBox").should exist
6
+
7
+ RAutomation::Window.wait_timeout = 0.1
8
+ expect {RAutomation::Window.new(:title => "non-existing-window").checkbox(:value => "Something")}.
9
+ to raise_exception(RAutomation::UnknownWindowException)
10
+ end
11
+
12
+ it "check for checkbox class" do
13
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "textField").should_not exist
14
+ end
15
+
16
+
17
+ it "#set? & #set" do
18
+ checkbox = RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBox")
19
+ checkbox.should_not be_set
20
+
21
+ checkbox.set
22
+ checkbox.should be_set
23
+ end
24
+
25
+ it "#clear" do
26
+ checkbox = RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBox")
27
+ checkbox.set
28
+ checkbox.should be_set
29
+
30
+ checkbox.clear
31
+ checkbox.should_not be_set
32
+ end
33
+
34
+ it "enabled/disabled" do
35
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "checkBox").should be_enabled
36
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "checkBox").should_not be_disabled
37
+
38
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "checkBoxDisabled").should_not be_enabled
39
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "checkBoxDisabled").should be_disabled
40
+ end
41
+
42
+ it "cannot check a disabled checkbox" do
43
+ lambda {
44
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:id => "checkBoxDisabled").set
45
+ }.should raise_error
46
+ end
47
+
48
+ end
@@ -0,0 +1,47 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'rautomation'
3
+ require 'rspec'
4
+
5
+ describe "KeystrokeConverter" do
6
+
7
+ it "converts plain ASCII" do
8
+ codes = RAutomation::Adapter::WinFfi::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::WinFfi::KeystrokeConverter.convert("aBc")
15
+ converted_keys = convert_keys "abc"
16
+ converted_keys = converted_keys.insert(1, RAutomation::Adapter::WinFfi::Constants::VK_LSHIFT)
17
+ codes.should == converted_keys
18
+ end
19
+
20
+ it "converts special keys" do
21
+ codes = RAutomation::Adapter::WinFfi::KeystrokeConverter.convert("{tab}a{backspace}b{enter}c {left}d{right}ee{down}f{up}g{unsupported}")
22
+ expected_codes = [
23
+ RAutomation::Adapter::WinFfi::Constants::VK_TAB,
24
+ convert_keys("a"),
25
+ RAutomation::Adapter::WinFfi::Constants::VK_BACK,
26
+ convert_keys("b"),
27
+ RAutomation::Adapter::WinFfi::Constants::VK_RETURN,
28
+ convert_keys("c"),
29
+ RAutomation::Adapter::WinFfi::Constants::VK_SPACE,
30
+ RAutomation::Adapter::WinFfi::Constants::VK_LEFT,
31
+ convert_keys("d"),
32
+ RAutomation::Adapter::WinFfi::Constants::VK_RIGHT,
33
+ convert_keys("ee"),
34
+ RAutomation::Adapter::WinFfi::Constants::VK_DOWN,
35
+ convert_keys("f"),
36
+ RAutomation::Adapter::WinFfi::Constants::VK_UP,
37
+ convert_keys("g"),
38
+ convert_keys("unsupported")
39
+ ].flatten
40
+ codes.should == expected_codes
41
+ end
42
+
43
+ def convert_keys keys
44
+ keys.split("").map {|k| k.upcase.unpack("c")[0]}
45
+ end
46
+
47
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe "WinFfi::Label", :if => SpecHelper.adapter == :win_ffi do
4
+ it "#exist?" do
5
+ window = RAutomation::Window.new(:title => "MainFormWindow")
6
+
7
+ window.label(:value => "This is a sample text").should exist
8
+ window.label(:value => "This label should not exist").should_not exist
9
+ end
10
+
11
+ it "check for label class" do
12
+ RAutomation::Window.new(:title => "MainFormWindow").label(:id => "textField").should_not exist
13
+ end
14
+
15
+
16
+ it "#label" do
17
+ window = RAutomation::Window.new(:title => "MainFormWindow")
18
+
19
+ window.label(:value => "This is a sample text").value.should == "This is a sample text"
20
+ end
21
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe "WinFfi::ListBox", :if => SpecHelper.adapter == :win_ffi do
4
+
5
+ it "#exists" do
6
+ RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox").should exist
7
+ end
8
+
9
+ it "check for listbox class" do
10
+ RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "textField").should_not exist
11
+ end
12
+
13
+ it "counts items" do
14
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
15
+ list_box.count.should == 3
16
+ end
17
+
18
+ it "lists items" do
19
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
20
+ list_box.items[0].should == "Apple"
21
+ list_box.items[1].should == "Orange"
22
+ list_box.items[2].should == "Mango"
23
+ end
24
+
25
+
26
+ it "#selected?" do
27
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
28
+
29
+ list_box.selected?(2).should == false
30
+ list_box.select(2)
31
+ list_box.selected?(2).should == true
32
+ end
33
+
34
+ it "#select" do
35
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
36
+
37
+ list_box.select(1)
38
+ list_box.selected?(1).should == true
39
+
40
+ list_box.select(0)
41
+ list_box.selected?(0).should == true
42
+
43
+ list_box.select(2)
44
+ list_box.selected?(2).should == true
45
+ end
46
+
47
+ it "#strings" do
48
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:id => "FruitListBox")
49
+
50
+ list_box.strings.should == ["Apple", "Orange", "Mango"]
51
+ end
52
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe "WinFfi::RadioButton", :if => SpecHelper.adapter == :win_ffi do
4
+ it "#exist?" do
5
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option 1").should exist
6
+
7
+ RAutomation::Window.wait_timeout = 0.1
8
+ expect {RAutomation::Window.new(:title => "non-existent-window").
9
+ radio(:value => "Option 1")}.
10
+ to raise_exception(RAutomation::UnknownWindowException)
11
+ end
12
+
13
+ it "check for radio class" do
14
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:id => "textField").should_not exist
15
+ end
16
+
17
+
18
+ it "#set? & #set" do
19
+ radio = RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option 1")
20
+ radio.should_not be_set
21
+
22
+ radio.set
23
+ radio.should be_set
24
+ end
25
+
26
+ it "enabled/disabled" do
27
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option 1").should be_enabled
28
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option 1").should_not be_disabled
29
+
30
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option Disabled").should_not be_enabled
31
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option Disabled").should be_disabled
32
+ end
33
+
34
+ it "cannot set a disabled radio button" do
35
+ lambda { RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option Disabled").set }.should raise_error
36
+ end
37
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe "WinFfi::SelectList", :if => SpecHelper.adapter == :win_ffi 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
+ end
16
+
17
+ it "#options" do
18
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
19
+ select_list.options.size.should == 5
20
+
21
+ expected_options = ["Apple", "Caimito", "Coconut", "Orange", "Passion Fruit"]
22
+ select_list.options.map {|option| option.text}.should == expected_options
23
+ end
24
+
25
+ it "#selected? & #select" do
26
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
27
+ select_list.options(:text => "Apple")[0].should_not be_selected
28
+ select_list.options(:text => "Apple")[0].select.should be_true
29
+ select_list.options(:text => "Apple")[0].should be_selected
30
+ end
31
+
32
+ it "#value" do
33
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
34
+
35
+ #default empty state
36
+ select_list.value.should == ""
37
+
38
+ select_list.options(:text => "Apple")[0].select
39
+ select_list.value.should == "Apple"
40
+
41
+ select_list.options(:text => "Caimito")[0].select
42
+ select_list.value.should == "Caimito"
43
+ end
44
+
45
+ it "enabled/disabled" do
46
+ RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox").should be_enabled
47
+ RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox").should_not be_disabled
48
+
49
+ RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "comboBoxDisabled").should_not be_enabled
50
+ RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "comboBoxDisabled").should be_disabled
51
+ end
52
+
53
+ it "#option" do
54
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
55
+
56
+ select_list.option(:text => "Apple").should_not be_selected
57
+ select_list.option(:text => "Apple").set
58
+ select_list.option(:text => "Apple").should be_selected
59
+ end
60
+
61
+ it "cannot select anything on a disabled select list" do
62
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "comboBoxDisabled")
63
+
64
+ lambda { select_list.option(:text => "Apple").set }.should raise_error
65
+ end
66
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe "WinFfi::Table", :if => SpecHelper.adapter == :win_ffi 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(:id => "personListView")
11
+ table.should 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 "#strings" do
20
+ table = RAutomation::Window.new(:title => "DataEntryForm").table(:id => "personListView")
21
+
22
+ table.strings.should == [
23
+ ["Name", "Date of birth", "State"],
24
+ ["John Doe", "12/15/1967", "FL"],
25
+ ["Anna Doe", "3/4/1975", ""]
26
+ ]
27
+ end
28
+
29
+ it "#select" do
30
+ table = RAutomation::Window.new(:title => "DataEntryForm").table(:id => "personListView")
31
+
32
+ table.selected?(2).should == false
33
+
34
+ table.select(2)
35
+ table.selected?(2).should == true
36
+ end
37
+
38
+ end
39
+
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe "WinFfi::TextField", :if => SpecHelper.adapter == :win_ffi do
4
+
5
+ it "check for text field class" do
6
+ RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "checkBox").should_not exist
7
+ end
8
+
9
+ it "enabled/disabled" do
10
+ RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textField").should be_enabled
11
+ RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textField").should_not be_disabled
12
+
13
+ RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textBoxDisabled").should_not be_enabled
14
+ RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textBoxDisabled").should be_disabled
15
+ end
16
+
17
+ it "cannot set a value to a disabled text field" do
18
+ lambda { RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textBoxDisabled").set "abc" }.should raise_error
19
+
20
+ lambda { RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textBoxDisabled").clear }.should raise_error
21
+ end
22
+
23
+ end
@@ -0,0 +1,43 @@
1
+ require "spec_helper"
2
+
3
+ describe "WinFfi::Window", :if => SpecHelper.adapter == :win_ffi do
4
+ it "#child" do
5
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
6
+ window.should exist
7
+
8
+ # buttons are windows too. so let's find the button for now
9
+ child = window.child(:title => /About/i)
10
+ child.should exist
11
+ child.title.should == "&About"
12
+ # child.text.should include "About"
13
+ end
14
+
15
+ it "send tab keystrokes to move focus between elements" do
16
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
17
+ window.button(:value => "&About").set_focus
18
+ window.button(:value => "&About").should have_focus
19
+
20
+ window.send_keys("{tab}{tab}{tab}")
21
+ button = window.button(:value => "Close")
22
+ button.should exist
23
+ button.should have_focus
24
+ end
25
+
26
+ it "send keystrokes to a text field" do
27
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
28
+ text_field = RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textField")
29
+ text_field.set_focus
30
+ window.send_keys("abc123ABChiHI")
31
+ text_field.value.should == "abc123ABChiHI"
32
+ end
33
+
34
+ it "#control" do
35
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
36
+ window.control(:id => "aboutButton").should exist
37
+ end
38
+
39
+ it "has controls" do
40
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
41
+ window.controls(:class => /BUTTON/i).size.should == 12
42
+ end
43
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe RAutomation::Button do
4
+ it "#button" do
5
+ RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).
6
+ button(:value => "Close").should exist
7
+
8
+ RAutomation::Window.wait_timeout = 0.1
9
+ expect {RAutomation::Window.new(:title => "non-existing-window").button(:value => "Something")}.
10
+ to raise_exception(RAutomation::UnknownWindowException)
11
+ end
12
+
13
+ it "#value" do
14
+ RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).
15
+ button(:value => "Close").value.should == "Close"
16
+
17
+ RAutomation::Window.wait_timeout = 0.1
18
+ expect {RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).button(:value => "non-existent-button").value}.
19
+ to raise_exception(RAutomation::UnknownButtonException)
20
+ end
21
+
22
+ it "#exists?" do
23
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
24
+ window.button(:value => "Close").should exist
25
+ window.button(:value => "non-existent-button").should_not exist
26
+ end
27
+
28
+ it "clicking non-existing button raises exception" do
29
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
30
+ RAutomation::Window.wait_timeout = 0.1
31
+ expect {window.button(:value => "non-existent-button").click}.
32
+ to raise_exception(RAutomation::UnknownButtonException)
33
+ end
34
+
35
+ it "#click" do
36
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
37
+
38
+ button = window.button(:value => "Close")
39
+ button.should exist
40
+ button.click
41
+
42
+ button.should_not exist
43
+ window.should_not exist
44
+ end
45
+
46
+ it "#click with a block for defining successful click returning false raises a TimeoutError" do
47
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
48
+ RAutomation::Window.wait_timeout = 5
49
+ button = window.button(:value => "Close")
50
+ expect {button.click {false}}.
51
+ to raise_exception(RAutomation::WaitHelper::TimeoutError)
52
+
53
+ button.should_not exist
54
+ window.should_not exist
55
+ end
56
+
57
+ it "#click with a block for defining successful click returning true" do
58
+ RAutomation::Window.wait_timeout = 10
59
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
60
+ button = window.button(:value => "Close")
61
+ button.should exist
62
+ button.click {|button| !button.exists? && !window.exists?}
63
+
64
+ button.should_not exist
65
+ window.should_not exist
66
+ end
67
+
68
+ end