seleniumrc 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +4 -0
- data/README +38 -0
- data/Rakefile +1 -1
- data/lib/seleniumrc.rb +2 -4
- data/lib/seleniumrc/dsl/selenium_dsl.rb +8 -143
- data/lib/seleniumrc/extensions/testrunnermediator.rb +2 -2
- data/lib/seleniumrc/mongrel_selenium_server_runner.rb +9 -7
- data/lib/seleniumrc/selenium_configuration.rb +233 -40
- data/lib/seleniumrc/selenium_driver.rb +193 -0
- data/lib/seleniumrc/selenium_element.rb +31 -37
- data/lib/seleniumrc/selenium_page.rb +16 -16
- data/lib/seleniumrc/selenium_server_runner.rb +1 -1
- data/lib/seleniumrc/selenium_test_case.rb +2 -4
- data/lib/seleniumrc/wait_for.rb +3 -10
- data/lib/seleniumrc/webrick_selenium_server_runner.rb +11 -11
- data/spec/seleniumrc/mongrel_selenium_server_runner_spec.rb +31 -38
- data/spec/seleniumrc/selenese_interpreter_spec.rb +12 -12
- data/spec/seleniumrc/selenium_configuration_spec.rb +350 -12
- data/spec/seleniumrc/selenium_driver_spec.rb +104 -0
- data/spec/seleniumrc/selenium_element_spec.rb +78 -76
- data/spec/seleniumrc/selenium_page_spec.rb +39 -29
- data/spec/seleniumrc/selenium_test_case_spec.rb +631 -673
- data/spec/seleniumrc/selenium_test_case_spec_helper.rb +0 -7
- data/spec/seleniumrc/webrick_selenium_server_runner_spec.rb +14 -13
- data/spec/spec_helper.rb +7 -1
- metadata +4 -7
- data/lib/seleniumrc/app_server_checker.rb +0 -43
- data/lib/seleniumrc/extensions/selenium_driver.rb +0 -33
- data/lib/seleniumrc/selenium_context.rb +0 -226
- data/spec/seleniumrc/app_server_checker_spec.rb +0 -56
- data/spec/seleniumrc/selenium_context_spec.rb +0 -362
@@ -1,362 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
-
|
3
|
-
module Seleniumrc
|
4
|
-
describe SeleniumContext do
|
5
|
-
before(:each) do
|
6
|
-
@context = Seleniumrc::SeleniumContext.new
|
7
|
-
@old_rails_root = RAILS_ROOT if Object.const_defined? :RAILS_ROOT
|
8
|
-
silence_warnings { Object.const_set :RAILS_ROOT, "foobar" }
|
9
|
-
require 'webrick_server'
|
10
|
-
end
|
11
|
-
|
12
|
-
after(:each) do
|
13
|
-
if @old_rails_root
|
14
|
-
silence_warnings { Object.const_set :RAILS_ROOT, @old_rails_root }
|
15
|
-
else
|
16
|
-
Object.instance_eval {remove_const :RAILS_ROOT}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "registers and notifies before_suite callbacks" do
|
21
|
-
proc1_called = false
|
22
|
-
proc1 = lambda {proc1_called = true}
|
23
|
-
proc2_called = false
|
24
|
-
proc2 = lambda {proc2_called = true}
|
25
|
-
|
26
|
-
@context.before_suite(&proc1)
|
27
|
-
@context.before_suite(&proc2)
|
28
|
-
@context.notify_before_suite
|
29
|
-
proc1_called.should == true
|
30
|
-
proc2_called.should == true
|
31
|
-
end
|
32
|
-
|
33
|
-
it "registers and notifies after_selenese_interpreter_started callbacks" do
|
34
|
-
proc1_args = nil
|
35
|
-
proc1 = lambda {|*args| proc1_args = args}
|
36
|
-
proc2_args = nil
|
37
|
-
proc2 = lambda {|*args| proc2_args = args}
|
38
|
-
|
39
|
-
@context.after_selenese_interpreter_started(&proc1)
|
40
|
-
@context.after_selenese_interpreter_started(&proc2)
|
41
|
-
|
42
|
-
expected_interpreter = Object.new
|
43
|
-
@context.notify_after_selenese_interpreter_started(expected_interpreter)
|
44
|
-
proc1_args.should == [expected_interpreter]
|
45
|
-
proc2_args.should == [expected_interpreter]
|
46
|
-
end
|
47
|
-
|
48
|
-
it "creates app server checker" do
|
49
|
-
app_server_checker = @context.create_app_server_checker
|
50
|
-
app_server_checker.context.should == @context
|
51
|
-
app_server_checker.tcp_socket_class.should == TCPSocket
|
52
|
-
end
|
53
|
-
|
54
|
-
it "defaults to true for verify_remote_app_server_is_running" do
|
55
|
-
@context.verify_remote_app_server_is_running.should == true
|
56
|
-
end
|
57
|
-
|
58
|
-
it "creates a Selenese interpreter and notify listeners" do
|
59
|
-
@context.selenium_server_host = "selenium_server_host.com"
|
60
|
-
@context.selenium_server_port = 80
|
61
|
-
@context.current_browser = "iexplore"
|
62
|
-
@context.external_app_server_host = "browser_host.com"
|
63
|
-
@context.external_app_server_port = 80
|
64
|
-
|
65
|
-
interpreter = @context.create_interpreter
|
66
|
-
interpreter.server_host.should == "selenium_server_host.com"
|
67
|
-
interpreter.server_port.should == 80
|
68
|
-
interpreter.browser_start_command.should == "*iexplore"
|
69
|
-
interpreter.browser_url.should == "http://browser_host.com:80"
|
70
|
-
end
|
71
|
-
|
72
|
-
it "creates, initializes. and notifies listeners for a Selenese interpreter " do
|
73
|
-
passed_interpreter = nil
|
74
|
-
@context.after_selenese_interpreter_started {|interpreter| passed_interpreter = interpreter}
|
75
|
-
|
76
|
-
stub_interpreter = Object.new
|
77
|
-
start_called = false
|
78
|
-
stub(stub_interpreter).start.returns {start_called = true}
|
79
|
-
stub(@context).create_interpreter.returns {stub_interpreter}
|
80
|
-
interpreter = @context.create_and_initialize_interpreter
|
81
|
-
interpreter.should == stub_interpreter
|
82
|
-
passed_interpreter.should == interpreter
|
83
|
-
start_called.should == true
|
84
|
-
end
|
85
|
-
|
86
|
-
it "creates a Webrick Server Runner" do
|
87
|
-
@context.selenium_server_port = 4000
|
88
|
-
@context.selenium_server_host = "localhost"
|
89
|
-
dir = File.dirname(__FILE__)
|
90
|
-
@context.rails_root = dir
|
91
|
-
@context.rails_env = "test"
|
92
|
-
|
93
|
-
runner = @context.create_webrick_runner
|
94
|
-
runner.should be_an_instance_of(Seleniumrc::WebrickSeleniumServerRunner)
|
95
|
-
runner.context.should == @context
|
96
|
-
runner.thread_class.should == Thread
|
97
|
-
runner.socket.should == Socket
|
98
|
-
runner.dispatch_servlet.should == DispatchServlet
|
99
|
-
runner.environment_path.should == File.expand_path("#{dir}/config/environment")
|
100
|
-
end
|
101
|
-
|
102
|
-
it "creates webrick http server" do
|
103
|
-
@context.internal_app_server_port = 4000
|
104
|
-
@context.internal_app_server_host = "localhost"
|
105
|
-
|
106
|
-
mock_logger = "logger"
|
107
|
-
mock(@context).new_logger.returns(mock_logger)
|
108
|
-
mock(WEBrick::HTTPServer).new.with({
|
109
|
-
:Port => 4000,
|
110
|
-
:BindAddress => "localhost",
|
111
|
-
:ServerType => WEBrick::SimpleServer,
|
112
|
-
:MimeTypes => WEBrick::HTTPUtils::DefaultMimeTypes,
|
113
|
-
:Logger => mock_logger,
|
114
|
-
:AccessLog => []
|
115
|
-
})
|
116
|
-
server = @context.create_webrick_server
|
117
|
-
end
|
118
|
-
|
119
|
-
it "creates Mongrel Server Runner" do
|
120
|
-
server = @context.create_mongrel_runner
|
121
|
-
server.should be_instance_of(Seleniumrc::MongrelSeleniumServerRunner)
|
122
|
-
server.context.should == @context
|
123
|
-
server.thread_class.should == Thread
|
124
|
-
end
|
125
|
-
|
126
|
-
it "creates Mongrel configurator" do
|
127
|
-
@context.internal_app_server_host = "localhost"
|
128
|
-
@context.internal_app_server_port = 4000
|
129
|
-
@context.rails_env = "test"
|
130
|
-
@context.rails_root = File.dirname(__FILE__)
|
131
|
-
|
132
|
-
configurator = @context.create_mongrel_configurator
|
133
|
-
configurator.defaults[:host].should == "localhost"
|
134
|
-
configurator.defaults[:port].should == 4000
|
135
|
-
configurator.defaults[:cwd].should == @context.rails_root
|
136
|
-
configurator.defaults[:log_file].should == "#{@context.rails_root}/log/mongrel.log"
|
137
|
-
configurator.defaults[:pid_file].should == "#{@context.rails_root}/log/mongrel.pid"
|
138
|
-
configurator.defaults[:environment].should == "test"
|
139
|
-
configurator.defaults[:docroot].should == "public"
|
140
|
-
configurator.defaults[:mime_map].should be_nil
|
141
|
-
configurator.defaults[:daemon].should == false
|
142
|
-
configurator.defaults[:debug].should == false
|
143
|
-
configurator.defaults[:includes].should == ["mongrel"]
|
144
|
-
configurator.defaults[:config_script].should be_nil
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context SeleniumConfiguration, "#establish_environment" do
|
149
|
-
before(:each) do
|
150
|
-
Seleniumrc::SeleniumConfiguration.instance_eval {@context = nil}
|
151
|
-
@configuration = Seleniumrc::SeleniumConfiguration.instance
|
152
|
-
@context = @configuration
|
153
|
-
end
|
154
|
-
|
155
|
-
it "establish_environment__webrick_host" do
|
156
|
-
should_establish_environment( 'internal_app_server_host', '192.168.10.1', :internal_app_server_host )
|
157
|
-
end
|
158
|
-
|
159
|
-
it "initializes webrick_port" do
|
160
|
-
should_establish_environment( 'internal_app_server_port', 1337, :internal_app_server_port )
|
161
|
-
end
|
162
|
-
|
163
|
-
it "initializes internal_app_server_port" do
|
164
|
-
should_establish_environment( 'external_app_server_port', 1337, :external_app_server_port )
|
165
|
-
end
|
166
|
-
|
167
|
-
it "initializes internal_app_server_host" do
|
168
|
-
should_establish_environment( 'external_app_server_host', 'sammich.com', :external_app_server_host)
|
169
|
-
end
|
170
|
-
|
171
|
-
it "initializes selenium_server_host" do
|
172
|
-
should_establish_environment( 'selenium_server_host', 'sammich.com')
|
173
|
-
end
|
174
|
-
|
175
|
-
it "initializes selenium_server_host" do
|
176
|
-
should_establish_environment( 'selenium_server_port', 1337)
|
177
|
-
end
|
178
|
-
|
179
|
-
it "initializes app_server_engine" do
|
180
|
-
should_establish_environment( 'app_server_engine', :webrick, :app_server_engine)
|
181
|
-
end
|
182
|
-
|
183
|
-
it "initializes browsers" do
|
184
|
-
@context.env = stub_env
|
185
|
-
env_var = "browsers"
|
186
|
-
expected_value = 'konqueror'
|
187
|
-
stub_env[env_var] = expected_value
|
188
|
-
Seleniumrc::SeleniumConfiguration.send :establish_environment
|
189
|
-
@configuration.browsers.should == [expected_value]
|
190
|
-
end
|
191
|
-
|
192
|
-
it "initializes keep_browser_open_on_failure" do
|
193
|
-
@context.env = stub_env
|
194
|
-
env_var = 'keep_browser_open_on_failure'
|
195
|
-
stub_env[env_var] = 'false'
|
196
|
-
Seleniumrc::SeleniumConfiguration.send :establish_environment
|
197
|
-
@configuration.send(env_var).should == false
|
198
|
-
@configuration.send(env_var).should == false
|
199
|
-
|
200
|
-
stub_env[env_var] = 'true'
|
201
|
-
Seleniumrc::SeleniumConfiguration.send :establish_environment
|
202
|
-
@configuration.send(env_var).should == true
|
203
|
-
@configuration.send(env_var).should == true
|
204
|
-
|
205
|
-
stub_env[env_var] = 'blah'
|
206
|
-
Seleniumrc::SeleniumConfiguration.send :establish_environment
|
207
|
-
@configuration.send(env_var).should == true
|
208
|
-
@configuration.send(env_var).should == true
|
209
|
-
end
|
210
|
-
|
211
|
-
it "initializes verify_remote_app_server_is_running" do
|
212
|
-
@context.env = stub_env
|
213
|
-
env_var = 'verify_remote_app_server_is_running'
|
214
|
-
stub_env[env_var] = 'false'
|
215
|
-
Seleniumrc::SeleniumConfiguration.send :establish_environment
|
216
|
-
@configuration.send(env_var).should == false
|
217
|
-
@configuration.send(env_var).should == false
|
218
|
-
|
219
|
-
stub_env[env_var] = 'true'
|
220
|
-
Seleniumrc::SeleniumConfiguration.send :establish_environment
|
221
|
-
@configuration.send(env_var).should == true
|
222
|
-
@configuration.send(env_var).should == true
|
223
|
-
|
224
|
-
stub_env[env_var] = 'blah'
|
225
|
-
Seleniumrc::SeleniumConfiguration.send :establish_environment
|
226
|
-
@configuration.send(env_var).should == true
|
227
|
-
@configuration.send(env_var).should == true
|
228
|
-
end
|
229
|
-
|
230
|
-
it "internal_app_server_host" do
|
231
|
-
should_lazily_load @configuration, :internal_app_server_host, "0.0.0.0"
|
232
|
-
end
|
233
|
-
|
234
|
-
it "internal_app_server_port" do
|
235
|
-
should_lazily_load @configuration, :internal_app_server_port, 4000
|
236
|
-
end
|
237
|
-
|
238
|
-
it "external_app_server_host" do
|
239
|
-
should_lazily_load @configuration, :external_app_server_host, "localhost"
|
240
|
-
end
|
241
|
-
|
242
|
-
it "external_app_server_port" do
|
243
|
-
should_lazily_load @configuration, :external_app_server_port, 4000
|
244
|
-
end
|
245
|
-
|
246
|
-
it "browsers__lazy_loaded" do
|
247
|
-
should_lazily_load @configuration, :browsers, [Seleniumrc::SeleniumConfiguration::FIREFOX]
|
248
|
-
end
|
249
|
-
|
250
|
-
it "keep_browser_open_on_failure" do
|
251
|
-
should_lazily_load @configuration, :keep_browser_open_on_failure, true
|
252
|
-
end
|
253
|
-
|
254
|
-
it "formatted_browser" do
|
255
|
-
@configuration.current_browser = Seleniumrc::SeleniumConfiguration::IEXPLORE
|
256
|
-
@configuration.formatted_browser.should == "*iexplore"
|
257
|
-
end
|
258
|
-
|
259
|
-
it "browser_url" do
|
260
|
-
@configuration.external_app_server_host = "test.com"
|
261
|
-
@configuration.external_app_server_port = 101
|
262
|
-
@configuration.browser_url.should == "http://test.com:101"
|
263
|
-
end
|
264
|
-
|
265
|
-
it "run_each_browser_within_the_browsers" do
|
266
|
-
expected_browsers = ["iexplore", "firefox", "custom"]
|
267
|
-
@configuration.browsers = expected_browsers
|
268
|
-
|
269
|
-
index = 0
|
270
|
-
@configuration.run_each_browser do
|
271
|
-
@configuration.current_browser.should == expected_browsers[index]
|
272
|
-
index += 1
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
it "selenese_interpreter__when_in_test_browser_mode__should_be_nil" do
|
277
|
-
@configuration.test_browser_mode!
|
278
|
-
@configuration.selenese_interpreter.should be_nil
|
279
|
-
end
|
280
|
-
|
281
|
-
protected
|
282
|
-
def should_establish_environment( env_var, expected_value, method_name=nil )
|
283
|
-
method_name = env_var unless method_name
|
284
|
-
@context.env = stub_env
|
285
|
-
stub_env[env_var] = expected_value
|
286
|
-
Seleniumrc::SeleniumConfiguration.send :establish_environment
|
287
|
-
Seleniumrc::SeleniumConfiguration.instance.send(method_name).should == expected_value
|
288
|
-
end
|
289
|
-
|
290
|
-
def stub_env
|
291
|
-
@stub_env ||= {}
|
292
|
-
end
|
293
|
-
|
294
|
-
def should_lazily_load(object, method_name, default_value)
|
295
|
-
object.send(method_name).should == default_value
|
296
|
-
test_object = Object.new
|
297
|
-
object.send(method_name.to_s + "=", test_object)
|
298
|
-
object.send(method_name).should == test_object
|
299
|
-
end
|
300
|
-
|
301
|
-
end
|
302
|
-
|
303
|
-
describe SeleniumContext, "#stop_interpreter_if_necessary" do
|
304
|
-
before(:each) do
|
305
|
-
@context = Seleniumrc::SeleniumContext.new
|
306
|
-
end
|
307
|
-
|
308
|
-
it "when suite passes, should stop interpreter" do
|
309
|
-
mock_interpreter = "mock_interpreter"
|
310
|
-
mock(mock_interpreter).stop.once
|
311
|
-
@context.interpreter = mock_interpreter
|
312
|
-
|
313
|
-
@context.stop_interpreter_if_necessary true
|
314
|
-
end
|
315
|
-
|
316
|
-
it "when suite fails and keep browser open on failure, should not stop interpreter" do
|
317
|
-
mock_interpreter = "mock_interpreter"
|
318
|
-
mock(mock_interpreter).stop.never
|
319
|
-
@context.interpreter = mock_interpreter
|
320
|
-
@context.keep_browser_open_on_failure = true
|
321
|
-
|
322
|
-
@context.stop_interpreter_if_necessary false
|
323
|
-
end
|
324
|
-
|
325
|
-
it "when suite fails and not keep browser open on failure, should stop interpreter" do
|
326
|
-
mock_interpreter = "mock_interpreter"
|
327
|
-
mock(mock_interpreter).stop
|
328
|
-
@context.interpreter = mock_interpreter
|
329
|
-
@context.keep_browser_open_on_failure = false
|
330
|
-
|
331
|
-
@context.stop_interpreter_if_necessary false
|
332
|
-
end
|
333
|
-
|
334
|
-
end
|
335
|
-
|
336
|
-
describe SeleniumContext, "#create_server_runner where application server engine is mongrel" do
|
337
|
-
it "creates a mongrel server runner" do
|
338
|
-
context = Seleniumrc::SeleniumContext.new
|
339
|
-
context.app_server_engine = :mongrel
|
340
|
-
runner = context.create_server_runner
|
341
|
-
runner.should be_instance_of(MongrelSeleniumServerRunner)
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
context SeleniumContext, "#create_server_runner where application server engine is webrick" do
|
346
|
-
before do
|
347
|
-
Object.const_set :RAILS_ROOT, "foobar"
|
348
|
-
require 'webrick_server'
|
349
|
-
end
|
350
|
-
|
351
|
-
after do
|
352
|
-
Object.instance_eval {remove_const :RAILS_ROOT}
|
353
|
-
end
|
354
|
-
|
355
|
-
it "creates a webrick server runner" do
|
356
|
-
context = Seleniumrc::SeleniumContext.new
|
357
|
-
context.app_server_engine = :webrick
|
358
|
-
runner = context.create_server_runner
|
359
|
-
runner.should be_instance_of(WebrickSeleniumServerRunner)
|
360
|
-
end
|
361
|
-
end
|
362
|
-
end
|