bauxite 0.5.0 → 0.6.0
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.
- checksums.yaml +4 -4
- data/Rakefile +20 -3
- data/doc/Bauxite/Action.html +92 -9
- data/doc/Bauxite/Context.html +63 -144
- data/doc/created.rid +8 -7
- data/doc/js/search_index.js +1 -1
- data/doc/table_of_contents.html +37 -37
- data/lib/bauxite/actions/capture.rb +66 -0
- data/lib/bauxite/actions/debug.rb +3 -1
- data/lib/bauxite/actions/failif.rb +8 -2
- data/lib/bauxite/actions/setif.rb +8 -4
- data/lib/bauxite/actions/test.rb +4 -3
- data/lib/bauxite/application.rb +16 -2
- data/lib/bauxite/core/context.rb +37 -88
- data/lib/bauxite.rb +1 -1
- data/test/capture/my_test.bxt +1 -0
- data/test/capture/page.html +7 -0
- data/test/capture.bxt.manual +20 -0
- data/test/debug.bxt.manual +1 -0
- data/test/failif/page.html +2 -1
- data/test/failif.bxt +1 -0
- metadata +7 -2
data/lib/bauxite/core/context.rb
CHANGED
@@ -143,7 +143,8 @@ module Bauxite
|
|
143
143
|
@variables = {
|
144
144
|
'__TIMEOUT__' => (options[:timeout] || 10).to_i,
|
145
145
|
'__DEBUG__' => false,
|
146
|
-
'__SELECTOR__' => options[:selector] || 'sid'
|
146
|
+
'__SELECTOR__' => options[:selector] || 'sid',
|
147
|
+
'__OUTPUT__' => options[:output]
|
147
148
|
}
|
148
149
|
@aliases = {}
|
149
150
|
@tests = []
|
@@ -155,9 +156,7 @@ module Bauxite
|
|
155
156
|
|
156
157
|
_load_extensions(options[:extensions] || [])
|
157
158
|
|
158
|
-
|
159
|
-
@logger = Context::load_logger(options[:logger], options[:logger_opt])
|
160
|
-
end
|
159
|
+
@logger = Context::load_logger(options[:logger], options[:logger_opt])
|
161
160
|
|
162
161
|
@parser = Parser.new(self)
|
163
162
|
end
|
@@ -181,7 +180,13 @@ module Bauxite
|
|
181
180
|
return unless actions.size > 0
|
182
181
|
begin
|
183
182
|
actions.each do |action|
|
184
|
-
|
183
|
+
begin
|
184
|
+
exec_action(action)
|
185
|
+
rescue StandardError => e
|
186
|
+
print_error(e)
|
187
|
+
raise unless @options[:debug]
|
188
|
+
debug
|
189
|
+
end
|
185
190
|
end
|
186
191
|
ensure
|
187
192
|
stop
|
@@ -310,78 +315,29 @@ module Bauxite
|
|
310
315
|
# Executes the specified action handling errors, logging and debug
|
311
316
|
# history.
|
312
317
|
#
|
318
|
+
# If +log+ is +true+, log the action execution (default behavior).
|
319
|
+
#
|
313
320
|
# This method if part of the action execution chain and is intended
|
314
321
|
# for advanced use (e.g. in complex actions). To execute an Action
|
315
322
|
# directly, the #exec_action method is preferred.
|
316
323
|
#
|
317
|
-
# If +log+ is +true+, log the action execution (default behavior).
|
318
|
-
#
|
319
324
|
# For example:
|
320
325
|
# ctx.exec_action 'open "http://www.ruby-lang.org"'
|
321
326
|
# # => navigates to www.ruby-lang.org
|
322
327
|
#
|
323
328
|
def exec_parsed_action(action, args, log = true, text = nil, file = nil, line = nil)
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
Readline::HISTORY << action.text
|
331
|
-
exec_action_object(action)
|
332
|
-
end
|
333
|
-
else
|
334
|
-
exec_action_object(action)
|
329
|
+
action = get_action(action, args, text, file, line)
|
330
|
+
ret = nil
|
331
|
+
if log
|
332
|
+
@logger.log_cmd(action) do
|
333
|
+
Readline::HISTORY << action.text
|
334
|
+
ret = exec_action_object(action)
|
335
335
|
end
|
336
|
-
end
|
337
|
-
handle_errors(true) do
|
338
|
-
ret.call if ret.respond_to? :call # delayed actions (after log_cmd)
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
|
343
|
-
# Executes the +block+ inside a rescue block applying standard criteria of
|
344
|
-
# error handling.
|
345
|
-
#
|
346
|
-
# The default behavior is to print the exception message and exit.
|
347
|
-
#
|
348
|
-
# If the +:verbose+ option is set, the exception backtrace will also be
|
349
|
-
# printed.
|
350
|
-
#
|
351
|
-
# If the +break_into_debug+ argument is +true+ and the +:debug+ option is
|
352
|
-
# set, the handler will break into the debug console instead of exiting.
|
353
|
-
#
|
354
|
-
# If the +exit_on_error+ argument is +false+ the handler will not exit
|
355
|
-
# after printing the error message.
|
356
|
-
#
|
357
|
-
# For example:
|
358
|
-
# ctx = Context.new({ :debug => true })
|
359
|
-
# ctx.handle_errors(true) { raise 'break into debug now!' }
|
360
|
-
# # => this breaks into the debug console
|
361
|
-
#
|
362
|
-
def handle_errors(break_into_debug = false, exit_on_error = true)
|
363
|
-
yield
|
364
|
-
rescue StandardError => e
|
365
|
-
if @logger
|
366
|
-
@logger.log "#{e.message}\n", :error
|
367
336
|
else
|
368
|
-
|
369
|
-
end
|
370
|
-
if @options[:verbose]
|
371
|
-
p e
|
372
|
-
puts e.backtrace
|
373
|
-
end
|
374
|
-
unless @variables['__DEBUG__']
|
375
|
-
if break_into_debug and @options[:debug]
|
376
|
-
debug
|
377
|
-
elsif exit_on_error
|
378
|
-
if @variables['__RAISE_ERROR__']
|
379
|
-
raise
|
380
|
-
else
|
381
|
-
exit false
|
382
|
-
end
|
383
|
-
end
|
337
|
+
ret = exec_action_object(action)
|
384
338
|
end
|
339
|
+
|
340
|
+
ret.call if ret.respond_to? :call # delayed actions (after log_cmd)
|
385
341
|
end
|
386
342
|
|
387
343
|
# Executes the given block retrying for at most <tt>${__TIMEOUT__}</tt>
|
@@ -556,35 +512,28 @@ module Bauxite
|
|
556
512
|
action.execute
|
557
513
|
end
|
558
514
|
|
559
|
-
#
|
560
|
-
#
|
515
|
+
# Prints the specified +error+ using the Logger configured and
|
516
|
+
# handling the verbose option.
|
561
517
|
#
|
562
|
-
# This method is intended to simplify conditional actions that execute
|
563
|
-
# different code depending on the outcome of an action execution.
|
564
|
-
#
|
565
518
|
# For example:
|
566
|
-
#
|
567
|
-
# # =>
|
568
|
-
#
|
569
|
-
#
|
519
|
+
# begin
|
520
|
+
# # => some code here
|
521
|
+
# rescue StandardError => e
|
522
|
+
# @ctx.print_error e
|
523
|
+
# # => additional error handling code here
|
570
524
|
# end
|
571
525
|
#
|
572
|
-
def
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
rescue Bauxite::Errors::AssertionError
|
582
|
-
false
|
583
|
-
end
|
584
|
-
end
|
526
|
+
def print_error(e)
|
527
|
+
if @logger
|
528
|
+
@logger.log "#{e.message}\n", :error
|
529
|
+
else
|
530
|
+
puts e.message
|
531
|
+
end
|
532
|
+
if @options[:verbose]
|
533
|
+
p e
|
534
|
+
puts e.backtrace
|
585
535
|
end
|
586
536
|
end
|
587
|
-
|
588
537
|
|
589
538
|
# ======================================================================= #
|
590
539
|
# :section: Metadata
|
data/lib/bauxite.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
capture
|
@@ -0,0 +1,20 @@
|
|
1
|
+
open "file://${__DIR__}/capture/page.html"
|
2
|
+
write by_id hello
|
3
|
+
|
4
|
+
# Seq 0
|
5
|
+
capture
|
6
|
+
|
7
|
+
# Seq 1
|
8
|
+
capture
|
9
|
+
|
10
|
+
# Seq 2
|
11
|
+
capture
|
12
|
+
|
13
|
+
# With name
|
14
|
+
capture with_name.png
|
15
|
+
|
16
|
+
# With test name
|
17
|
+
test "capture/my_test.bxt"
|
18
|
+
|
19
|
+
# With named test name
|
20
|
+
test "capture/my_test.bxt" named_test
|
@@ -0,0 +1 @@
|
|
1
|
+
assertv true false
|
data/test/failif/page.html
CHANGED
data/test/failif.bxt
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bauxite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patricio Zavolinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/bauxite/actions/assert.rb
|
121
121
|
- lib/bauxite/actions/assertv.rb
|
122
122
|
- lib/bauxite/actions/break.rb
|
123
|
+
- lib/bauxite/actions/capture.rb
|
123
124
|
- lib/bauxite/actions/click.rb
|
124
125
|
- lib/bauxite/actions/debug.rb
|
125
126
|
- lib/bauxite/actions/doif.rb
|
@@ -165,6 +166,10 @@ files:
|
|
165
166
|
- lib/bauxite/selectors/smart.rb
|
166
167
|
- test/alias.bxt
|
167
168
|
- test/assertv.bxt
|
169
|
+
- test/capture.bxt.manual
|
170
|
+
- test/capture/my_test.bxt
|
171
|
+
- test/capture/page.html
|
172
|
+
- test/debug.bxt.manual
|
168
173
|
- test/default_selector.bxt.manual
|
169
174
|
- test/default_selector/page.html
|
170
175
|
- test/default_selector_var.bxt
|