rautomation 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/History.rdoc +16 -1
  2. data/LICENSE +1 -1
  3. data/README.rdoc +25 -7
  4. data/Rakefile +4 -0
  5. data/VERSION +1 -1
  6. data/ext/IAccessibleDLL/IAccessibleDLL.sln +20 -0
  7. data/ext/IAccessibleDLL/IAccessibleDLL.suo +0 -0
  8. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.cpp +36 -0
  9. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj +100 -0
  10. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj.filters +39 -0
  11. data/ext/IAccessibleDLL/IAccessibleDLL/IAccessibleDLL.vcxproj.user +3 -0
  12. data/ext/IAccessibleDLL/IAccessibleDLL/ReadMe.txt +48 -0
  13. data/ext/IAccessibleDLL/IAccessibleDLL/dllmain.cpp +19 -0
  14. data/ext/IAccessibleDLL/IAccessibleDLL/stdafx.cpp +8 -0
  15. data/ext/IAccessibleDLL/IAccessibleDLL/stdafx.h +16 -0
  16. data/ext/IAccessibleDLL/IAccessibleDLL/targetver.h +8 -0
  17. data/ext/IAccessibleDLL/Release/IAccessibleDLL.dll +0 -0
  18. data/ext/IAccessibleDLL/Release/IAccessibleDLL.exp +0 -0
  19. data/ext/IAccessibleDLL/Release/IAccessibleDLL.lib +0 -0
  20. data/ext/WindowsForms/bin/WindowsForms.exe +0 -0
  21. data/ext/WindowsForms/src/WindowsForms/WindowsForms.sln +20 -0
  22. data/ext/WindowsForms/src/WindowsForms/WindowsForms.suo +0 -0
  23. data/ext/WindowsForms/src/WindowsForms/WindowsForms/AboutBox.Designer.cs +80 -0
  24. data/ext/WindowsForms/src/WindowsForms/WindowsForms/AboutBox.cs +103 -0
  25. data/ext/WindowsForms/src/WindowsForms/WindowsForms/AboutBox.resx +120 -0
  26. data/ext/WindowsForms/src/WindowsForms/WindowsForms/DataEntryForm.Designer.cs +167 -0
  27. data/ext/WindowsForms/src/WindowsForms/WindowsForms/DataEntryForm.cs +45 -0
  28. data/ext/WindowsForms/src/WindowsForms/WindowsForms/DataEntryForm.resx +120 -0
  29. data/ext/WindowsForms/src/WindowsForms/WindowsForms/MainFormWindow.Designer.cs +278 -0
  30. data/ext/WindowsForms/src/WindowsForms/WindowsForms/MainFormWindow.cs +78 -0
  31. data/ext/WindowsForms/src/WindowsForms/WindowsForms/MainFormWindow.resx +120 -0
  32. data/ext/WindowsForms/src/WindowsForms/WindowsForms/PersonForm.Designer.cs +119 -0
  33. data/ext/WindowsForms/src/WindowsForms/WindowsForms/PersonForm.cs +34 -0
  34. data/ext/WindowsForms/src/WindowsForms/WindowsForms/PersonForm.resx +120 -0
  35. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Program.cs +21 -0
  36. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/AssemblyInfo.cs +36 -0
  37. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/Resources.Designer.cs +71 -0
  38. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/Resources.resx +117 -0
  39. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/Settings.Designer.cs +30 -0
  40. data/ext/WindowsForms/src/WindowsForms/WindowsForms/Properties/Settings.settings +7 -0
  41. data/ext/WindowsForms/src/WindowsForms/WindowsForms/SimpleElementsForm.Designer.cs +93 -0
  42. data/ext/WindowsForms/src/WindowsForms/WindowsForms/SimpleElementsForm.cs +19 -0
  43. data/ext/WindowsForms/src/WindowsForms/WindowsForms/SimpleElementsForm.resx +120 -0
  44. data/ext/WindowsForms/src/WindowsForms/WindowsForms/WindowsForms.csproj +123 -0
  45. data/ext/WindowsForms/src/WindowsForms/WindowsForms/bin/Debug/WindowsForms.exe +0 -0
  46. data/ext/WindowsForms/src/WindowsForms/WindowsForms/bin/Debug/WindowsForms.pdb +0 -0
  47. data/ext/WindowsForms/src/WindowsForms/WindowsForms/bin/Debug/WindowsForms.vshost.exe +0 -0
  48. data/ext/WindowsForms/src/WindowsForms/WindowsForms/bin/Debug/WindowsForms.vshost.exe.manifest +11 -0
  49. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache +0 -0
  50. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache +0 -0
  51. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/GenerateResource.read.1.tlog +0 -0
  52. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/GenerateResource.write.1.tlog +0 -0
  53. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/ResolveAssemblyReference.cache +0 -0
  54. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/WindowsForms.AboutBox.resources +0 -0
  55. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/WindowsForms.DataEntryForm.resources +0 -0
  56. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/WindowsForms.MainFormWindow.resources +0 -0
  57. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/WindowsForms.PersonForm.resources +0 -0
  58. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/WindowsForms.Properties.Resources.resources +0 -0
  59. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/WindowsForms.SimpleElementsForm.resources +0 -0
  60. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/WindowsForms.csproj.FileListAbsolute.txt +25 -0
  61. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/WindowsForms.exe +0 -0
  62. data/ext/WindowsForms/src/WindowsForms/WindowsForms/obj/x86/Debug/WindowsForms.pdb +0 -0
  63. data/lib/{RAutomation.rb → rautomation.rb} +3 -1
  64. data/lib/rautomation/adapter/autoit/button.rb +7 -4
  65. data/lib/rautomation/adapter/autoit/locators.rb +4 -2
  66. data/lib/rautomation/adapter/autoit/text_field.rb +8 -5
  67. data/lib/rautomation/adapter/autoit/window.rb +23 -7
  68. data/lib/rautomation/adapter/win_ffi.rb +9 -3
  69. data/lib/rautomation/adapter/win_ffi/button.rb +3 -34
  70. data/lib/rautomation/adapter/win_ffi/button_helper.rb +24 -0
  71. data/lib/rautomation/adapter/win_ffi/checkbox.rb +12 -0
  72. data/lib/rautomation/adapter/win_ffi/constants.rb +21 -0
  73. data/lib/rautomation/adapter/win_ffi/control.rb +46 -0
  74. data/lib/rautomation/adapter/win_ffi/functions.rb +52 -1
  75. data/lib/rautomation/adapter/win_ffi/locators.rb +2 -1
  76. data/lib/rautomation/adapter/win_ffi/radio.rb +12 -0
  77. data/lib/rautomation/adapter/win_ffi/select_list.rb +64 -0
  78. data/lib/rautomation/adapter/win_ffi/table.rb +18 -0
  79. data/lib/rautomation/adapter/win_ffi/text_field.rb +4 -20
  80. data/lib/rautomation/adapter/win_ffi/window.rb +48 -10
  81. data/lib/rautomation/element_collections.rb +44 -0
  82. data/lib/rautomation/window.rb +29 -5
  83. data/spec/adapter/win_ffi/checkbox_spec.rb +29 -0
  84. data/spec/adapter/win_ffi/radio_spec.rb +21 -0
  85. data/spec/adapter/win_ffi/select_list_spec.rb +41 -0
  86. data/spec/adapter/win_ffi/table_spec.rb +20 -0
  87. data/spec/adapter/win_ffi/window_spec.rb +6 -12
  88. data/spec/button_spec.rb +28 -20
  89. data/spec/buttons_spec.rb +21 -0
  90. data/spec/spec_helper.rb +46 -37
  91. data/spec/text_field_spec.rb +11 -11
  92. data/spec/text_fields_spec.rb +22 -0
  93. data/spec/window_spec.rb +11 -19
  94. data/spec/windows_spec.rb +55 -0
  95. metadata +84 -9
  96. data/.gitignore +0 -25
  97. data/rautomation.gemspec +0 -90
  98. data/spec/test.html +0 -15
@@ -1,13 +1,33 @@
1
1
  module RAutomation
2
- class UnknownWindowException < RuntimeError
2
+ class UnknownElementException < RuntimeError
3
3
  end
4
- class UnknownButtonException < RuntimeError
4
+ class UnknownWindowException < UnknownElementException
5
5
  end
6
- class UnknownTextFieldException < RuntimeError
6
+ class UnknownButtonException < UnknownElementException
7
+ end
8
+ class UnknownTextFieldException < UnknownElementException
7
9
  end
8
10
 
9
11
  class Window
10
12
  include Adapter::Helper
13
+ extend ElementCollections
14
+
15
+ has_many :windows, :buttons, :text_fields
16
+
17
+ class << self
18
+ # @return [Windows] all windows.
19
+ def windows
20
+ Windows.new(nil, {})
21
+ end
22
+ end
23
+
24
+ # Retrieves all windows with similar locators to the current window.
25
+ # @param locators (see #initialize)
26
+ # @return [Windows] all windows matching current window's _locators_ if no
27
+ # explicit locators specified or windows matching the specified _locators_.
28
+ def windows(locators = @window.locators)
29
+ Windows.new(nil, locators)
30
+ end
11
31
 
12
32
  # Currently used {Adapter}.
13
33
  attr_reader :adapter
@@ -38,8 +58,9 @@ module RAutomation
38
58
  # __RAUTOMATION_ADAPTER__
39
59
  #
40
60
  # @note This constructor doesn't check for window's existance.
41
- # @note Only visible Windows are supported.
42
- # @param [Hash] locators for the window.
61
+ # @note Only visible windows are supported.
62
+ # @note If given _locators_ include :hwnd then every other possible _locator_ is ignored.
63
+ # @param [Hash] locators locators for the window.
43
64
  def initialize(locators)
44
65
  @adapter = locators.delete(:adapter) || ENV["RAUTOMATION_ADAPTER"] && ENV["RAUTOMATION_ADAPTER"].to_sym || default_adapter
45
66
  @window = Adapter.const_get(normalize(@adapter)).const_get(:Window).new(locators)
@@ -60,15 +81,18 @@ module RAutomation
60
81
  def wait_timeout
61
82
  @@wait_timeout
62
83
  end
84
+
63
85
  end
64
86
 
65
87
  # @return [Fixnum] handle of the window which is used internally for other methods.
88
+ # @raise [UnknownWindowException] if the window doesn't exist.
66
89
  def hwnd
67
90
  wait_until_exists
68
91
  @window.hwnd
69
92
  end
70
93
 
71
94
  # @return [Fixnum] process identifier (PID) of the window.
95
+ # @raise [UnknownWindowException] if the window doesn't exist.
72
96
  def pid
73
97
  wait_until_exists
74
98
  @window.pid
@@ -0,0 +1,29 @@
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 "#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 "#clear" do
21
+ checkbox = RAutomation::Window.new(:title => "MainFormWindow").checkbox(:value => "checkBox")
22
+ checkbox.set
23
+ checkbox.should be_set
24
+
25
+ checkbox.clear
26
+ checkbox.should_not be_set
27
+ end
28
+
29
+ end
@@ -0,0 +1,21 @@
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 "#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
+ end
@@ -0,0 +1,41 @@
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(:class => /COMBOBOX/i).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 "#options" do
14
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /COMBOBOX/i)
15
+ select_list.options.size.should == 5
16
+
17
+ expected_options = ["Apple", "Caimito", "Coconut", "Orange", "Passion Fruit"]
18
+ select_list.options.map {|option| option.text}.should == expected_options
19
+ end
20
+
21
+ it "#selected? & #select" do
22
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /COMBOBOX/i)
23
+ select_list.options(:text => "Apple")[0].should_not be_selected
24
+ select_list.options(:text => "Apple")[0].select.should be_true
25
+ select_list.options(:text => "Apple")[0].should be_selected
26
+ end
27
+
28
+ it "#value" do
29
+ select_list = RAutomation::Window.new(:title => "MainFormWindow").select_list(:class => /COMBOBOX/i)
30
+
31
+ #default empty state
32
+ select_list.value.should == ""
33
+
34
+ select_list.options(:text => "Apple")[0].select
35
+ select_list.value.should == "Apple"
36
+
37
+ select_list.options(:text => "Caimito")[0].select
38
+ select_list.value.should == "Caimito"
39
+ end
40
+
41
+ end
@@ -0,0 +1,20 @@
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(:class => /SysListView32/i)
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
+ end
20
+
@@ -1,20 +1,14 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "WinFfi::Window", :if => SpecHelper.adapter == :win_ffi do
4
- before :all do
5
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
6
- RAutomation::WaitHelper.wait_until {window.present?}
7
-
8
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
9
- RAutomation::WaitHelper.wait_until {window.present?}
10
- end
11
-
12
4
  it "#child" do
13
- window = RAutomation::Window.new(:title => /Internet Explorer$/i)
5
+ window = RAutomation::Window.new(:title => /MainFormWindow/i)
14
6
  window.should exist
15
- child = window.child(:title => SpecHelper::DATA[:window2_title])
7
+
8
+ # buttons are windows too. so let's find the button for now
9
+ child = window.child(:title => /About/i)
16
10
  child.should exist
17
- child.title.should == SpecHelper::DATA[:window2_title]
18
- child.text.should include(SpecHelper::DATA[:window2_text])
11
+ child.title.should == "&About"
12
+ # child.text.should include "About"
19
13
  end
20
14
  end
data/spec/button_spec.rb CHANGED
@@ -2,57 +2,65 @@ require 'spec_helper'
2
2
 
3
3
  describe RAutomation::Button do
4
4
  it "#button" do
5
- RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).
6
- button(:value => SpecHelper::DATA[:window2_button_text]).should exist
5
+ RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).
6
+ button(:value => "Close").should exist
7
7
 
8
8
  RAutomation::Window.wait_timeout = 0.1
9
9
  expect {RAutomation::Window.new(:title => "non-existing-window").button(:value => "Something")}.
10
- to raise_exception(RAutomation::UnknownWindowException)
10
+ to raise_exception(RAutomation::UnknownWindowException)
11
11
  end
12
12
 
13
13
  it "#value" do
14
- RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).
15
- button(:value => SpecHelper::DATA[:window2_button_text]).value.should == SpecHelper::DATA[:window2_button_text]
14
+ RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).
15
+ button(:value => "Close").value.should == "Close"
16
16
 
17
17
  RAutomation::Window.wait_timeout = 0.1
18
- expect {RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).button(:value => "non-existent-button").value}.
19
- to raise_exception(RAutomation::UnknownButtonException)
18
+ expect {RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).button(:value => "non-existent-button").value}.
19
+ to raise_exception(RAutomation::UnknownButtonException)
20
20
  end
21
21
 
22
22
  it "#exists?" do
23
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
24
- window.button(:value => SpecHelper::DATA[:window2_button_text]).should exist
23
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
24
+ window.button(:value => "Close").should exist
25
25
  window.button(:value => "non-existent-button").should_not exist
26
26
  end
27
27
 
28
- it "#click" do
29
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
28
+ it "clicking non-existing button raises exception" do
29
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
30
30
  RAutomation::Window.wait_timeout = 0.1
31
31
  expect {window.button(:value => "non-existent-button").click}.
32
- to raise_exception(RAutomation::UnknownButtonException)
32
+ to raise_exception(RAutomation::UnknownButtonException)
33
+ end
34
+
35
+ it "#click" do
36
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
33
37
 
34
- RAutomation::Window.wait_timeout = 60
35
- button = window.button(:value => SpecHelper::DATA[:window2_button_text])
38
+ button = window.button(:value => "Close")
36
39
  button.should exist
37
40
  button.click
41
+
38
42
  button.should_not exist
39
43
  window.should_not exist
40
44
  end
41
45
 
42
- it "#click with a block for defining successful click" do
43
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
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])
44
48
  RAutomation::Window.wait_timeout = 5
45
- button = window.button(:value => SpecHelper::DATA[:window2_button_text])
49
+ button = window.button(:value => "Close")
46
50
  expect {button.click {false}}.
47
- to raise_exception(RAutomation::WaitHelper::TimeoutError)
51
+ to raise_exception(RAutomation::WaitHelper::TimeoutError)
52
+
48
53
  button.should_not exist
49
54
  window.should_not exist
55
+ end
50
56
 
57
+ it "#click with a block for defining successful click returning true" do
51
58
  RAutomation::Window.wait_timeout = 10
52
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
53
- button = window.button(:value => SpecHelper::DATA[:window2_button_text])
59
+ window = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
60
+ button = window.button(:value => "Close")
54
61
  button.should exist
55
62
  button.click {|button| !button.exists? && !window.exists?}
63
+
56
64
  button.should_not exist
57
65
  window.should_not exist
58
66
  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
+ buttons.size.should == 2
10
+ buttons.find_all {|b| b.value == 'button1'}.size.should == 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
+ buttons.size.should == 1
18
+ buttons.first.value.should == 'button1'
19
+ end
20
+
21
+ end
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,12 @@ module SpecHelper
8
8
  ENV["RAUTOMATION_ADAPTER"] && ENV["RAUTOMATION_ADAPTER"].to_sym || RAutomation::Adapter::Helper.default_adapter
9
9
  end
10
10
 
11
- module_function :adapter
11
+ def navigate_to_simple_elements
12
+ main_window = RAutomation::Window.new(:title => "MainFormWindow")
13
+ main_window.button(:value => "Simple Elements").click { RAutomation::Window.new(:title => "SimpleElementsForm").present? }
14
+ end
15
+
16
+ module_function :adapter, :navigate_to_simple_elements
12
17
 
13
18
  # Since adapters are different then the windows to be tested
14
19
  # might be different also.
@@ -23,62 +28,66 @@ module SpecHelper
23
28
  :autoit => {
24
29
  # Path to some binary, which opens up a window, what can be
25
30
  # minimized, maximized, activated, closed and etc.
26
- :window1 => "mspaint",
31
+ :window1 => "ext\\WindowsForms\\bin\\WindowsForms.exe",
32
+ :window2 => "calc",
33
+ :window2_title => /calc/i,
27
34
  # Window 1 title, has to be a Regexp.
28
- :window1_title => /untitled - paint/i,
29
- # Path to some browser's binary.
30
- :window2 => '"c:\\program files\\internet explorer\\iexplore.exe"',
31
- # Window 2 title, has to be a String.
32
- :window2_title => "Explorer User Prompt",
33
- # Window 2 should have this text on it.
34
- :window2_text => "Where do you want to go today?",
35
+ :window1_title => /FormWindow/i,
36
+ :window1_full_title => 'MainFormWindow',
37
+ # Window 1 should have this text on it.
38
+ :window1_text => "This is a sample text",
35
39
  # When sending ENTER on Window 2, then the window OK button should be pressed and Window 2 should be closed.
36
- :window2_send_keys => "{ENTER}",
37
- # Window 2 should have a button with the following text.
38
- :window2_button_text => "OK",
39
- # Window 2 should have a text field with the specified class name.
40
- :window2_text_field_class => "Edit",
40
+ # "A" key
41
+ :window1_send_keys => "A",
42
+ :proc_after_send_keys => lambda do
43
+ about_box = RAutomation::Window.new(:title => /About/i)
44
+ RAutomation::WaitHelper.wait_until {about_box.present?}
45
+ end,
46
+ # Window 1 should have a button with the following text.
47
+ :window1_button_text => "&About",
48
+ # Window 1 should have a text field with the specified class name.
49
+ :window1_text_field_class => "Edit",
41
50
  # Adapter internal method invocation for getting title of window2
42
- :title_proc => lambda {|win| win.WinGetTitle("[TITLE:Explorer User Prompt]")}
51
+ :title_proc => lambda {|win| win.WinGetTitle("[TITLE:MainFormWindow]")}
43
52
  },
44
- # This adapter needs Windows OS with Internet Explorer installed into 'c:\program files\internet explorer'.
45
53
  :win_ffi => {
46
54
  # Path to some binary, which opens up a window, what can be
47
55
  # minimized, maximized, activated, closed and etc.
48
- :window1 => "mspaint",
56
+ :window1 => "ext\\WindowsForms\\bin\\WindowsForms.exe",
57
+ :window2 => "calc",
58
+ :window2_title => /calc/i,
49
59
  # Window 1 title, has to be a Regexp.
50
- :window1_title => /untitled - paint/i,
51
- # Path to some browser's binary.
52
- :window2 => '"c:\\program files\\internet explorer\\iexplore.exe"',
53
- # Window 2 title, has to be a String.
54
- :window2_title => "Explorer User Prompt",
55
- # Window 2 should have this text on it.
56
- :window2_text => "Where do you want to go today?",
60
+ :window1_title => /FormWindow/i,
61
+ :window1_full_title => 'MainFormWindow',
62
+ # Window 1 should have this text on it.
63
+ :window1_text => "This is a sample text",
57
64
  # When sending ENTER on Window 2, then the window OK button should be pressed and Window 2 should be closed.
58
- # VK_RETURN
59
- :window2_send_keys => 0xD,
60
- # Window 2 should have a button with the following text.
61
- :window2_button_text => "OK",
62
- # Window 2 should have a text field with the specified class name.
63
- :window2_text_field_class => "Edit",
65
+ # "A" key
66
+ :window1_send_keys => 0x41,
67
+ :proc_after_send_keys => lambda do
68
+ about_box = RAutomation::Window.new(:title => /About/i)
69
+ RAutomation::WaitHelper.wait_until {about_box.present?}
70
+ end,
71
+ # Window 1 should have a button with the following text.
72
+ :window1_button_text => "&About",
73
+ # Window 1 should have a text field with the specified class name.
74
+ :window1_text_field_class => "Edit",
64
75
  # Adapter internal method invocation for getting title of window2
65
76
  :title_proc => lambda {|win| win.window_title(win.hwnd)}
66
77
  }
67
78
  }[adapter]
68
79
  end
69
80
 
70
- RSpec.configure do |config|
71
- config.before(:all) do
72
- @pid1 = IO.popen(SpecHelper::DATA[:window1]).pid
73
- @pid2 = IO.popen(SpecHelper::DATA[:window2] + " " + File.dirname(__FILE__) + "/test.html").pid
74
- end
75
81
 
82
+ RSpec.configure do |config|
76
83
  config.before(:each) do
77
84
  RAutomation::Window.wait_timeout = 60
85
+
86
+ @pid1 = IO.popen(SpecHelper::DATA[:window1]).pid
87
+ RAutomation::WaitHelper.wait_until {RAutomation::Window.new(:pid => @pid1).present?}
78
88
  end
79
89
 
80
- config.after(:all) do
90
+ config.after(:each) do
81
91
  Process.kill(9, @pid1) rescue nil
82
- Process.kill(9, @pid2) rescue nil
83
92
  end
84
93
  end
@@ -2,18 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  describe RAutomation::TextField do
4
4
  it "#text_field" do
5
- RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).
6
- text_field(:class => SpecHelper::DATA[:window2_text_field_class]).should exist
5
+ RAutomation::Window.new(:title => "MainFormWindow").
6
+ text_field(:class => /Edit/i).should exist
7
7
 
8
8
  RAutomation::Window.wait_timeout = 0.1
9
9
  expect {RAutomation::Window.new(:title => "non-existent-window").
10
- text_field(:class => SpecHelper::DATA[:window2_text_field_class])}.
10
+ text_field(:class => "Edit")}.
11
11
  to raise_exception(RAutomation::UnknownWindowException)
12
12
  end
13
13
 
14
14
  it "#set" do
15
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
16
- window.text_field(:class => SpecHelper::DATA[:window2_text_field_class]).set "hello!"
15
+ window = RAutomation::Window.new(:title => "MainFormWindow")
16
+ window.text_field(:class => /Edit/i).set "hello!"
17
17
 
18
18
  RAutomation::Window.wait_timeout = 0.1
19
19
  expect {window.text_field(:class => "non-existing-field").set "hello!"}.
@@ -21,8 +21,8 @@ describe RAutomation::TextField do
21
21
  end
22
22
 
23
23
  it "#clear"do
24
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
25
- field = window.text_field(:class => SpecHelper::DATA[:window2_text_field_class])
24
+ window = RAutomation::Window.new(:title => "MainFormWindow")
25
+ field = window.text_field(:class => /Edit/i)
26
26
  field.set "hello!"
27
27
  field.value.should == "hello!"
28
28
  field.clear
@@ -34,8 +34,8 @@ describe RAutomation::TextField do
34
34
  end
35
35
 
36
36
  it "#value" do
37
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
38
- field = window.text_field(:class => SpecHelper::DATA[:window2_text_field_class])
37
+ window = RAutomation::Window.new(:title => "MainFormWindow")
38
+ field = window.text_field(:class => /Edit/i)
39
39
  field.set "hello!"
40
40
  field.value.should == "hello!"
41
41
 
@@ -45,8 +45,8 @@ describe RAutomation::TextField do
45
45
  end
46
46
 
47
47
  it "#exists?" do
48
- window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
49
- field = window.text_field(:class => SpecHelper::DATA[:window2_text_field_class])
48
+ window = RAutomation::Window.new(:title => "MainFormWindow")
49
+ field = window.text_field(:class => /Edit/i)
50
50
  field.should exist
51
51
  window.text_field(:class => "non-existent-field").should_not exist
52
52
  end