rautomation 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ === Version 0.0.4 / 2010-10-27
2
+
3
+ * most Window, Button and TextField methods wait until the object exists.
4
+ Use RAutomation::Window.wait_timeout= to set timeout before failing. Default is 60 seconds.
5
+
1
6
  === Version 0.0.3 / 2010-10-15
2
7
 
3
8
  * RAutomation didn't load AutoIt correctly if it wasn't installed before
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -11,7 +11,7 @@ module RAutomation
11
11
  #
12
12
  # Raises an UnknownButtonException if the Button itself doesn't exist.
13
13
  def click
14
- assert_exists
14
+ wait_until_exists
15
15
  @button.click
16
16
  end
17
17
 
@@ -19,7 +19,7 @@ module RAutomation
19
19
  #
20
20
  # Raises an UnknownButtonException if the Button itself doesn't exist.
21
21
  def value
22
- assert_exists
22
+ wait_until_exists
23
23
  @button.value
24
24
  end
25
25
 
@@ -32,8 +32,10 @@ module RAutomation
32
32
 
33
33
  private
34
34
 
35
- def assert_exists
36
- raise UnknownButtonException.new("Button '#{@locators.inspect}' doesn't exist on window '#{@window.locators.inspect}'!") unless exists?
35
+ def wait_until_exists
36
+ WaitHelper.wait_until(RAutomation::Window.wait_timeout) {exists?}
37
+ rescue WaitHelper::TimeoutError
38
+ raise UnknownButtonException.new("Button #{@locators.inspect} doesn't exist on window #{@window.locators.inspect}!")
37
39
  end
38
40
  end
39
41
  end
@@ -11,7 +11,7 @@ module RAutomation
11
11
  :value => :text
12
12
  }
13
13
 
14
- # Possible locators are :value, :id, :class, :class_name and :instance.
14
+ # Possible locators are :text, :value, :id, :class, :class_name and :instance.
15
15
  def initialize(window, locators)
16
16
  @window = window
17
17
  extract(locators)
@@ -11,7 +11,7 @@ module RAutomation
11
11
  #
12
12
  # Raises an UnknownTextFieldException if the TextField itself doesn't exist.
13
13
  def set(text)
14
- assert_exists
14
+ wait_until_exists
15
15
  @text_field.set(text)
16
16
  end
17
17
 
@@ -19,7 +19,7 @@ module RAutomation
19
19
  #
20
20
  # Raises an UnknownTextFieldException if the TextField itself doesn't exist.
21
21
  def clear
22
- assert_exists
22
+ wait_until_exists
23
23
  @text_field.clear
24
24
  end
25
25
 
@@ -27,7 +27,7 @@ module RAutomation
27
27
  #
28
28
  # Raises an UnknownTextFieldException if the TextField itself doesn't exist.
29
29
  def value
30
- assert_exists
30
+ wait_until_exists
31
31
  @text_field.value
32
32
  end
33
33
 
@@ -40,8 +40,10 @@ module RAutomation
40
40
 
41
41
  private
42
42
 
43
- def assert_exists
44
- raise UnknownTextFieldException.new("Text field '#{@locators.inspect}' doesn't exist on window '#{@window.locators.inspect}'!") unless exists?
43
+ def wait_until_exists
44
+ WaitHelper.wait_until(RAutomation::Window.wait_timeout) {exists?}
45
+ rescue WaitHelper::TimeoutError
46
+ raise UnknownTextFieldException.new("Text field #{@locators.inspect} doesn't exist on window #{@window.locators.inspect}!") unless exists?
45
47
  end
46
48
  end
47
49
  end
@@ -43,11 +43,24 @@ module RAutomation
43
43
  @window = @implementation.new(locators)
44
44
  end
45
45
 
46
+ class << self
47
+ # Timeout for waiting until object exists. If the timeout exceeds then an Exception is thrown.
48
+ @@wait_timeout = 60
49
+
50
+ def wait_timeout=(timeout)
51
+ @@wait_timeout = timeout
52
+ end
53
+
54
+ def wait_timeout
55
+ @@wait_timeout
56
+ end
57
+ end
58
+
46
59
  # Returns handle of the Window.
47
60
  #
48
61
  # This handle will be used internally for all operations.
49
62
  def hwnd
50
- assert_exists
63
+ wait_until_exists
51
64
  @window.hwnd
52
65
  end
53
66
 
@@ -55,7 +68,7 @@ module RAutomation
55
68
  #
56
69
  # Raises an UnknownWindowException if the Window itself doesn't exist.
57
70
  def title
58
- assert_exists
71
+ wait_until_exists
59
72
  @window.title
60
73
  end
61
74
 
@@ -73,7 +86,7 @@ module RAutomation
73
86
  #
74
87
  # Raises an UnknownWindowException if the Window itself doesn't exist.
75
88
  def text
76
- assert_exists
89
+ wait_until_exists
77
90
  @window.text
78
91
  end
79
92
 
@@ -89,7 +102,7 @@ module RAutomation
89
102
  #
90
103
  # Raises an UnknownWindowException if the Window itself doesn't exist.
91
104
  def visible?
92
- assert_exists
105
+ wait_until_exists
93
106
  @window.visible?
94
107
  end
95
108
 
@@ -102,7 +115,7 @@ module RAutomation
102
115
  #
103
116
  # Raises an UnknownWindowException if the Window itself doesn't exist.
104
117
  def maximize
105
- assert_exists
118
+ wait_until_exists
106
119
  @window.maximize
107
120
  end
108
121
 
@@ -110,7 +123,7 @@ module RAutomation
110
123
  #
111
124
  # Raises an UnknownWindowException if the Window itself doesn't exist.
112
125
  def minimize
113
- assert_exists
126
+ wait_until_exists
114
127
  @window.minimize
115
128
  end
116
129
 
@@ -118,7 +131,7 @@ module RAutomation
118
131
  #
119
132
  # Raises an UnknownWindowException if the Window itself doesn't exist.
120
133
  def minimized?
121
- assert_exists
134
+ wait_until_exists
122
135
  @window.minimized?
123
136
  end
124
137
 
@@ -126,7 +139,7 @@ module RAutomation
126
139
  #
127
140
  # Raises an UnknownWindowException if the Window itself doesn't exist.
128
141
  def restore
129
- assert_exists
142
+ wait_until_exists
130
143
  @window.restore
131
144
  end
132
145
 
@@ -134,7 +147,7 @@ module RAutomation
134
147
  #
135
148
  # Raises an UnknownWindowException if the Window itself doesn't exist.
136
149
  def send_keys(keys)
137
- assert_exists
150
+ wait_until_exists
138
151
  @window.send_keys(keys)
139
152
  end
140
153
 
@@ -149,7 +162,7 @@ module RAutomation
149
162
  #
150
163
  # Raises an UnknownWindowException if the Window itself doesn't exist.
151
164
  def button(locators)
152
- assert_exists
165
+ wait_until_exists
153
166
  Button.new(@window, locators)
154
167
  end
155
168
 
@@ -158,7 +171,7 @@ module RAutomation
158
171
  #
159
172
  # Raises an UnknownWindowException if the Window itself doesn't exist.
160
173
  def text_field(locators)
161
- assert_exists
174
+ wait_until_exists
162
175
  TextField.new(@window, locators)
163
176
  end
164
177
 
@@ -169,8 +182,11 @@ module RAutomation
169
182
 
170
183
  private
171
184
 
172
- def assert_exists
173
- raise UnknownWindowException.new("Window with locator '#{@window.locators.inspect}' doesn't exist!") unless exists?
185
+ def wait_until_exists
186
+ WaitHelper.wait_until(RAutomation::Window.wait_timeout) {exists?}
187
+ rescue WaitHelper::TimeoutError
188
+ raise UnknownWindowException.new("Window with locator #{@window.locators.inspect} doesn't exist!") unless exists?
174
189
  end
190
+
175
191
  end
176
192
  end
data/rautomation.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rautomation}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jarmo Pertman"]
12
- s.date = %q{2010-10-15}
12
+ s.date = %q{2010-10-27}
13
13
  s.description = %q{RAutomation tries to be a small and easy to use library for helping out to automate windows and their controls
14
14
  for automated testing.
15
15
 
data/spec/button_spec.rb CHANGED
@@ -4,6 +4,8 @@ describe RAutomation::Button do
4
4
  it "#button" do
5
5
  RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).
6
6
  button(:value => SpecHelper::DATA[:window2_button_text]).should exist
7
+
8
+ RAutomation::Window.wait_timeout = 0.1
7
9
  lambda {RAutomation::Window.new(:title => "non-existing-window").button(:value => "Something")}.
8
10
  should raise_exception(RAutomation::UnknownWindowException)
9
11
  end
@@ -11,6 +13,8 @@ describe RAutomation::Button do
11
13
  it "#value" do
12
14
  RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).
13
15
  button(:value => SpecHelper::DATA[:window2_button_text]).value.should == SpecHelper::DATA[:window2_button_text]
16
+
17
+ RAutomation::Window.wait_timeout = 0.1
14
18
  lambda {RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).button(:value => "non-existent-button").value}.
15
19
  should raise_exception(RAutomation::UnknownButtonException)
16
20
  end
@@ -23,6 +27,7 @@ describe RAutomation::Button do
23
27
 
24
28
  it "#click" do
25
29
  window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
30
+ RAutomation::Window.wait_timeout = 0.1
26
31
  lambda{window.button(:value => "non-existent-button").click}.
27
32
  should raise_exception(RAutomation::UnknownButtonException)
28
33
 
data/spec/spec.opts CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format n
data/spec/spec_helper.rb CHANGED
@@ -40,10 +40,10 @@ Spec::Runner.configure do |config|
40
40
  config.before(:all) do
41
41
  @pid1 = IO.popen(SpecHelper::DATA[:window1]).pid
42
42
  @pid2 = IO.popen(SpecHelper::DATA[:window2] + " " + File.dirname(__FILE__) + "/test.html").pid
43
- window1 = RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title])
44
- RAutomation::WaitHelper.wait_until(15) {window1.present?}
45
- window2 = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
46
- RAutomation::WaitHelper.wait_until(15) {window2.present?}
43
+ end
44
+
45
+ config.before(:each) do
46
+ RAutomation::Window.wait_timeout = 60
47
47
  end
48
48
 
49
49
  config.after(:all) do
@@ -4,6 +4,8 @@ describe RAutomation::TextField do
4
4
  it "#text_field" do
5
5
  RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).
6
6
  text_field(:class_name => SpecHelper::DATA[:window2_text_field_class_name]).should exist
7
+
8
+ RAutomation::Window.wait_timeout = 0.1
7
9
  lambda {RAutomation::Window.new(:title => "non-existent-window").
8
10
  text_field(:class_name => SpecHelper::DATA[:window2_text_field_class_name])}.
9
11
  should raise_exception(RAutomation::UnknownWindowException)
@@ -12,6 +14,8 @@ describe RAutomation::TextField do
12
14
  it "#set" do
13
15
  window = RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title])
14
16
  window.text_field(:class_name => SpecHelper::DATA[:window2_text_field_class_name]).set "hello!"
17
+
18
+ RAutomation::Window.wait_timeout = 0.1
15
19
  lambda {window.text_field(:class_name => "non-existing-field").set "hello!"}.
16
20
  should raise_exception(RAutomation::UnknownTextFieldException)
17
21
  end
@@ -24,6 +28,7 @@ describe RAutomation::TextField do
24
28
  field.clear
25
29
  field.value.should be_empty
26
30
 
31
+ RAutomation::Window.wait_timeout = 0.1
27
32
  lambda {window.text_field(:class_name => "non-existent-field").clear}.
28
33
  should raise_exception(RAutomation::UnknownTextFieldException)
29
34
  end
@@ -34,6 +39,7 @@ describe RAutomation::TextField do
34
39
  field.set "hello!"
35
40
  field.value.should == "hello!"
36
41
 
42
+ RAutomation::Window.wait_timeout = 0.1
37
43
  lambda {window.text_field(:class_name => "non-existent-field").value}.
38
44
  should raise_exception(RAutomation::UnknownTextFieldException)
39
45
  end
data/spec/window_spec.rb CHANGED
@@ -1,6 +1,14 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe RAutomation::Window 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
+
4
12
  it "RAutomation::Window.implementation" do
5
13
  RAutomation::Window.new(:title => "random").implementation.should == (ENV["RAUTOMATION_IMPLEMENTATION"] || RAutomation::Implementations::Helper.default_implementation)
6
14
  end
@@ -27,6 +35,7 @@ describe RAutomation::Window do
27
35
 
28
36
  it "#visible?"do
29
37
  RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).should be_visible
38
+ RAutomation::Window.wait_timeout = 0.1
30
39
  lambda{RAutomation::Window.new(:title => "non-existing-window").visible?}.
31
40
  should raise_exception(RAutomation::UnknownWindowException)
32
41
  end
@@ -38,12 +47,14 @@ describe RAutomation::Window do
38
47
 
39
48
  it "#hwnd" do
40
49
  RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).hwnd.should be_a(Fixnum)
50
+ RAutomation::Window.wait_timeout = 0.1
41
51
  lambda {RAutomation::Window.new(:title => "non-existing-window").hwnd}.
42
52
  should raise_exception(RAutomation::UnknownWindowException)
43
53
  end
44
54
 
45
55
  it "#title" do
46
56
  RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).title.should == SpecHelper::DATA[:window2_title]
57
+ RAutomation::Window.wait_timeout = 0.1
47
58
  lambda {RAutomation::Window.new(:title => "non-existing-window").title}.
48
59
  should raise_exception(RAutomation::UnknownWindowException)
49
60
  end
@@ -59,12 +70,14 @@ describe RAutomation::Window do
59
70
 
60
71
  it "#text" do
61
72
  RAutomation::Window.new(:title => SpecHelper::DATA[:window2_title]).text.should include(SpecHelper::DATA[:window2_text])
73
+ RAutomation::Window.wait_timeout = 0.1
62
74
  lambda {RAutomation::Window.new(:title => "non-existing-window").text}.
63
75
  should raise_exception(RAutomation::UnknownWindowException)
64
76
  end
65
77
 
66
78
  it "#maximize" do
67
79
  RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).maximize
80
+ RAutomation::Window.wait_timeout = 0.1
68
81
  lambda {RAutomation::Window.new(:title => "non-existing-window").maximize}.
69
82
  should raise_exception(RAutomation::UnknownWindowException)
70
83
  end
@@ -75,6 +88,7 @@ describe RAutomation::Window do
75
88
  window.minimize
76
89
  window.should be_minimized
77
90
 
91
+ RAutomation::Window.wait_timeout = 0.1
78
92
  lambda {RAutomation::Window.new(:title => "non-existing-window").minimize}.
79
93
  should raise_exception(RAutomation::UnknownWindowException)
80
94
  lambda {RAutomation::Window.new(:title => "non-existing-window").minimized?}.
@@ -83,6 +97,7 @@ describe RAutomation::Window do
83
97
 
84
98
  it "#restore" do
85
99
  RAutomation::Window.new(:title => SpecHelper::DATA[:window1_title]).restore
100
+ RAutomation::Window.wait_timeout = 0.1
86
101
  lambda {RAutomation::Window.new(:title => "non-existing-window").restore}.
87
102
  should raise_exception(RAutomation::UnknownWindowException)
88
103
  end
@@ -93,6 +108,7 @@ describe RAutomation::Window do
93
108
  window.send_keys(SpecHelper::DATA[:window2_send_keys])
94
109
  RAutomation::WaitHelper.wait_until(15) {not window.exists?}
95
110
 
111
+ RAutomation::Window.wait_timeout = 0.1
96
112
  lambda {RAutomation::Window.new(:title => "non-existing-window").send_keys("123")}.
97
113
  should raise_exception(RAutomation::UnknownWindowException)
98
114
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rautomation
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jarmo Pertman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-15 00:00:00 +03:00
18
+ date: 2010-10-27 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency