rautomation 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/.gitignore +34 -0
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +24 -0
  4. data/History.rdoc +21 -0
  5. data/LICENSE +1 -1
  6. data/README.rdoc +8 -7
  7. data/Rakefile +22 -32
  8. data/VERSION +1 -1
  9. data/ext/UiaDll/Release/UiaDll.dll +0 -0
  10. data/ext/UiaDll/UiaDll.suo +0 -0
  11. data/ext/UiaDll/UiaDll/UiaDll.cpp +236 -10
  12. data/lib/rautomation/adapter/autoit/locators.rb +1 -1
  13. data/lib/rautomation/adapter/autoit/text_field.rb +10 -1
  14. data/lib/rautomation/adapter/autoit/window.rb +50 -23
  15. data/lib/rautomation/adapter/helper.rb +6 -6
  16. data/lib/rautomation/adapter/ms_uia.rb +22 -0
  17. data/lib/rautomation/adapter/{win_ffi → ms_uia}/button.rb +3 -2
  18. data/lib/rautomation/adapter/ms_uia/button_helper.rb +25 -0
  19. data/lib/rautomation/adapter/ms_uia/checkbox.rb +27 -0
  20. data/lib/rautomation/adapter/{win_ffi → ms_uia}/constants.rb +20 -5
  21. data/lib/rautomation/adapter/ms_uia/control.rb +180 -0
  22. data/lib/rautomation/adapter/{win_ffi → ms_uia}/functions.rb +24 -26
  23. data/lib/rautomation/adapter/ms_uia/keystroke_converter.rb +122 -0
  24. data/lib/rautomation/adapter/{win_ffi → ms_uia}/label.rb +3 -2
  25. data/lib/rautomation/adapter/ms_uia/list_box.rb +91 -0
  26. data/lib/rautomation/adapter/ms_uia/list_item.rb +49 -0
  27. data/lib/rautomation/adapter/ms_uia/locators.rb +23 -0
  28. data/lib/rautomation/adapter/{win_ffi → ms_uia}/radio.rb +2 -2
  29. data/lib/rautomation/adapter/{win_ffi → ms_uia}/select_list.rb +41 -7
  30. data/lib/rautomation/adapter/ms_uia/table.rb +86 -0
  31. data/lib/rautomation/adapter/{win_ffi → ms_uia}/text_field.rb +5 -4
  32. data/lib/rautomation/adapter/ms_uia/uia_dll.rb +62 -0
  33. data/lib/rautomation/adapter/ms_uia/window.rb +364 -0
  34. data/lib/rautomation/adapter/win_32.rb +21 -0
  35. data/lib/rautomation/adapter/win_32/button.rb +14 -0
  36. data/lib/rautomation/adapter/{win_ffi → win_32}/button_helper.rb +1 -1
  37. data/lib/rautomation/adapter/win_32/checkbox.rb +14 -0
  38. data/lib/rautomation/adapter/win_32/constants.rb +68 -0
  39. data/lib/rautomation/adapter/{win_ffi → win_32}/control.rb +30 -23
  40. data/lib/rautomation/adapter/win_32/functions.rb +313 -0
  41. data/lib/rautomation/adapter/win_32/keys.rb +121 -0
  42. data/lib/rautomation/adapter/win_32/label.rb +10 -0
  43. data/lib/rautomation/adapter/win_32/list_box.rb +40 -0
  44. data/lib/rautomation/adapter/{win_ffi → win_32}/locators.rb +2 -2
  45. data/lib/rautomation/adapter/win_32/radio.rb +11 -0
  46. data/lib/rautomation/adapter/win_32/select_list.rb +97 -0
  47. data/lib/rautomation/adapter/win_32/table.rb +22 -0
  48. data/lib/rautomation/adapter/win_32/text_field.rb +42 -0
  49. data/lib/rautomation/adapter/{win_ffi → win_32}/window.rb +79 -62
  50. data/lib/rautomation/element_collections.rb +9 -1
  51. data/lib/rautomation/window.rb +17 -9
  52. data/rautomation.gemspec +24 -0
  53. data/spec/adapter/autoit/window_spec.rb +71 -0
  54. data/spec/adapter/{win_ffi → ms_uia}/button_spec.rb +1 -1
  55. data/spec/adapter/{win_ffi → ms_uia}/checkbox_spec.rb +9 -3
  56. data/spec/adapter/ms_uia/control_spec.rb +28 -0
  57. data/spec/adapter/ms_uia/keystroke_converter_spec.rb +50 -0
  58. data/spec/adapter/{win_ffi → ms_uia}/label_spec.rb +2 -2
  59. data/spec/adapter/ms_uia/list_item_spec.rb +14 -0
  60. data/spec/adapter/{win_ffi → ms_uia}/listbox_spec.rb +18 -5
  61. data/spec/adapter/{win_ffi → ms_uia}/radio_spec.rb +3 -1
  62. data/spec/adapter/ms_uia/select_list_spec.rb +109 -0
  63. data/spec/adapter/{win_ffi → ms_uia}/table_spec.rb +12 -1
  64. data/spec/adapter/{win_ffi → ms_uia}/text_field_spec.rb +2 -1
  65. data/spec/adapter/ms_uia/window_spec.rb +89 -0
  66. data/spec/adapter/win_32/button_spec.rb +30 -0
  67. data/spec/adapter/win_32/checkbox_spec.rb +48 -0
  68. data/spec/adapter/win_32/label_spec.rb +15 -0
  69. data/spec/adapter/win_32/listbox_spec.rb +42 -0
  70. data/spec/adapter/win_32/radio_spec.rb +32 -0
  71. data/spec/adapter/{win_ffi → win_32}/select_list_spec.rb +16 -16
  72. data/spec/adapter/win_32/table_spec.rb +28 -0
  73. data/spec/adapter/win_32/text_field_spec.rb +24 -0
  74. data/spec/adapter/{win_ffi → win_32}/window_spec.rb +19 -14
  75. data/spec/button_spec.rb +1 -0
  76. data/spec/buttons_spec.rb +4 -4
  77. data/spec/spec_helper.rb +30 -4
  78. data/spec/text_field_spec.rb +6 -7
  79. data/spec/window_spec.rb +12 -0
  80. data/spec/windows_spec.rb +19 -0
  81. metadata +116 -97
  82. data/lib/rautomation/adapter/win_ffi.rb +0 -21
  83. data/lib/rautomation/adapter/win_ffi/checkbox.rb +0 -19
  84. data/lib/rautomation/adapter/win_ffi/keystroke_converter.rb +0 -67
  85. data/lib/rautomation/adapter/win_ffi/list_box.rb +0 -60
  86. data/lib/rautomation/adapter/win_ffi/ms_uia/uia_dll.rb +0 -36
  87. data/lib/rautomation/adapter/win_ffi/table.rb +0 -57
  88. data/spec/adapter/win_ffi/keystroke_converter_spec.rb +0 -47
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "WinFfi::Table", :if => SpecHelper.adapter == :win_ffi do
3
+ describe "MsUia::Table", :if => SpecHelper.adapter == :ms_uia do
4
4
  before :each do
5
5
  window = RAutomation::Window.new(:title => "MainFormWindow")
6
6
  window.button(:value => "Data Entry Form").click { RAutomation::Window.new(:title => "DataEntryForm").exists? }
@@ -16,7 +16,18 @@ describe "WinFfi::Table", :if => SpecHelper.adapter == :win_ffi do
16
16
  to raise_exception(RAutomation::UnknownWindowException)
17
17
  end
18
18
 
19
+ it "check for table class" do
20
+ RAutomation::Window.new(:title => "DataEntryForm").table(:id => "deleteItemButton").should_not exist
21
+ RAutomation::Window.new(:title => "DataEntryForm").table(:id => "personListView").should exist
22
+ end
23
+
19
24
  it "#strings" do
25
+ table = RAutomation::Window.new(:title => "MainFormWindow").table(:id => "FruitListBox")
26
+
27
+ table.strings.should == ["Apple", "Orange", "Mango"]
28
+ end
29
+
30
+ it "#strings with nested elements" do
20
31
  table = RAutomation::Window.new(:title => "DataEntryForm").table(:id => "personListView")
21
32
 
22
33
  table.strings.should == [
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "WinFfi::TextField", :if => SpecHelper.adapter == :win_ffi do
3
+ describe "MsUia::TextField", :if => SpecHelper.adapter == :ms_uia do
4
4
 
5
5
  it "check for text field class" do
6
6
  RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "checkBox").should_not exist
7
+ RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textField").should exist
7
8
  end
8
9
 
9
10
  it "enabled/disabled" do
@@ -0,0 +1,89 @@
1
+ require "spec_helper"
2
+
3
+ describe "MsUia::Window", :if => SpecHelper.adapter == :ms_uia do
4
+
5
+
6
+
7
+ it "move and click" do
8
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
9
+ window.maximize
10
+ window.move_mouse(62,46)
11
+ sleep 1
12
+ window.click_mouse
13
+ sleep 1
14
+
15
+ end
16
+
17
+ =begin
18
+ it "control by focus" do
19
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
20
+
21
+ button = window.button(:value => "Reset")
22
+ button.set_focus
23
+ control = window.control(:id => "button1", :focus => "")
24
+
25
+ box2 = button.bounding_rectangle
26
+ box1 = control.bounding_rectangle
27
+
28
+ box1.should == box2
29
+ end
30
+
31
+ it "#child" do
32
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
33
+ window.should exist
34
+
35
+ # buttons are windows too. so let's find the button for now
36
+ child = window.child(:title => /About/i)
37
+ child.should exist
38
+ child.title.should == "&About"
39
+ # child.text.should include "About"
40
+ end
41
+
42
+ it "send tab keystrokes to move focus between elements" do
43
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
44
+ window.button(:value => "&About").set_focus
45
+ window.button(:value => "&About").should have_focus
46
+
47
+ window.send_keys("{tab}{tab}{tab}")
48
+ button = window.button(:value => "Close")
49
+ button.should exist
50
+ button.should have_focus
51
+ end
52
+
53
+ it "send keystrokes to a text field" do
54
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
55
+ text_field = RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textField")
56
+ text_field.set_focus
57
+ window.send_keys("abc123ABChiHI!\#@$%^&*()\"/-,'&_<>")
58
+ text_field.value.should == "abc123ABChiHI!\#@$%^&*()\"/-,'&_<>"
59
+ end
60
+
61
+ it "sending keystrokes does not change argument string" do
62
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
63
+
64
+ text_field = RAutomation::Window.new(:title => "MainFormWindow").text_field(:id => "textField")
65
+ text_field.set_focus()
66
+
67
+ an_important_string = "Don't lose me"
68
+ window.send_keys(an_important_string)
69
+ an_important_string.should == "Don't lose me"
70
+ end
71
+
72
+ it "#control" do
73
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
74
+ window.control(:id => "aboutButton").should exist
75
+ end
76
+
77
+ it "has controls" do
78
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
79
+ window.controls(:class => /BUTTON/i).size.should == 12
80
+ end
81
+
82
+ it "window coordinates" do
83
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
84
+
85
+ window.maximize
86
+ window.bounding_rectangle.should == [-4, -4, 1444, 874]
87
+ end
88
+ =end
89
+ end
@@ -0,0 +1,30 @@
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
+ window.button(:value => "Enabled").should be_enabled
7
+ window.button(:value => "Enabled").should_not be_disabled
8
+
9
+ window.button(:value => "Disabled").should be_disabled
10
+ window.button(:value => "Disabled").should_not be_enabled
11
+ end
12
+
13
+ it "#focus" do
14
+ button = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).button(:value => "Enabled")
15
+ button.should_not be_focused
16
+ button.focus
17
+ button.should be_focused
18
+ end
19
+
20
+ it "cannot click disabled button" do
21
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
22
+ lambda { window.button(:value => "Disabled").click }.should raise_error
23
+ end
24
+
25
+ it "cannot set focus to disabled button" do
26
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
27
+ lambda { window.button(:value => "Disabled").focus }.should raise_error
28
+ end
29
+
30
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::Checkbox", :if => SpecHelper.adapter == :win_32 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 "#set? & #set" do
13
+ checkbox = RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBox")
14
+ checkbox.should_not be_set
15
+
16
+ checkbox.set
17
+ checkbox.should be_set
18
+ end
19
+
20
+ it "#value" do
21
+ checkbox = RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBox")
22
+ checkbox.value.should == "checkBox"
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(:value => "checkBox").should be_enabled
36
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBox").should_not be_disabled
37
+
38
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBoxDisabled").should_not be_enabled
39
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBoxDisabled").should be_disabled
40
+ end
41
+
42
+ it "cannot check a disabled checkbox" do
43
+ lambda {
44
+ RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBoxDisabled").set
45
+ }.should raise_error
46
+ end
47
+
48
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::Label", :if => SpecHelper.adapter == :win_32 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 "#label" do
12
+ window = RAutomation::Window.new(:title => "MainFormWindow")
13
+ window.label(:value => "This is a sample text").value.should == "This is a sample text"
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::ListBox", :if => SpecHelper.adapter == :win_32 do
4
+
5
+ it "#exists" do
6
+ RAutomation::Window.new(:title => "MainFormWindow").list_box(:index => 0).should exist
7
+ end
8
+
9
+ it "#count" do
10
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:index => 0)
11
+ list_box.count.should == 3
12
+ end
13
+
14
+ it "lists items" do
15
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:index => 0)
16
+ list_box.items[0].should == "Apple"
17
+ list_box.items[1].should == "Orange"
18
+ list_box.items[2].should == "Mango"
19
+ end
20
+
21
+ it "#selected?" do
22
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:index => 0)
23
+ list_box.should_not be_selected(2)
24
+ list_box.select(2)
25
+ list_box.should be_selected(2)
26
+ end
27
+
28
+ it "#select" do
29
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:index => 0)
30
+ list_box.select(1)
31
+ list_box.should be_selected(1)
32
+ list_box.select(0)
33
+ list_box.should be_selected(0)
34
+ list_box.select(2)
35
+ list_box.should be_selected(2)
36
+ end
37
+
38
+ it "#strings" do
39
+ list_box = RAutomation::Window.new(:title => "MainFormWindow").list_box(:index => 0)
40
+ list_box.strings.should == ["Apple", "Orange", "Mango"]
41
+ end
42
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::RadioButton", :if => SpecHelper.adapter == :win_32 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 "#set? & #set" do
14
+ radio = RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option 1")
15
+ radio.should_not be_set
16
+
17
+ radio.set
18
+ radio.should be_set
19
+ end
20
+
21
+ it "enabled/disabled" do
22
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option 1").should be_enabled
23
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option 1").should_not be_disabled
24
+
25
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option Disabled").should_not be_enabled
26
+ RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option Disabled").should be_disabled
27
+ end
28
+
29
+ it "cannot set a disabled radio button" do
30
+ lambda { RAutomation::Window.new(:title => "MainFormWindow").radio(:value => "Option Disabled").set }.should raise_error
31
+ end
32
+ end
@@ -1,21 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "WinFfi::SelectList", :if => SpecHelper.adapter == :win_ffi do
3
+ describe "Win32::SelectList", :if => SpecHelper.adapter == :win_32 do
4
4
  it "#select_list" do
5
- RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox").should exist
5
+ RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /combobox/i, :index => 1).should exist
6
6
 
7
7
  RAutomation::Window.wait_timeout = 0.1
8
8
  expect {RAutomation::Window.new(:title => "non-existent-window").
9
- select_list(:class => /COMBOBOX/i)}.
9
+ select_list(:class => /combobox/i, :index => 1)}.
10
10
  to raise_exception(RAutomation::UnknownWindowException)
11
11
  end
12
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
13
  it "#options" do
18
- select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
14
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /combobox/i, :index => 1)
19
15
  select_list.options.size.should == 5
20
16
 
21
17
  expected_options = ["Apple", "Caimito", "Coconut", "Orange", "Passion Fruit"]
@@ -23,14 +19,21 @@ describe "WinFfi::SelectList", :if => SpecHelper.adapter == :win_ffi do
23
19
  end
24
20
 
25
21
  it "#selected? & #select" do
26
- select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
22
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /combobox/i, :index => 1)
27
23
  select_list.options(:text => "Apple")[0].should_not be_selected
28
24
  select_list.options(:text => "Apple")[0].select.should be_true
29
25
  select_list.options(:text => "Apple")[0].should be_selected
30
26
  end
31
27
 
28
+ it "#set" do
29
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /combobox/i, :index => 1)
30
+ select_list.options(:text => "Apple")[0].should_not be_selected
31
+ select_list.set("Apple")
32
+ select_list.options(:text => "Apple")[0].should be_selected
33
+ end
34
+
32
35
  it "#value" do
33
- select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
36
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /combobox/i, :index => 1)
34
37
 
35
38
  #default empty state
36
39
  select_list.value.should == ""
@@ -43,15 +46,12 @@ describe "WinFfi::SelectList", :if => SpecHelper.adapter == :win_ffi do
43
46
  end
44
47
 
45
48
  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
49
+ RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /combobox/i, :index => 1).should be_enabled
50
+ RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /combobox/i, :index => 1).should_not be_disabled
51
51
  end
52
52
 
53
53
  it "#option" do
54
- select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:id => "FruitsComboBox")
54
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /combobox/i, :index => 1)
55
55
 
56
56
  select_list.option(:text => "Apple").should_not be_selected
57
57
  select_list.option(:text => "Apple").set
@@ -0,0 +1,28 @@
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
+ 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 "#select" do
20
+ table = RAutomation::Window.new(:title => "DataEntryForm").table
21
+
22
+ table.should_not be_selected(2)
23
+ table.select(2)
24
+ table.should be_selected(2)
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Win32::TextField", :if => SpecHelper.adapter == :win_32 do
4
+
5
+ it "enabled/disabled" do
6
+ RAutomation::Window.new(:title => "MainFormWindow").text_field(:index => 1).should be_enabled
7
+ RAutomation::Window.new(:title => "MainFormWindow").text_field(:index => 1).should_not be_disabled
8
+ end
9
+
10
+ it "cannot set a value to a disabled text field" do
11
+ lambda { RAutomation::Window.new(:title => "MainFormWindow").text_field.set "abc" }.should raise_error
12
+ lambda { RAutomation::Window.new(:title => "MainFormWindow").text_field.clear }.should raise_error
13
+ end
14
+
15
+ it "#send_keys" do
16
+ text_field = RAutomation::Window.new(:title => "MainFormWindow").text_field(:index => 1)
17
+ text_field.send_keys "abc"
18
+ text_field.value.should == "abc"
19
+
20
+ text_field.send_keys [:control, "a"], :backspace
21
+ text_field.value.should be_empty
22
+ end
23
+
24
+ end
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "WinFfi::Window", :if => SpecHelper.adapter == :win_ffi do
3
+ describe "Win32::Window", :if => SpecHelper.adapter == :win_32 do
4
4
  it "#child" do
5
5
  window = RAutomation::Window.new(:title => /MainFormWindow/i)
6
6
  window.should exist
@@ -9,35 +9,40 @@ describe "WinFfi::Window", :if => SpecHelper.adapter == :win_ffi do
9
9
  child = window.child(:title => /About/i)
10
10
  child.should exist
11
11
  child.title.should == "&About"
12
- # child.text.should include "About"
13
12
  end
14
13
 
15
14
  it "send tab keystrokes to move focus between elements" do
16
15
  window = RAutomation::Window.new(:title => /MainFormWindow/i)
17
- window.button(:value => "&About").set_focus
18
- window.button(:value => "&About").should have_focus
16
+ window.button(:value => "&About").focus
17
+ window.button(:value => "&About").should be_focused
19
18
 
20
- window.send_keys("{tab}{tab}{tab}")
19
+ window.send_keys(:tab, :tab, :tab)
21
20
  button = window.button(:value => "Close")
22
21
  button.should exist
23
- button.should have_focus
22
+ button.should be_focused
24
23
  end
25
24
 
26
- it "send keystrokes to a text field" do
25
+ it "#send_keys" do
27
26
  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
27
+ text_field = window.text_field(:index => 1)
28
+ text_field.focus
29
+ window.send_keys "abc123ABChiHI!"
30
+ text_field.value.should == "abc123ABChiHI!"
31
+
32
+ window.send_keys :space, "X"
33
+ text_field.value.should == "abc123ABChiHI! X"
34
+
35
+ window.send_keys [:control, "a"], :backspace
36
+ text_field.value.should be_empty
37
+ end
33
38
 
34
39
  it "#control" do
35
40
  window = RAutomation::Window.new(:title => /MainFormWindow/i)
36
- window.control(:id => "aboutButton").should exist
41
+ window.control(:value => "&About").should exist
37
42
  end
38
43
 
39
44
  it "has controls" do
40
45
  window = RAutomation::Window.new(:title => /MainFormWindow/i)
41
- window.controls(:class => /BUTTON/i).size.should == 12
46
+ window.controls(:class => /button/i).size.should == 12
42
47
  end
43
48
  end