bauxite 0.6.18 → 0.6.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -21
- data/README.md +293 -293
- data/Rakefile +128 -128
- data/bin/bauxite +27 -27
- data/doc/Bauxite.html +6 -9
- data/doc/Bauxite/Action.html +298 -315
- data/doc/Bauxite/ActionModule.html +23 -26
- data/doc/Bauxite/Application.html +36 -38
- data/doc/Bauxite/Context.html +303 -303
- data/doc/Bauxite/Errors.html +6 -9
- data/doc/Bauxite/Errors/AssertionError.html +6 -9
- data/doc/Bauxite/Errors/FileNotFoundError.html +6 -9
- data/doc/Bauxite/Errors/FormatError.html +6 -9
- data/doc/Bauxite/Loggers.html +6 -9
- data/doc/Bauxite/Loggers/CompositeLogger.html +29 -32
- data/doc/Bauxite/Loggers/EchoLogger.html +10 -13
- data/doc/Bauxite/Loggers/FileLogger.html +25 -28
- data/doc/Bauxite/Loggers/HtmlLogger.html +99 -102
- data/doc/Bauxite/Loggers/NullLogger.html +16 -19
- data/doc/Bauxite/Loggers/ReportLogger.html +43 -46
- data/doc/Bauxite/Loggers/TerminalLogger.html +76 -79
- data/doc/Bauxite/Loggers/XtermLogger.html +28 -31
- data/doc/Bauxite/Parser.html +87 -89
- data/doc/Bauxite/ParserModule.html +19 -22
- data/doc/Bauxite/Selector.html +99 -105
- data/doc/Bauxite/SelectorModule.html +27 -30
- data/doc/README_md.html +117 -103
- data/doc/created.rid +58 -58
- data/doc/fonts.css +167 -167
- data/doc/fonts/Lato-Light.ttf +0 -0
- data/doc/fonts/Lato-LightItalic.ttf +0 -0
- data/doc/fonts/Lato-Regular.ttf +0 -0
- data/doc/fonts/Lato-RegularItalic.ttf +0 -0
- data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/doc/images/add.png +0 -0
- data/doc/images/arrow_up.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +117 -103
- data/doc/js/darkfish.js +32 -11
- data/doc/js/jquery.js +0 -0
- data/doc/js/navigation.js +0 -0
- data/doc/js/search.js +0 -0
- data/doc/js/search_index.js +1 -1
- data/doc/js/searcher.js +0 -0
- data/doc/rdoc.css +580 -580
- data/doc/table_of_contents.html +69 -72
- data/lib/bauxite.rb +28 -28
- data/lib/bauxite/actions/alias.rb +51 -51
- data/lib/bauxite/actions/assert.rb +49 -49
- data/lib/bauxite/actions/asserth.rb +60 -60
- data/lib/bauxite/actions/assertm.rb +49 -49
- data/lib/bauxite/actions/assertv.rb +40 -40
- data/lib/bauxite/actions/assertw.rb +47 -47
- data/lib/bauxite/actions/break.rb +39 -39
- data/lib/bauxite/actions/capture.rb +61 -61
- data/lib/bauxite/actions/click.rb +36 -36
- data/lib/bauxite/actions/debug.rb +103 -103
- data/lib/bauxite/actions/doif.rb +43 -43
- data/lib/bauxite/actions/dounless.rb +43 -43
- data/lib/bauxite/actions/echo.rb +36 -36
- data/lib/bauxite/actions/exec.rb +46 -46
- data/lib/bauxite/actions/exit.rb +35 -35
- data/lib/bauxite/actions/failif.rb +52 -52
- data/lib/bauxite/actions/js.rb +41 -41
- data/lib/bauxite/actions/load.rb +49 -49
- data/lib/bauxite/actions/open.rb +35 -35
- data/lib/bauxite/actions/params.rb +40 -40
- data/lib/bauxite/actions/replace.rb +37 -37
- data/lib/bauxite/actions/reset.rb +38 -38
- data/lib/bauxite/actions/return.rb +68 -68
- data/lib/bauxite/actions/ruby.rb +58 -58
- data/lib/bauxite/actions/select.rb +48 -48
- data/lib/bauxite/actions/set.rb +39 -39
- data/lib/bauxite/actions/setif.rb +44 -44
- data/lib/bauxite/actions/source.rb +44 -44
- data/lib/bauxite/actions/store.rb +38 -38
- data/lib/bauxite/actions/submit.rb +37 -37
- data/lib/bauxite/actions/test.rb +67 -67
- data/lib/bauxite/actions/tryload.rb +71 -71
- data/lib/bauxite/actions/wait.rb +38 -38
- data/lib/bauxite/actions/write.rb +44 -44
- data/lib/bauxite/application.rb +349 -349
- data/lib/bauxite/core/action.rb +199 -199
- data/lib/bauxite/core/context.rb +791 -791
- data/lib/bauxite/core/errors.rb +41 -41
- data/lib/bauxite/core/logger.rb +169 -169
- data/lib/bauxite/core/parser.rb +85 -85
- data/lib/bauxite/core/selector.rb +152 -152
- data/lib/bauxite/loggers/composite.rb +91 -91
- data/lib/bauxite/loggers/echo.rb +36 -36
- data/lib/bauxite/loggers/file.rb +68 -68
- data/lib/bauxite/loggers/html.rb +154 -154
- data/lib/bauxite/loggers/terminal.rb +134 -134
- data/lib/bauxite/loggers/xterm.rb +101 -101
- data/lib/bauxite/parsers/csv.rb +43 -43
- data/lib/bauxite/parsers/default.rb +42 -42
- data/lib/bauxite/parsers/html.rb +79 -79
- data/lib/bauxite/selectors/attr.rb +39 -39
- data/lib/bauxite/selectors/frame.rb +60 -60
- data/lib/bauxite/selectors/json.rb +88 -88
- data/lib/bauxite/selectors/sid.rb +38 -38
- data/lib/bauxite/selectors/smart.rb +80 -80
- data/lib/bauxite/selectors/window.rb +77 -77
- data/test/alert.bxt +3 -3
- data/test/alert/page.html +4 -4
- data/test/alias.bxt +9 -9
- data/test/asserth.bxt +2 -2
- data/test/assertv.bxt +1 -1
- data/test/assertw.bxt +7 -7
- data/test/broken.bxt.manual +0 -0
- data/test/bug_load_path.bxt.manual +0 -0
- data/test/bug_load_path/broken.bxt.manual +0 -0
- data/test/bug_load_path/test.bxt +0 -0
- data/test/capture.bxt.manual +20 -20
- data/test/capture/my_test.bxt +1 -1
- data/test/capture/page.html +6 -6
- data/test/capture_on_error.bxt.manual +3 -3
- data/test/capture_on_error/my_test.bxt +1 -1
- data/test/capture_on_error/page.html +2 -2
- data/test/debug.bxt.manual +0 -0
- data/test/default_selector.bxt.manual +7 -7
- data/test/default_selector/page.html +10 -10
- data/test/default_selector_var.bxt +1 -1
- data/test/delay.bxt +2 -2
- data/test/delay/page.html +4 -4
- data/test/doif.bxt +6 -6
- data/test/dounless.bxt +6 -6
- data/test/exec.bxt +6 -6
- data/test/exit.bxt +3 -3
- data/test/exit/test.bxt +3 -3
- data/test/extension.bxt.manual +4 -4
- data/test/extension/custom.rb +12 -12
- data/test/extension/page.html +4 -4
- data/test/failif.bxt +7 -7
- data/test/failif/page.html +5 -5
- data/test/format.bxt +17 -17
- data/test/format/page.html +6 -6
- data/test/frame.bxt +6 -6
- data/test/frame/child_frame.html +6 -6
- data/test/frame/grandchild_frame.html +4 -4
- data/test/frame/page.html +4 -4
- data/test/js.bxt +4 -4
- data/test/json.bxt +19 -19
- data/test/json/array.json +3 -3
- data/test/json/object.json +13 -13
- data/test/load.bxt +18 -18
- data/test/load/child.bxt +12 -12
- data/test/parsers.bxt +1 -1
- data/test/parsers.csv +7 -7
- data/test/parsers.html +32 -32
- data/test/parsers/page.html +6 -6
- data/test/return.bxt +1 -1
- data/test/return/f1.bxt +1 -1
- data/test/return/f2.bxt +1 -1
- data/test/return/f3.bxt +1 -1
- data/test/return/f4.bxt +2 -2
- data/test/ruby.bxt +1 -1
- data/test/ruby/custom.rb +5 -5
- data/test/select.bxt +9 -9
- data/test/select/page.html +8 -8
- data/test/selectors.bxt +7 -7
- data/test/selectors/page.html +6 -6
- data/test/set_builtin.bxt +5 -0
- data/test/set_builtin/page.html +5 -0
- data/test/setif.bxt +3 -3
- data/test/smart_selector.bxt +17 -17
- data/test/smart_selector/page.html +17 -17
- data/test/stdin.bxt +0 -0
- data/test/submit.bxt +4 -4
- data/test/submit/page.html +6 -6
- data/test/submit/page2.html +4 -4
- data/test/test.bxt.manual +6 -6
- data/test/test/test1.bxt +2 -2
- data/test/test/test2.bxt +3 -3
- data/test/test/test3.bxt +2 -2
- data/test/test/test4.bxt +1 -1
- data/test/test/test5.bxt +1 -1
- data/test/window.bxt +14 -14
- data/test/window/page.html +5 -5
- data/test/window/popup.html +4 -4
- metadata +5 -3
data/Rakefile
CHANGED
@@ -1,129 +1,129 @@
|
|
1
|
-
task :default => [:test, :doc]
|
2
|
-
|
3
|
-
CURRENT_VERSION = `ruby -Ilib bin/bauxite --version`.gsub(/^.* /, '')
|
4
|
-
|
5
|
-
# === Gem Package =========================================================== #
|
6
|
-
require 'rubygems'
|
7
|
-
require 'rubygems/package_task'
|
8
|
-
|
9
|
-
spec = Gem::Specification.new do |s|
|
10
|
-
s.name = 'bauxite'
|
11
|
-
s.summary = 'Bauxite is a façade over Selenium intended for non-developers'
|
12
|
-
s.description = 'Bauxite is a façade over Selenium intended for non-developers. The idea behind this project was to create a tool that allows non-developers to write web tests in a human-readable language. Another major requirement is to be able to easily extend the test language to create functional abstractions over technical details.'
|
13
|
-
s.author = 'Patricio Zavolinsky'
|
14
|
-
s.email = 'pzavolinsky at yahoo dot com dot ar'
|
15
|
-
s.homepage = 'https://github.com/pzavolinsky/bauxite'
|
16
|
-
s.license = 'MIT'
|
17
|
-
s.version = CURRENT_VERSION
|
18
|
-
s.executables = ["bauxite"]
|
19
|
-
s.add_runtime_dependency 'selenium-webdriver', '~> 2.47'
|
20
|
-
s.add_development_dependency 'rake' , '~> 10.1'
|
21
|
-
s.files = FileList[
|
22
|
-
'LICENSE',
|
23
|
-
'README.md',
|
24
|
-
'Rakefile',
|
25
|
-
'bin/*',
|
26
|
-
'lib/**/*.rb',
|
27
|
-
'test/**/*',
|
28
|
-
'doc/**/*'
|
29
|
-
]
|
30
|
-
end
|
31
|
-
|
32
|
-
task :package => [ :test, :doc ]
|
33
|
-
task :gem => [ :test, :doc ]
|
34
|
-
|
35
|
-
Gem::PackageTask.new(spec) do |pkg|
|
36
|
-
pkg.need_zip = true
|
37
|
-
pkg.need_tar = true
|
38
|
-
end
|
39
|
-
|
40
|
-
# === Integration tests ===================================================== #
|
41
|
-
desc "Run integration tests"
|
42
|
-
task :test do
|
43
|
-
test_files = Dir[File.join('test', '*.bxt')].select { |f| not File.directory? f }.join(' ')
|
44
|
-
ruby "-Ilib bin/bauxite -v #{test_files}"
|
45
|
-
|
46
|
-
ruby "-Ilib bin/bauxite -v -e test/extension #{File.join('test', 'extension.bxt.manual')}"
|
47
|
-
|
48
|
-
ruby "-Ilib bin/bauxite -v -s css test/default_selector.bxt.manual"
|
49
|
-
|
50
|
-
system("ruby -Ilib bin/bauxite test/test.bxt.manual")
|
51
|
-
fail "The 'test' action test failed to return the expected exit status: the exit status was #{$?.exitstatus}" unless $?.exitstatus == 2
|
52
|
-
|
53
|
-
debug = `echo exit | ruby -Ilib bin/bauxite -l echo test/debug.bxt.manual -d`
|
54
|
-
puts debug
|
55
|
-
unless debug.include? 'debug> '
|
56
|
-
fail "The -d argument failed to open the debug console"
|
57
|
-
end
|
58
|
-
|
59
|
-
check = lambda { |f| fail "Captured file not found #{f}" unless File.exists? f }
|
60
|
-
|
61
|
-
system('rm -rf /tmp/bauxite-test')
|
62
|
-
ruby "-Ilib bin/bauxite --output /tmp/bauxite-test test/capture.bxt.manual"
|
63
|
-
check.call '/tmp/bauxite-test/test_capture_bxt_manual_0.png'
|
64
|
-
check.call '/tmp/bauxite-test/test_capture_bxt_manual_1.png'
|
65
|
-
check.call '/tmp/bauxite-test/test_capture_bxt_manual_2.png'
|
66
|
-
check.call '/tmp/bauxite-test/with_name.png'
|
67
|
-
check.call '/tmp/bauxite-test/capture_my_test_bxt_test_capture_my_test_bxt_3.png'
|
68
|
-
check.call '/tmp/bauxite-test/named_test_test_capture_my_test_bxt_3.png'
|
69
|
-
|
70
|
-
system('rm -rf /tmp/bauxite-test')
|
71
|
-
system("ruby -Ilib bin/bauxite --output /tmp/bauxite-test -c test/capture_on_error.bxt.manual")
|
72
|
-
fail "The 'capture_on_error' test failed to return the expected exit status: the exit status was #{$?.exitstatus}" unless $?.exitstatus == 1
|
73
|
-
check.call '/tmp/bauxite-test/capture_on_error_my_test_bxt_test_capture_on_error_bxt_manual_0.png'
|
74
|
-
check.call '/tmp/bauxite-test/test_capture_on_error_bxt_manual_0.png'
|
75
|
-
|
76
|
-
system("( cd test; ruby -I../lib ../bin/bauxite bug_load_path.bxt.manual -v; )")
|
77
|
-
fail "The regression test for 'bug_load_path' failed" unless $?.exitstatus == 0
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
# === Documentation ========================================================= #
|
82
|
-
desc "Generate Bauxite documentation"
|
83
|
-
task :doc do
|
84
|
-
doc = `rdoc -O -U -V --main README.md README.md #{File.join('lib', 'bauxite')}`
|
85
|
-
puts doc
|
86
|
-
fail "Documentation failed" unless $?.exitstatus == 0
|
87
|
-
fail "Undocumented artifacts found" unless doc.include? '100.00% documented'
|
88
|
-
end
|
89
|
-
|
90
|
-
desc "Open documentation in a browser"
|
91
|
-
task :viewdoc => [:doc] do
|
92
|
-
`xdg-open #{File.join('doc', 'index.html')}`
|
93
|
-
end
|
94
|
-
|
95
|
-
# === Helpers =============================================================== #
|
96
|
-
desc "Helper: Inject license into every file in lib"
|
97
|
-
task :inject_license do
|
98
|
-
license = File.open('LICENSE', 'r') { |f| f.read }
|
99
|
-
license = license.each_line.to_a[2..-1].map { |l| "# #{l}".sub(/ *$/, '') }
|
100
|
-
license = "#--\n#{license.join('')}#++\n\n"
|
101
|
-
|
102
|
-
Dir['lib/**/*'].select { |f| not File.directory? f }.each do |f|
|
103
|
-
puts f
|
104
|
-
content = license + File.open(f, 'r') { |f| f.read }
|
105
|
-
#File.open(f, 'w') { |f| f.write content }
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
desc "Helper: Update Bauxite version"
|
110
|
-
task :update_version, :version do |t,args|
|
111
|
-
version = args[:version]
|
112
|
-
unless version
|
113
|
-
puts "Usage rake update_version[version]"
|
114
|
-
puts ""
|
115
|
-
puts "Current version: #{CURRENT_VERSION}"
|
116
|
-
exit false
|
117
|
-
end
|
118
|
-
|
119
|
-
content = File.open('lib/bauxite.rb', 'r') { |f| f.read }
|
120
|
-
expr = /(.*VERSION = ")([^"]*)(".*)/
|
121
|
-
|
122
|
-
content = content.each_line.map do |line|
|
123
|
-
line.sub(/(.*VERSION = ").*(".*)/, "\\1#{version}\\2")
|
124
|
-
end.join
|
125
|
-
if version
|
126
|
-
puts "Updated version to #{version}"
|
127
|
-
File.open('lib/bauxite.rb', 'w') { |f| f.write content }
|
128
|
-
end
|
1
|
+
task :default => [:test, :doc]
|
2
|
+
|
3
|
+
CURRENT_VERSION = `ruby -Ilib bin/bauxite --version`.gsub(/^.* /, '')
|
4
|
+
|
5
|
+
# === Gem Package =========================================================== #
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rubygems/package_task'
|
8
|
+
|
9
|
+
spec = Gem::Specification.new do |s|
|
10
|
+
s.name = 'bauxite'
|
11
|
+
s.summary = 'Bauxite is a façade over Selenium intended for non-developers'
|
12
|
+
s.description = 'Bauxite is a façade over Selenium intended for non-developers. The idea behind this project was to create a tool that allows non-developers to write web tests in a human-readable language. Another major requirement is to be able to easily extend the test language to create functional abstractions over technical details.'
|
13
|
+
s.author = 'Patricio Zavolinsky'
|
14
|
+
s.email = 'pzavolinsky at yahoo dot com dot ar'
|
15
|
+
s.homepage = 'https://github.com/pzavolinsky/bauxite'
|
16
|
+
s.license = 'MIT'
|
17
|
+
s.version = CURRENT_VERSION
|
18
|
+
s.executables = ["bauxite"]
|
19
|
+
s.add_runtime_dependency 'selenium-webdriver', '~> 2.47'
|
20
|
+
s.add_development_dependency 'rake' , '~> 10.1'
|
21
|
+
s.files = FileList[
|
22
|
+
'LICENSE',
|
23
|
+
'README.md',
|
24
|
+
'Rakefile',
|
25
|
+
'bin/*',
|
26
|
+
'lib/**/*.rb',
|
27
|
+
'test/**/*',
|
28
|
+
'doc/**/*'
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
task :package => [ :test, :doc ]
|
33
|
+
task :gem => [ :test, :doc ]
|
34
|
+
|
35
|
+
Gem::PackageTask.new(spec) do |pkg|
|
36
|
+
pkg.need_zip = true
|
37
|
+
pkg.need_tar = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# === Integration tests ===================================================== #
|
41
|
+
desc "Run integration tests"
|
42
|
+
task :test do
|
43
|
+
test_files = Dir[File.join('test', '*.bxt')].select { |f| not File.directory? f }.join(' ')
|
44
|
+
ruby "-Ilib bin/bauxite -v #{test_files}"
|
45
|
+
|
46
|
+
ruby "-Ilib bin/bauxite -v -e test/extension #{File.join('test', 'extension.bxt.manual')}"
|
47
|
+
|
48
|
+
ruby "-Ilib bin/bauxite -v -s css test/default_selector.bxt.manual"
|
49
|
+
|
50
|
+
system("ruby -Ilib bin/bauxite test/test.bxt.manual")
|
51
|
+
fail "The 'test' action test failed to return the expected exit status: the exit status was #{$?.exitstatus}" unless $?.exitstatus == 2
|
52
|
+
|
53
|
+
debug = `echo exit | ruby -Ilib bin/bauxite -l echo test/debug.bxt.manual -d`
|
54
|
+
puts debug
|
55
|
+
unless debug.include? 'debug> '
|
56
|
+
fail "The -d argument failed to open the debug console"
|
57
|
+
end
|
58
|
+
|
59
|
+
check = lambda { |f| fail "Captured file not found #{f}" unless File.exists? f }
|
60
|
+
|
61
|
+
system('rm -rf /tmp/bauxite-test')
|
62
|
+
ruby "-Ilib bin/bauxite --output /tmp/bauxite-test test/capture.bxt.manual"
|
63
|
+
check.call '/tmp/bauxite-test/test_capture_bxt_manual_0.png'
|
64
|
+
check.call '/tmp/bauxite-test/test_capture_bxt_manual_1.png'
|
65
|
+
check.call '/tmp/bauxite-test/test_capture_bxt_manual_2.png'
|
66
|
+
check.call '/tmp/bauxite-test/with_name.png'
|
67
|
+
check.call '/tmp/bauxite-test/capture_my_test_bxt_test_capture_my_test_bxt_3.png'
|
68
|
+
check.call '/tmp/bauxite-test/named_test_test_capture_my_test_bxt_3.png'
|
69
|
+
|
70
|
+
system('rm -rf /tmp/bauxite-test')
|
71
|
+
system("ruby -Ilib bin/bauxite --output /tmp/bauxite-test -c test/capture_on_error.bxt.manual")
|
72
|
+
fail "The 'capture_on_error' test failed to return the expected exit status: the exit status was #{$?.exitstatus}" unless $?.exitstatus == 1
|
73
|
+
check.call '/tmp/bauxite-test/capture_on_error_my_test_bxt_test_capture_on_error_bxt_manual_0.png'
|
74
|
+
check.call '/tmp/bauxite-test/test_capture_on_error_bxt_manual_0.png'
|
75
|
+
|
76
|
+
system("( cd test; ruby -I../lib ../bin/bauxite bug_load_path.bxt.manual -v; )")
|
77
|
+
fail "The regression test for 'bug_load_path' failed" unless $?.exitstatus == 0
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
# === Documentation ========================================================= #
|
82
|
+
desc "Generate Bauxite documentation"
|
83
|
+
task :doc do
|
84
|
+
doc = `rdoc -O -U -V --main README.md README.md #{File.join('lib', 'bauxite')}`
|
85
|
+
puts doc
|
86
|
+
fail "Documentation failed" unless $?.exitstatus == 0
|
87
|
+
fail "Undocumented artifacts found" unless doc.include? '100.00% documented'
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "Open documentation in a browser"
|
91
|
+
task :viewdoc => [:doc] do
|
92
|
+
`xdg-open #{File.join('doc', 'index.html')}`
|
93
|
+
end
|
94
|
+
|
95
|
+
# === Helpers =============================================================== #
|
96
|
+
desc "Helper: Inject license into every file in lib"
|
97
|
+
task :inject_license do
|
98
|
+
license = File.open('LICENSE', 'r') { |f| f.read }
|
99
|
+
license = license.each_line.to_a[2..-1].map { |l| "# #{l}".sub(/ *$/, '') }
|
100
|
+
license = "#--\n#{license.join('')}#++\n\n"
|
101
|
+
|
102
|
+
Dir['lib/**/*'].select { |f| not File.directory? f }.each do |f|
|
103
|
+
puts f
|
104
|
+
content = license + File.open(f, 'r') { |f| f.read }
|
105
|
+
#File.open(f, 'w') { |f| f.write content }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
desc "Helper: Update Bauxite version"
|
110
|
+
task :update_version, :version do |t,args|
|
111
|
+
version = args[:version]
|
112
|
+
unless version
|
113
|
+
puts "Usage rake update_version[version]"
|
114
|
+
puts ""
|
115
|
+
puts "Current version: #{CURRENT_VERSION}"
|
116
|
+
exit false
|
117
|
+
end
|
118
|
+
|
119
|
+
content = File.open('lib/bauxite.rb', 'r') { |f| f.read }
|
120
|
+
expr = /(.*VERSION = ")([^"]*)(".*)/
|
121
|
+
|
122
|
+
content = content.each_line.map do |line|
|
123
|
+
line.sub(/(.*VERSION = ").*(".*)/, "\\1#{version}\\2")
|
124
|
+
end.join
|
125
|
+
if version
|
126
|
+
puts "Updated version to #{version}"
|
127
|
+
File.open('lib/bauxite.rb', 'w') { |f| f.write content }
|
128
|
+
end
|
129
129
|
end
|
data/bin/bauxite
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
#--
|
4
|
-
# Copyright (c) 2014 Patricio Zavolinsky
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
-
# a copy of this software and associated documentation files (the
|
8
|
-
# "Software"), to deal in the Software without restriction, including
|
9
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
-
# the following conditions:
|
13
|
-
#
|
14
|
-
# The above copyright notice and this permission notice shall be
|
15
|
-
# included in all copies or substantial portions of the Software.
|
16
|
-
#
|
17
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
-
#++
|
25
|
-
|
26
|
-
require 'bauxite'
|
27
|
-
Bauxite::Application::start
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Copyright (c) 2014 Patricio Zavolinsky
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
# a copy of this software and associated documentation files (the
|
8
|
+
# "Software"), to deal in the Software without restriction, including
|
9
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
# the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be
|
15
|
+
# included in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
#++
|
25
|
+
|
26
|
+
require 'bauxite'
|
27
|
+
Bauxite::Application::start
|
data/doc/Bauxite.html
CHANGED
@@ -6,20 +6,17 @@
|
|
6
6
|
|
7
7
|
<title>module Bauxite - RDoc Documentation</title>
|
8
8
|
|
9
|
-
<link href="./fonts.css" rel="stylesheet">
|
10
|
-
<link href="./rdoc.css" rel="stylesheet">
|
11
|
-
|
12
9
|
<script type="text/javascript">
|
13
10
|
var rdoc_rel_prefix = "./";
|
14
11
|
</script>
|
15
12
|
|
16
13
|
<script src="./js/jquery.js"></script>
|
17
|
-
<script src="./js/navigation.js"></script>
|
18
|
-
<script src="./js/search_index.js"></script>
|
19
|
-
<script src="./js/search.js"></script>
|
20
|
-
<script src="./js/searcher.js"></script>
|
21
14
|
<script src="./js/darkfish.js"></script>
|
22
15
|
|
16
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
17
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
18
|
+
|
19
|
+
|
23
20
|
|
24
21
|
<body id="top" role="document" class="module">
|
25
22
|
<nav role="navigation">
|
@@ -94,7 +91,7 @@
|
|
94
91
|
|
95
92
|
<footer id="validator-badges" role="contentinfo">
|
96
93
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
97
|
-
<p>Generated by <a href="http://
|
98
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-
|
94
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
95
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
99
96
|
</footer>
|
100
97
|
|
data/doc/Bauxite/Action.html
CHANGED
@@ -6,20 +6,17 @@
|
|
6
6
|
|
7
7
|
<title>class Bauxite::Action - RDoc Documentation</title>
|
8
8
|
|
9
|
-
<link href="../fonts.css" rel="stylesheet">
|
10
|
-
<link href="../rdoc.css" rel="stylesheet">
|
11
|
-
|
12
9
|
<script type="text/javascript">
|
13
10
|
var rdoc_rel_prefix = "../";
|
14
11
|
</script>
|
15
12
|
|
16
13
|
<script src="../js/jquery.js"></script>
|
17
|
-
<script src="../js/navigation.js"></script>
|
18
|
-
<script src="../js/search_index.js"></script>
|
19
|
-
<script src="../js/search.js"></script>
|
20
|
-
<script src="../js/searcher.js"></script>
|
21
14
|
<script src="../js/darkfish.js"></script>
|
22
15
|
|
16
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
17
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
18
|
+
|
19
|
+
|
23
20
|
|
24
21
|
<body id="top" role="document" class="class">
|
25
22
|
<nav role="navigation">
|
@@ -194,18 +191,17 @@ attribute to refer to the current test <a href="Context.html">Context</a>.</p>
|
|
194
191
|
|
195
192
|
<p>For example (new action template):</p>
|
196
193
|
|
197
|
-
<pre
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
194
|
+
<pre># === actions/print_source.rb ======= #
|
195
|
+
class Action
|
196
|
+
# :category: Action Methods
|
197
|
+
def print_source
|
198
|
+
# action code goes here, for example:
|
199
|
+
puts @ctx.driver.page_source.
|
200
|
+
end
|
201
|
+
end
|
202
|
+
# === end actions/print_source.rb === #
|
206
203
|
|
207
|
-
|
208
|
-
</pre>
|
204
|
+
Context::actions.include? 'print_source' # => true</pre>
|
209
205
|
|
210
206
|
<p>To avoid name clashing with Ruby reserved words, the '_action'
|
211
207
|
suffix can be included in the action method name (this suffix will not be
|
@@ -358,19 +354,18 @@ not alias_action.</p>
|
|
358
354
|
|
359
355
|
<p>For example:</p>
|
360
356
|
|
361
|
-
<pre
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
</pre>
|
357
|
+
<pre>alias hey echo "$1, nice to see you!"
|
358
|
+
hey john
|
359
|
+
# => this would expand to
|
360
|
+
# echo "john, nice to see you!"</pre>
|
366
361
|
|
367
362
|
|
368
363
|
|
369
364
|
|
370
365
|
<div class="method-source-code" id="alias_action-source">
|
371
366
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/alias.rb, line 48</span>
|
372
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">alias_action</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
373
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">add_alias</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>)
|
367
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">alias_action</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
368
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">add_alias</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>)
|
374
369
|
<span class="ruby-keyword">end</span></pre>
|
375
370
|
</div>
|
376
371
|
|
@@ -416,16 +411,16 @@ flags.</p>
|
|
416
411
|
|
417
412
|
<div class="method-source-code" id="assert-source">
|
418
413
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/assert.rb, line 38</span>
|
419
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">text</span>)
|
420
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
|
421
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
422
|
-
<span class="ruby-identifier">actual</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">e</span>)
|
423
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">text</span>)
|
424
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed: expected '#{text}', got '#{actual}'"</span>
|
425
|
-
<span class="ruby-keyword">end</span>
|
426
|
-
<span class="ruby-keyword">true</span>
|
427
|
-
<span class="ruby-keyword">end</span>
|
428
|
-
<span class="ruby-keyword">end</span>
|
414
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">text</span>)
|
415
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
|
416
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
417
|
+
<span class="ruby-identifier">actual</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">e</span>)
|
418
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">text</span>)
|
419
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed: expected '#{text}', got '#{actual}'"</span>
|
420
|
+
<span class="ruby-keyword">end</span>
|
421
|
+
<span class="ruby-keyword">true</span>
|
422
|
+
<span class="ruby-keyword">end</span>
|
423
|
+
<span class="ruby-keyword">end</span>
|
429
424
|
<span class="ruby-keyword">end</span></pre>
|
430
425
|
</div>
|
431
426
|
|
@@ -479,19 +474,19 @@ every expression specified.</p>
|
|
479
474
|
|
480
475
|
<div class="method-source-code" id="asserth-source">
|
481
476
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/asserth.rb, line 46</span>
|
482
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">asserth</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
483
|
-
<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">current_url</span>)
|
484
|
-
<span class="ruby-identifier">res</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-identifier">uri</span>)
|
485
|
-
<span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
|
486
|
-
<span class="ruby-identifier">name</span>,<span class="ruby-identifier">value</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">'='</span>, <span class="ruby-value">2</span>);
|
487
|
-
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span>
|
488
|
-
<span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">strip</span>
|
489
|
-
|
490
|
-
<span class="ruby-identifier">actual</span> = <span class="ruby-identifier">res</span>[<span class="ruby-identifier">name</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>
|
491
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">value</span>)
|
492
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed for HTTP Header '#{name}': expected '#{value}', got '#{actual}'"</span>
|
493
|
-
<span class="ruby-keyword">end</span>
|
494
|
-
<span class="ruby-keyword">end</span>
|
477
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">asserth</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
478
|
+
<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">current_url</span>)
|
479
|
+
<span class="ruby-identifier">res</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">get_response</span>(<span class="ruby-identifier">uri</span>)
|
480
|
+
<span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
|
481
|
+
<span class="ruby-identifier">name</span>,<span class="ruby-identifier">value</span> = <span class="ruby-identifier">a</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">'='</span>, <span class="ruby-value">2</span>);
|
482
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">downcase</span>
|
483
|
+
<span class="ruby-identifier">value</span> = <span class="ruby-identifier">value</span>.<span class="ruby-identifier">strip</span>
|
484
|
+
|
485
|
+
<span class="ruby-identifier">actual</span> = <span class="ruby-identifier">res</span>[<span class="ruby-identifier">name</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>
|
486
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">value</span>)
|
487
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed for HTTP Header '#{name}': expected '#{value}', got '#{actual}'"</span>
|
488
|
+
<span class="ruby-keyword">end</span>
|
489
|
+
<span class="ruby-keyword">end</span>
|
495
490
|
<span class="ruby-keyword">end</span></pre>
|
496
491
|
</div>
|
497
492
|
|
@@ -540,14 +535,14 @@ the popup. Alternatively, the action specified could be to
|
|
540
535
|
|
541
536
|
<div class="method-source-code" id="assertm-source">
|
542
537
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/assertm.rb, line 40</span>
|
543
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">assertm</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">action</span> = <span class="ruby-string">'accept'</span>)
|
544
|
-
<span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">NoAlertPresentError</span> <span class="ruby-keyword">do</span>
|
545
|
-
<span class="ruby-identifier">a</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">switch_to</span>.<span class="ruby-identifier">alert</span>
|
546
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">text</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">text</span>)
|
547
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed: expected '#{text}', got '#{a.text}'"</span>
|
548
|
-
<span class="ruby-keyword">end</span>
|
549
|
-
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">action</span>.<span class="ruby-identifier">to_sym</span>)
|
550
|
-
<span class="ruby-keyword">end</span>
|
538
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">assertm</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">action</span> = <span class="ruby-string">'accept'</span>)
|
539
|
+
<span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">NoAlertPresentError</span> <span class="ruby-keyword">do</span>
|
540
|
+
<span class="ruby-identifier">a</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">switch_to</span>.<span class="ruby-identifier">alert</span>
|
541
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">text</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">text</span>)
|
542
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed: expected '#{text}', got '#{a.text}'"</span>
|
543
|
+
<span class="ruby-keyword">end</span>
|
544
|
+
<span class="ruby-identifier">a</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">action</span>.<span class="ruby-identifier">to_sym</span>)
|
545
|
+
<span class="ruby-keyword">end</span>
|
551
546
|
<span class="ruby-keyword">end</span></pre>
|
552
547
|
</div>
|
553
548
|
|
@@ -590,11 +585,11 @@ href="Action.html#method-i-assert">assert</a> for more details.</p>
|
|
590
585
|
|
591
586
|
<div class="method-source-code" id="assertv-source">
|
592
587
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/assertv.rb, line 34</span>
|
593
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">assertv</span>(<span class="ruby-identifier">expected</span>, <span class="ruby-identifier">actual</span>)
|
594
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">expected</span>)
|
595
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed: '#{actual}' does not match '#{expected}'"</span>
|
596
|
-
<span class="ruby-keyword">end</span>
|
597
|
-
<span class="ruby-keyword">true</span>
|
588
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">assertv</span>(<span class="ruby-identifier">expected</span>, <span class="ruby-identifier">actual</span>)
|
589
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">expected</span>)
|
590
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed: '#{actual}' does not match '#{expected}'"</span>
|
591
|
+
<span class="ruby-keyword">end</span>
|
592
|
+
<span class="ruby-keyword">true</span>
|
598
593
|
<span class="ruby-keyword">end</span></pre>
|
599
594
|
</div>
|
600
595
|
|
@@ -641,13 +636,13 @@ href="Action.html#method-i-assert">assert</a> for more details.</p>
|
|
641
636
|
|
642
637
|
<div class="method-source-code" id="assertw-source">
|
643
638
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/assertw.rb, line 39</span>
|
644
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">assertw</span>(<span class="ruby-identifier">count</span> = <span class="ruby-value">1</span>)
|
645
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
|
646
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">window_handles</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">count</span>.<span class="ruby-identifier">to_i</span>
|
647
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-string">"Assertion failed: all popups must be closed."</span>
|
648
|
-
<span class="ruby-keyword">end</span>
|
649
|
-
<span class="ruby-keyword">true</span>
|
650
|
-
<span class="ruby-keyword">end</span>
|
639
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">assertw</span>(<span class="ruby-identifier">count</span> = <span class="ruby-value">1</span>)
|
640
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
|
641
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">window_handles</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">count</span>.<span class="ruby-identifier">to_i</span>
|
642
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-string">"Assertion failed: all popups must be closed."</span>
|
643
|
+
<span class="ruby-keyword">end</span>
|
644
|
+
<span class="ruby-keyword">true</span>
|
645
|
+
<span class="ruby-keyword">end</span>
|
651
646
|
<span class="ruby-keyword">end</span></pre>
|
652
647
|
</div>
|
653
648
|
|
@@ -681,17 +676,16 @@ break_action.</p>
|
|
681
676
|
|
682
677
|
<p>For example:</p>
|
683
678
|
|
684
|
-
<pre
|
685
|
-
|
686
|
-
</pre>
|
679
|
+
<pre>break
|
680
|
+
# => echoes "Press ENTER to continue" and waits for user input</pre>
|
687
681
|
|
688
682
|
|
689
683
|
|
690
684
|
|
691
685
|
<div class="method-source-code" id="break_action-source">
|
692
686
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/break.rb, line 36</span>
|
693
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">break_action</span>
|
694
|
-
<span class="ruby-identifier">lambda</span> { <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">wait</span> }
|
687
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">break_action</span>
|
688
|
+
<span class="ruby-identifier">lambda</span> { <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">wait</span> }
|
695
689
|
<span class="ruby-keyword">end</span></pre>
|
696
690
|
</div>
|
697
691
|
|
@@ -739,26 +733,26 @@ will be stored in <code>__CAPTURE__</code>.</p>
|
|
739
733
|
|
740
734
|
<div class="method-source-code" id="capture-source">
|
741
735
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/capture.rb, line 40</span>
|
742
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">capture</span>(<span class="ruby-identifier">file</span> = <span class="ruby-keyword">nil</span>)
|
743
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">file</span>
|
744
|
-
<span class="ruby-identifier">seq</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__CAPTURE_SEQ__'</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
|
745
|
-
<span class="ruby-identifier">test</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__TEST__'</span>]
|
746
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__CAPTURE_SEQ__'</span>] = <span class="ruby-identifier">seq</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
747
|
-
|
748
|
-
<span class="ruby-identifier">file</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__FILE__'</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>
|
749
|
-
<span class="ruby-identifier">file</span> = <span class="ruby-identifier">file</span>[<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">start_with?</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
|
750
|
-
|
751
|
-
<span class="ruby-identifier">file</span> <span class="ruby-operator">+=</span> <span class="ruby-node">"_#{seq}"</span>
|
752
|
-
<span class="ruby-identifier">file</span> = <span class="ruby-node">"#{test}_#{file}"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">test</span>
|
753
|
-
<span class="ruby-identifier">file</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/[^A-Z0-9_-]/i</span>, <span class="ruby-string">'_'</span>) <span class="ruby-operator">+</span> <span class="ruby-string">'.png'</span>
|
754
|
-
<span class="ruby-keyword">end</span>
|
755
|
-
|
756
|
-
<span class="ruby-identifier">file</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">output_path</span>(<span class="ruby-identifier">file</span>)
|
757
|
-
|
758
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">save_screenshot</span>(<span class="ruby-identifier">file</span>)
|
759
|
-
|
760
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__CAPTURE__'</span>] = <span class="ruby-identifier">file</span>
|
761
|
-
<span class="ruby-keyword">true</span>
|
736
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">capture</span>(<span class="ruby-identifier">file</span> = <span class="ruby-keyword">nil</span>)
|
737
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">file</span>
|
738
|
+
<span class="ruby-identifier">seq</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__CAPTURE_SEQ__'</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
|
739
|
+
<span class="ruby-identifier">test</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__TEST__'</span>]
|
740
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__CAPTURE_SEQ__'</span>] = <span class="ruby-identifier">seq</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
741
|
+
|
742
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__FILE__'</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>
|
743
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-identifier">file</span>[<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>.<span class="ruby-identifier">size</span><span class="ruby-operator">+</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">start_with?</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>
|
744
|
+
|
745
|
+
<span class="ruby-identifier">file</span> <span class="ruby-operator">+=</span> <span class="ruby-node">"_#{seq}"</span>
|
746
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-node">"#{test}_#{file}"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">test</span>
|
747
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/[^A-Z0-9_-]/i</span>, <span class="ruby-string">'_'</span>) <span class="ruby-operator">+</span> <span class="ruby-string">'.png'</span>
|
748
|
+
<span class="ruby-keyword">end</span>
|
749
|
+
|
750
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">output_path</span>(<span class="ruby-identifier">file</span>)
|
751
|
+
|
752
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">save_screenshot</span>(<span class="ruby-identifier">file</span>)
|
753
|
+
|
754
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__CAPTURE__'</span>] = <span class="ruby-identifier">file</span>
|
755
|
+
<span class="ruby-keyword">true</span>
|
762
756
|
<span class="ruby-keyword">end</span></pre>
|
763
757
|
</div>
|
764
758
|
|
@@ -797,9 +791,9 @@ will be stored in <code>__CAPTURE__</code>.</p>
|
|
797
791
|
|
798
792
|
<div class="method-source-code" id="click-source">
|
799
793
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/click.rb, line 32</span>
|
800
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">click</span>(<span class="ruby-identifier">selector</span>)
|
801
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">click</span> }
|
802
|
-
<span class="ruby-keyword">true</span>
|
794
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">click</span>(<span class="ruby-identifier">selector</span>)
|
795
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">click</span> }
|
796
|
+
<span class="ruby-keyword">true</span>
|
803
797
|
<span class="ruby-keyword">end</span></pre>
|
804
798
|
</div>
|
805
799
|
|
@@ -842,12 +836,12 @@ autocomplete (pressing the <code>TAB</code> key).</p>
|
|
842
836
|
|
843
837
|
<div class="method-source-code" id="debug-source">
|
844
838
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/debug.rb, line 35</span>
|
845
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">debug</span>
|
846
|
-
<span class="ruby-identifier">lambda</span> <span class="ruby-keyword">do</span>
|
847
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">'__DEBUG__'</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">true</span> }) <span class="ruby-keyword">do</span>
|
848
|
-
<span class="ruby-identifier">_debug_process</span>
|
849
|
-
<span class="ruby-keyword">end</span>
|
850
|
-
<span class="ruby-keyword">end</span>
|
839
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">debug</span>
|
840
|
+
<span class="ruby-identifier">lambda</span> <span class="ruby-keyword">do</span>
|
841
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">'__DEBUG__'</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">true</span> }) <span class="ruby-keyword">do</span>
|
842
|
+
<span class="ruby-identifier">_debug_process</span>
|
843
|
+
<span class="ruby-keyword">end</span>
|
844
|
+
<span class="ruby-keyword">end</span>
|
851
845
|
<span class="ruby-keyword">end</span></pre>
|
852
846
|
</div>
|
853
847
|
|
@@ -880,24 +874,23 @@ href="Action.html#method-i-assertv">assertv</a>.</p>
|
|
880
874
|
|
881
875
|
<p>For example:</p>
|
882
876
|
|
883
|
-
<pre
|
884
|
-
|
885
|
-
|
886
|
-
|
877
|
+
<pre>set first john
|
878
|
+
set last doe
|
879
|
+
doif john ${first} assertv doe ${last}
|
880
|
+
# => this assertion would pass.
|
887
881
|
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
</pre>
|
882
|
+
doif smith ${last} load smith_specific_text.bxt
|
883
|
+
# => this would only load smith_specific_text.bxt if the last
|
884
|
+
# variable matches 'smith'</pre>
|
892
885
|
|
893
886
|
|
894
887
|
|
895
888
|
|
896
889
|
<div class="method-source-code" id="doif-source">
|
897
890
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/doif.rb, line 39</span>
|
898
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">doif</span>(<span class="ruby-identifier">expected</span>, <span class="ruby-identifier">actual</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
899
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">expected</span>)
|
900
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_action_object</span>(<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>))
|
891
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">doif</span>(<span class="ruby-identifier">expected</span>, <span class="ruby-identifier">actual</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
892
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">expected</span>)
|
893
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_action_object</span>(<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>))
|
901
894
|
<span class="ruby-keyword">end</span></pre>
|
902
895
|
</div>
|
903
896
|
|
@@ -930,24 +923,23 @@ href="Action.html#method-i-assertv">assertv</a>.</p>
|
|
930
923
|
|
931
924
|
<p>For example:</p>
|
932
925
|
|
933
|
-
<pre
|
934
|
-
|
935
|
-
|
936
|
-
|
926
|
+
<pre>set first john
|
927
|
+
set last doe
|
928
|
+
dounless james ${first} assertv doe ${last}
|
929
|
+
# => this assertion would pass.
|
937
930
|
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
</pre>
|
931
|
+
dounless false ${load_captcha} load captcha.bxt
|
932
|
+
# => this would only load captcha.bxt if the load_captcha
|
933
|
+
# variable is not 'false'</pre>
|
942
934
|
|
943
935
|
|
944
936
|
|
945
937
|
|
946
938
|
<div class="method-source-code" id="dounless-source">
|
947
939
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/dounless.rb, line 39</span>
|
948
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">dounless</span>(<span class="ruby-identifier">expected</span>, <span class="ruby-identifier">actual</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
949
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">expected</span>)
|
950
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_action_object</span>(<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>))
|
940
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">dounless</span>(<span class="ruby-identifier">expected</span>, <span class="ruby-identifier">actual</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
941
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">expected</span>)
|
942
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_action_object</span>(<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>))
|
951
943
|
<span class="ruby-keyword">end</span></pre>
|
952
944
|
</div>
|
953
945
|
|
@@ -988,8 +980,8 @@ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
|
|
988
980
|
|
989
981
|
<div class="method-source-code" id="echo-source">
|
990
982
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/echo.rb, line 33</span>
|
991
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">echo</span>(<span class="ruby-identifier">text</span>)
|
992
|
-
<span class="ruby-keyword">true</span>
|
983
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">echo</span>(<span class="ruby-identifier">text</span>)
|
984
|
+
<span class="ruby-keyword">true</span>
|
993
985
|
<span class="ruby-keyword">end</span></pre>
|
994
986
|
</div>
|
995
987
|
|
@@ -1033,16 +1025,16 @@ results of the execution will be assigned to the variable named
|
|
1033
1025
|
|
1034
1026
|
<div class="method-source-code" id="exec-source">
|
1035
1027
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/exec.rb, line 35</span>
|
1036
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">exec</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">command</span>)
|
1037
|
-
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">command</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">'='</span>, <span class="ruby-value">2</span>)
|
1038
|
-
<span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>
|
1039
|
-
<span class="ruby-keyword">if</span> (<span class="ruby-identifier">data</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>)
|
1040
|
-
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>]
|
1041
|
-
<span class="ruby-identifier">command</span>[<span class="ruby-value">0</span>] = <span class="ruby-identifier">data</span>[<span class="ruby-value">1</span>]
|
1042
|
-
<span class="ruby-keyword">end</span>
|
1043
|
-
|
1044
|
-
<span class="ruby-identifier">ret</span> = <span class="ruby-node">%x
|
1045
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>
|
1028
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">exec</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">command</span>)
|
1029
|
+
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">command</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">'='</span>, <span class="ruby-value">2</span>)
|
1030
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>
|
1031
|
+
<span class="ruby-keyword">if</span> (<span class="ruby-identifier">data</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>)
|
1032
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>]
|
1033
|
+
<span class="ruby-identifier">command</span>[<span class="ruby-value">0</span>] = <span class="ruby-identifier">data</span>[<span class="ruby-value">1</span>]
|
1034
|
+
<span class="ruby-keyword">end</span>
|
1035
|
+
|
1036
|
+
<span class="ruby-identifier">ret</span> = <span class="ruby-node">%x`#{command.join(' ')}`</span>
|
1037
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>
|
1046
1038
|
<span class="ruby-keyword">end</span></pre>
|
1047
1039
|
</div>
|
1048
1040
|
|
@@ -1071,18 +1063,17 @@ results of the execution will be assigned to the variable named
|
|
1071
1063
|
|
1072
1064
|
<p>For example:</p>
|
1073
1065
|
|
1074
|
-
<pre
|
1075
|
-
|
1076
|
-
|
1077
|
-
</pre>
|
1066
|
+
<pre>exit
|
1067
|
+
assertv true false
|
1068
|
+
# => the assertv will NOT be executed</pre>
|
1078
1069
|
|
1079
1070
|
|
1080
1071
|
|
1081
1072
|
|
1082
1073
|
<div class="method-source-code" id="exit_action-source">
|
1083
1074
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/exit.rb, line 32</span>
|
1084
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">exit_action</span>
|
1085
|
-
<span class="ruby-value">:break</span>
|
1075
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">exit_action</span>
|
1076
|
+
<span class="ruby-value">:break</span>
|
1086
1077
|
<span class="ruby-keyword">end</span></pre>
|
1087
1078
|
</div>
|
1088
1079
|
|
@@ -1125,29 +1116,28 @@ href="Action.html#method-i-test">test</a>, etc.) is undefined.</p>
|
|
1125
1116
|
|
1126
1117
|
<p>For example:</p>
|
1127
1118
|
|
1128
|
-
<pre
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
</pre>
|
1119
|
+
<pre># assuming <input type="text" id="hello" value="world" />
|
1120
|
+
assert hello world
|
1121
|
+
failif assert hello universe
|
1122
|
+
failif assertv true false
|
1123
|
+
# => these assertions would pass</pre>
|
1134
1124
|
|
1135
1125
|
|
1136
1126
|
|
1137
1127
|
|
1138
1128
|
<div class="method-source-code" id="failif-source">
|
1139
1129
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/failif.rb, line 40</span>
|
1140
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">failif</span>(<span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
1141
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
|
1142
|
-
<span class="ruby-keyword">begin</span>
|
1143
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">'__TIMEOUT__'</span> =<span class="ruby-operator">></span> <span class="ruby-value">0</span>}) <span class="ruby-keyword">do</span>
|
1144
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_parsed_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>, <span class="ruby-keyword">false</span>)
|
1145
|
-
<span class="ruby-keyword">end</span>
|
1146
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">NoSuchElementError</span>
|
1147
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
|
1148
|
-
<span class="ruby-keyword">end</span>
|
1149
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion did not failed as expected:#{action} #{args.join(' ')}"</span>
|
1150
|
-
<span class="ruby-keyword">end</span>
|
1130
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">failif</span>(<span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
1131
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
|
1132
|
+
<span class="ruby-keyword">begin</span>
|
1133
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">'__TIMEOUT__'</span> =<span class="ruby-operator">></span> <span class="ruby-value">0</span>}) <span class="ruby-keyword">do</span>
|
1134
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_parsed_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>, <span class="ruby-keyword">false</span>)
|
1135
|
+
<span class="ruby-keyword">end</span>
|
1136
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">NoSuchElementError</span>
|
1137
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
|
1138
|
+
<span class="ruby-keyword">end</span>
|
1139
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion did not failed as expected:#{action} #{args.join(' ')}"</span>
|
1140
|
+
<span class="ruby-keyword">end</span>
|
1151
1141
|
<span class="ruby-keyword">end</span></pre>
|
1152
1142
|
</div>
|
1153
1143
|
|
@@ -1180,20 +1170,19 @@ using the Javascript <code>return</code> statement.</p>
|
|
1180
1170
|
|
1181
1171
|
<p>For example:</p>
|
1182
1172
|
|
1183
|
-
<pre
|
1184
|
-
|
1185
|
-
|
1186
|
-
</pre>
|
1173
|
+
<pre>js "return document.title" title_var
|
1174
|
+
echo "${title_var}"
|
1175
|
+
# => this would print the title of the page</pre>
|
1187
1176
|
|
1188
1177
|
|
1189
1178
|
|
1190
1179
|
|
1191
1180
|
<div class="method-source-code" id="js-source">
|
1192
1181
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/js.rb, line 36</span>
|
1193
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">js</span>(<span class="ruby-identifier">script</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>)
|
1194
|
-
<span class="ruby-identifier">result</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">execute_script</span>(<span class="ruby-identifier">script</span>)
|
1195
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">result</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>
|
1196
|
-
<span class="ruby-keyword">true</span>
|
1182
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">js</span>(<span class="ruby-identifier">script</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>)
|
1183
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">execute_script</span>(<span class="ruby-identifier">script</span>)
|
1184
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">result</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>
|
1185
|
+
<span class="ruby-keyword">true</span>
|
1197
1186
|
<span class="ruby-keyword">end</span></pre>
|
1198
1187
|
</div>
|
1199
1188
|
|
@@ -1249,8 +1238,8 @@ href="Context.html#method-i-with_vars">Bauxite::Context#with_vars</a>).</p>
|
|
1249
1238
|
|
1250
1239
|
<div class="method-source-code" id="load-source">
|
1251
1240
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/load.rb, line 46</span>
|
1252
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">load</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1253
|
-
<span class="ruby-identifier">tryload</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>) <span class="ruby-operator">||</span> (<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">FileNotFoundError</span>, <span class="ruby-node">"File not found: #{file}"</span>)
|
1241
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">load</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1242
|
+
<span class="ruby-identifier">tryload</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>) <span class="ruby-operator">||</span> (<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">FileNotFoundError</span>, <span class="ruby-node">"File not found: #{file}"</span>)
|
1254
1243
|
<span class="ruby-keyword">end</span></pre>
|
1255
1244
|
</div>
|
1256
1245
|
|
@@ -1288,9 +1277,9 @@ href="Context.html#method-i-with_vars">Bauxite::Context#with_vars</a>).</p>
|
|
1288
1277
|
|
1289
1278
|
<div class="method-source-code" id="open-source">
|
1290
1279
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/open.rb, line 31</span>
|
1291
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">open</span>(<span class="ruby-identifier">url</span>)
|
1292
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">navigate</span>.<span class="ruby-identifier">to</span> <span class="ruby-identifier">url</span>
|
1293
|
-
<span class="ruby-keyword">true</span>
|
1280
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">open</span>(<span class="ruby-identifier">url</span>)
|
1281
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">navigate</span>.<span class="ruby-identifier">to</span> <span class="ruby-identifier">url</span>
|
1282
|
+
<span class="ruby-keyword">true</span>
|
1294
1283
|
<span class="ruby-keyword">end</span></pre>
|
1295
1284
|
</div>
|
1296
1285
|
|
@@ -1330,13 +1319,13 @@ empty.</p>
|
|
1330
1319
|
|
1331
1320
|
<div class="method-source-code" id="params-source">
|
1332
1321
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/params.rb, line 32</span>
|
1333
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">params</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1334
|
-
<span class="ruby-identifier">missing</span> = <span class="ruby-identifier">vars</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> (<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">v</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>) <span class="ruby-operator">==</span> <span class="ruby-string">''</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-string">', '</span>)
|
1335
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">missing</span> <span class="ruby-operator">!=</span> <span class="ruby-string">''</span>
|
1336
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>,
|
1337
|
-
<span class="ruby-node">"Assertion failed: the following variables must be defined and not be empty: #{missing}."</span>
|
1338
|
-
<span class="ruby-keyword">end</span>
|
1339
|
-
<span class="ruby-keyword">true</span>
|
1322
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">params</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1323
|
+
<span class="ruby-identifier">missing</span> = <span class="ruby-identifier">vars</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> (<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">v</span>] <span class="ruby-operator">||</span> <span class="ruby-string">''</span>) <span class="ruby-operator">==</span> <span class="ruby-string">''</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-string">', '</span>)
|
1324
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">missing</span> <span class="ruby-operator">!=</span> <span class="ruby-string">''</span>
|
1325
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>,
|
1326
|
+
<span class="ruby-node">"Assertion failed: the following variables must be defined and not be empty: #{missing}."</span>
|
1327
|
+
<span class="ruby-keyword">end</span>
|
1328
|
+
<span class="ruby-keyword">true</span>
|
1340
1329
|
<span class="ruby-keyword">end</span></pre>
|
1341
1330
|
</div>
|
1342
1331
|
|
@@ -1367,19 +1356,18 @@ empty.</p>
|
|
1367
1356
|
|
1368
1357
|
<p>For example:</p>
|
1369
1358
|
|
1370
|
-
<pre
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
</pre>
|
1359
|
+
<pre>set place "World"
|
1360
|
+
replace "Hello ${place}" "World" "Universe" greeting
|
1361
|
+
echo "${greeting}!"
|
1362
|
+
# => this would print 'Hello Universe!'</pre>
|
1375
1363
|
|
1376
1364
|
|
1377
1365
|
|
1378
1366
|
|
1379
1367
|
<div class="method-source-code" id="replace-source">
|
1380
1368
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/replace.rb, line 34</span>
|
1381
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">replace</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">replacement</span>, <span class="ruby-identifier">name</span>)
|
1382
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">pattern</span>), <span class="ruby-identifier">replacement</span>)
|
1369
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">replace</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">replacement</span>, <span class="ruby-identifier">name</span>)
|
1370
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">pattern</span>), <span class="ruby-identifier">replacement</span>)
|
1383
1371
|
<span class="ruby-keyword">end</span></pre>
|
1384
1372
|
</div>
|
1385
1373
|
|
@@ -1420,9 +1408,9 @@ are destroyed.</p>
|
|
1420
1408
|
|
1421
1409
|
<div class="method-source-code" id="reset-source">
|
1422
1410
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/reset.rb, line 34</span>
|
1423
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">reset</span>()
|
1424
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">reset_driver</span>
|
1425
|
-
<span class="ruby-keyword">true</span>
|
1411
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">reset</span>()
|
1412
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">reset_driver</span>
|
1413
|
+
<span class="ruby-keyword">true</span>
|
1426
1414
|
<span class="ruby-keyword">end</span></pre>
|
1427
1415
|
</div>
|
1428
1416
|
|
@@ -1473,35 +1461,34 @@ href="Action.html#method-i-click">click</a>, <a
|
|
1473
1461
|
href="Action.html#method-i-store">store</a> and <a
|
1474
1462
|
href="Action.html#method-i-assert">assert</a> for more details):</p>
|
1475
1463
|
|
1476
|
-
<pre
|
1477
|
-
|
1464
|
+
<pre># in main.bxt
|
1465
|
+
load login.txt "username=jdoe" "password=hello world!"
|
1478
1466
|
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1467
|
+
# in login.bxt
|
1468
|
+
write id=user "${username}"
|
1469
|
+
write id=pass "${password}"
|
1470
|
+
click id=login
|
1471
|
+
store id=loginName fullName
|
1472
|
+
return fullName
|
1485
1473
|
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
</pre>
|
1474
|
+
# back in main.bxt
|
1475
|
+
assert id=greeting "Welcome ${fullName}!"
|
1476
|
+
# => this assertion uses the variable returned from login.bxt</pre>
|
1490
1477
|
|
1491
1478
|
|
1492
1479
|
|
1493
1480
|
|
1494
1481
|
<div class="method-source-code" id="return_action-source">
|
1495
1482
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/return.rb, line 58</span>
|
1496
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">return_action</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1497
|
-
<span class="ruby-keyword">if</span> <span class="ruby-identifier">vars</span> <span class="ruby-operator">==</span> [<span class="ruby-string">'*'</span>]
|
1498
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__RETURN__'</span>] = <span class="ruby-identifier">vars</span>
|
1499
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
|
1500
|
-
<span class="ruby-keyword">end</span>
|
1501
|
-
|
1502
|
-
<span class="ruby-identifier">rets</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__RETURN__'</span>] <span class="ruby-operator">||</span> []
|
1503
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__RETURN__'</span>] = <span class="ruby-identifier">rets</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vars</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">rets</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">'*'</span>
|
1504
|
-
<span class="ruby-keyword">true</span>
|
1483
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">return_action</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1484
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">vars</span> <span class="ruby-operator">==</span> [<span class="ruby-string">'*'</span>]
|
1485
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__RETURN__'</span>] = <span class="ruby-identifier">vars</span>
|
1486
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
|
1487
|
+
<span class="ruby-keyword">end</span>
|
1488
|
+
|
1489
|
+
<span class="ruby-identifier">rets</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__RETURN__'</span>] <span class="ruby-operator">||</span> []
|
1490
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__RETURN__'</span>] = <span class="ruby-identifier">rets</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vars</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">rets</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">'*'</span>
|
1491
|
+
<span class="ruby-keyword">true</span>
|
1505
1492
|
<span class="ruby-keyword">end</span></pre>
|
1506
1493
|
</div>
|
1507
1494
|
|
@@ -1559,13 +1546,13 @@ href="Context.html">Context</a> instance as its only argument.</p>
|
|
1559
1546
|
|
1560
1547
|
<div class="method-source-code" id="ruby-source">
|
1561
1548
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/ruby.rb, line 50</span>
|
1562
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">ruby</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1563
|
-
<span class="ruby-comment"># _load_file_action is defined in tryload.rb
|
1564
|
-
<span class="ruby-identifier">_load_file_action</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
1565
|
-
<span class="ruby-identifier">content</span> = <span class="ruby-string">''</span>
|
1566
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">f</span>, <span class="ruby-string">'r'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">ff</span><span class="ruby-operator">|</span> <span class="ruby-identifier">content</span> = <span class="ruby-identifier">ff</span>.<span class="ruby-identifier">read</span> }
|
1567
|
-
<span class="ruby-identifier">eval</span>(<span class="ruby-identifier">content</span>).<span class="ruby-identifier">call</span>(<span class="ruby-ivar">@ctx</span>)
|
1568
|
-
<span class="ruby-keyword">end</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">FileNotFoundError</span>, <span class="ruby-node">"File not found: #{file}"</span>)
|
1549
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">ruby</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1550
|
+
<span class="ruby-comment"># _load_file_action is defined in tryload.rb
|
1551
|
+
<span class="ruby-identifier">_load_file_action</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
1552
|
+
<span class="ruby-identifier">content</span> = <span class="ruby-string">''</span>
|
1553
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">f</span>, <span class="ruby-string">'r'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">ff</span><span class="ruby-operator">|</span> <span class="ruby-identifier">content</span> = <span class="ruby-identifier">ff</span>.<span class="ruby-identifier">read</span> }
|
1554
|
+
<span class="ruby-identifier">eval</span>(<span class="ruby-identifier">content</span>).<span class="ruby-identifier">call</span>(<span class="ruby-ivar">@ctx</span>)
|
1555
|
+
<span class="ruby-keyword">end</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">FileNotFoundError</span>, <span class="ruby-node">"File not found: #{file}"</span>)
|
1569
1556
|
<span class="ruby-keyword">end</span></pre>
|
1570
1557
|
</div>
|
1571
1558
|
|
@@ -1612,15 +1599,15 @@ the target <code>HTMLOption</code>.</p>
|
|
1612
1599
|
|
1613
1600
|
<div class="method-source-code" id="select-source">
|
1614
1601
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/select.rb, line 38</span>
|
1615
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">select</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">text</span>)
|
1616
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
1617
|
-
<span class="ruby-identifier">e</span> = <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Support</span><span class="ruby-operator">::</span><span class="ruby-constant">Select</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">e</span>)
|
1618
|
-
<span class="ruby-keyword">begin</span>
|
1619
|
-
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">select_by</span>(<span class="ruby-value">:value</span>, <span class="ruby-identifier">text</span>)
|
1620
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">NoSuchElementError</span>
|
1621
|
-
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">select_by</span>(<span class="ruby-value">:text</span>, <span class="ruby-identifier">text</span>)
|
1622
|
-
<span class="ruby-keyword">end</span>
|
1623
|
-
<span class="ruby-keyword">end</span>
|
1602
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">select</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">text</span>)
|
1603
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
1604
|
+
<span class="ruby-identifier">e</span> = <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Support</span><span class="ruby-operator">::</span><span class="ruby-constant">Select</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">e</span>)
|
1605
|
+
<span class="ruby-keyword">begin</span>
|
1606
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">select_by</span>(<span class="ruby-value">:value</span>, <span class="ruby-identifier">text</span>)
|
1607
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">NoSuchElementError</span>
|
1608
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">select_by</span>(<span class="ruby-value">:text</span>, <span class="ruby-identifier">text</span>)
|
1609
|
+
<span class="ruby-keyword">end</span>
|
1610
|
+
<span class="ruby-keyword">end</span>
|
1624
1611
|
<span class="ruby-keyword">end</span></pre>
|
1625
1612
|
</div>
|
1626
1613
|
|
@@ -1665,8 +1652,8 @@ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
|
|
1665
1652
|
|
1666
1653
|
<div class="method-source-code" id="set-source">
|
1667
1654
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/set.rb, line 36</span>
|
1668
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">set</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
|
1669
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span>
|
1655
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">set</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
|
1656
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span>
|
1670
1657
|
<span class="ruby-keyword">end</span></pre>
|
1671
1658
|
</div>
|
1672
1659
|
|
@@ -1697,25 +1684,24 @@ execution fails, the value of <code>name</code> is left unchanged.</p>
|
|
1697
1684
|
|
1698
1685
|
<p>For example:</p>
|
1699
1686
|
|
1700
|
-
<pre
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
</pre>
|
1687
|
+
<pre>set name john
|
1688
|
+
setif is_john true assertv "/John/i" "${name}"
|
1689
|
+
assertv true ${is_john}
|
1690
|
+
# => the assertion would pass</pre>
|
1705
1691
|
|
1706
1692
|
|
1707
1693
|
|
1708
1694
|
|
1709
1695
|
<div class="method-source-code" id="setif-source">
|
1710
1696
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/setif.rb, line 35</span>
|
1711
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">setif</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
1712
|
-
<span class="ruby-keyword">begin</span>
|
1713
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_parsed_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>, <span class="ruby-keyword">false</span>)
|
1714
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span>
|
1715
|
-
<span class="ruby-keyword">true</span>
|
1716
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>
|
1717
|
-
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
|
1718
|
-
<span class="ruby-keyword">end</span>
|
1697
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">setif</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
1698
|
+
<span class="ruby-keyword">begin</span>
|
1699
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_parsed_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>, <span class="ruby-keyword">false</span>)
|
1700
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span>
|
1701
|
+
<span class="ruby-keyword">true</span>
|
1702
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>
|
1703
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
|
1704
|
+
<span class="ruby-keyword">end</span>
|
1719
1705
|
<span class="ruby-keyword">end</span></pre>
|
1720
1706
|
</div>
|
1721
1707
|
|
@@ -1757,15 +1743,15 @@ href="Action.html#method-i-assert">assert</a> for more details.</p>
|
|
1757
1743
|
|
1758
1744
|
<div class="method-source-code" id="source-source">
|
1759
1745
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/source.rb, line 34</span>
|
1760
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">source</span>(<span class="ruby-identifier">text</span>)
|
1761
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
|
1762
|
-
<span class="ruby-identifier">actual</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">page_source</span>
|
1763
|
-
<span class="ruby-identifier">verbose</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">options</span>[<span class="ruby-value">:verbose</span>] <span class="ruby-operator">?</span> <span class="ruby-node">"\nPage source:\n#{actual}"</span> <span class="ruby-operator">:</span> <span class="ruby-string">''</span>
|
1764
|
-
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">text</span>)
|
1765
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed: page source does not match '#{text}'#{verbose}"</span>
|
1766
|
-
<span class="ruby-keyword">end</span>
|
1767
|
-
<span class="ruby-keyword">true</span>
|
1768
|
-
<span class="ruby-keyword">end</span>
|
1746
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">source</span>(<span class="ruby-identifier">text</span>)
|
1747
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
|
1748
|
+
<span class="ruby-identifier">actual</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">page_source</span>
|
1749
|
+
<span class="ruby-identifier">verbose</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">options</span>[<span class="ruby-value">:verbose</span>] <span class="ruby-operator">?</span> <span class="ruby-node">"\nPage source:\n#{actual}"</span> <span class="ruby-operator">:</span> <span class="ruby-string">''</span>
|
1750
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">text</span>)
|
1751
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion failed: page source does not match '#{text}'#{verbose}"</span>
|
1752
|
+
<span class="ruby-keyword">end</span>
|
1753
|
+
<span class="ruby-keyword">true</span>
|
1754
|
+
<span class="ruby-keyword">end</span>
|
1769
1755
|
<span class="ruby-keyword">end</span></pre>
|
1770
1756
|
</div>
|
1771
1757
|
|
@@ -1798,19 +1784,18 @@ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
|
|
1798
1784
|
|
1799
1785
|
<p>For example:</p>
|
1800
1786
|
|
1801
|
-
<pre
|
1802
|
-
|
1803
|
-
|
1804
|
-
# => this would print 'John'
|
1805
|
-
</span></pre>
|
1787
|
+
<pre># assuming <span id="name">John</span>
|
1788
|
+
store id=name firstName
|
1789
|
+
echo "${firstName}
|
1790
|
+
# => this would print 'John'</pre>
|
1806
1791
|
|
1807
1792
|
|
1808
1793
|
|
1809
1794
|
|
1810
1795
|
<div class="method-source-code" id="store-source">
|
1811
1796
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/store.rb, line 35</span>
|
1812
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">store</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">name</span>)
|
1813
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">e</span>) }
|
1797
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">store</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">name</span>)
|
1798
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">e</span>) }
|
1814
1799
|
<span class="ruby-keyword">end</span></pre>
|
1815
1800
|
</div>
|
1816
1801
|
|
@@ -1849,10 +1834,10 @@ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
|
|
1849
1834
|
|
1850
1835
|
<div class="method-source-code" id="submit-source">
|
1851
1836
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/submit.rb, line 32</span>
|
1852
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">submit</span>(<span class="ruby-identifier">selector</span>)
|
1853
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
1854
|
-
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">submit</span>
|
1855
|
-
<span class="ruby-keyword">end</span>
|
1837
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">submit</span>(<span class="ruby-identifier">selector</span>)
|
1838
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
1839
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">submit</span>
|
1840
|
+
<span class="ruby-keyword">end</span>
|
1856
1841
|
<span class="ruby-keyword">end</span></pre>
|
1857
1842
|
</div>
|
1858
1843
|
|
@@ -1892,41 +1877,40 @@ the execution continues with the next test context (if any).</p>
|
|
1892
1877
|
|
1893
1878
|
<p>For example:</p>
|
1894
1879
|
|
1895
|
-
<pre
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
</pre>
|
1880
|
+
<pre>test mytest.bxt "My Test" my_var=1
|
1881
|
+
# => this would load mytest.bxt into a new test context
|
1882
|
+
# named "My Test", and within that context ${my_var}
|
1883
|
+
# would expand to 1.</pre>
|
1900
1884
|
|
1901
1885
|
|
1902
1886
|
|
1903
1887
|
|
1904
1888
|
<div class="method-source-code" id="test-source">
|
1905
1889
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/test.rb, line 42</span>
|
1906
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1907
|
-
<span class="ruby-identifier">delayed</span> = <span class="ruby-identifier">load</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1908
|
-
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">file</span>
|
1909
|
-
<span class="ruby-identifier">lambda</span> <span class="ruby-keyword">do</span>
|
1910
|
-
<span class="ruby-keyword">begin</span>
|
1911
|
-
<span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>
|
1912
|
-
<span class="ruby-identifier">status</span> = <span class="ruby-string">'ERROR'</span>
|
1913
|
-
<span class="ruby-identifier">error</span> = <span class="ruby-keyword">nil</span>
|
1914
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">'__TEST__'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span> }) <span class="ruby-keyword">do</span>
|
1915
|
-
<span class="ruby-identifier">delayed</span>.<span class="ruby-identifier">call</span>
|
1916
|
-
<span class="ruby-identifier">status</span> = <span class="ruby-string">'OK'</span>
|
1917
|
-
<span class="ruby-keyword">end</span>
|
1918
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
1919
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">print_error</span>(<span class="ruby-identifier">e</span>)
|
1920
|
-
<span class="ruby-identifier">error</span> = <span class="ruby-identifier">e</span>
|
1921
|
-
<span class="ruby-keyword">ensure</span>
|
1922
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">tests</span> <span class="ruby-operator"><<</span> {
|
1923
|
-
<span class="ruby-value">:name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span>,
|
1924
|
-
<span class="ruby-value">:status</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">status</span>,
|
1925
|
-
<span class="ruby-value">:time</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">t</span>,
|
1926
|
-
<span class="ruby-value">:error</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">error</span>
|
1927
|
-
}
|
1928
|
-
<span class="ruby-keyword">end</span>
|
1929
|
-
<span class="ruby-keyword">end</span>
|
1890
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1891
|
+
<span class="ruby-identifier">delayed</span> = <span class="ruby-identifier">load</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1892
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">file</span>
|
1893
|
+
<span class="ruby-identifier">lambda</span> <span class="ruby-keyword">do</span>
|
1894
|
+
<span class="ruby-keyword">begin</span>
|
1895
|
+
<span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>
|
1896
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-string">'ERROR'</span>
|
1897
|
+
<span class="ruby-identifier">error</span> = <span class="ruby-keyword">nil</span>
|
1898
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">'__TEST__'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span> }) <span class="ruby-keyword">do</span>
|
1899
|
+
<span class="ruby-identifier">delayed</span>.<span class="ruby-identifier">call</span>
|
1900
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-string">'OK'</span>
|
1901
|
+
<span class="ruby-keyword">end</span>
|
1902
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
1903
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">print_error</span>(<span class="ruby-identifier">e</span>)
|
1904
|
+
<span class="ruby-identifier">error</span> = <span class="ruby-identifier">e</span>
|
1905
|
+
<span class="ruby-keyword">ensure</span>
|
1906
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">tests</span> <span class="ruby-operator"><<</span> {
|
1907
|
+
<span class="ruby-value">:name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span>,
|
1908
|
+
<span class="ruby-value">:status</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">status</span>,
|
1909
|
+
<span class="ruby-value">:time</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">t</span>,
|
1910
|
+
<span class="ruby-value">:error</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">error</span>
|
1911
|
+
}
|
1912
|
+
<span class="ruby-keyword">end</span>
|
1913
|
+
<span class="ruby-keyword">end</span>
|
1930
1914
|
<span class="ruby-keyword">end</span></pre>
|
1931
1915
|
</div>
|
1932
1916
|
|
@@ -1980,10 +1964,10 @@ href="Context.html#method-i-with_vars">Bauxite::Context#with_vars</a>).</p>
|
|
1980
1964
|
|
1981
1965
|
<div class="method-source-code" id="tryload-source">
|
1982
1966
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/tryload.rb, line 46</span>
|
1983
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">tryload</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1984
|
-
<span class="ruby-identifier">_load_file_action</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
1985
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_file</span>(<span class="ruby-identifier">f</span>)
|
1986
|
-
<span class="ruby-keyword">end</span>
|
1967
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">tryload</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
|
1968
|
+
<span class="ruby-identifier">_load_file_action</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
1969
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_file</span>(<span class="ruby-identifier">f</span>)
|
1970
|
+
<span class="ruby-keyword">end</span>
|
1987
1971
|
<span class="ruby-keyword">end</span></pre>
|
1988
1972
|
</div>
|
1989
1973
|
|
@@ -2021,12 +2005,12 @@ href="Context.html#method-i-with_vars">Bauxite::Context#with_vars</a>).</p>
|
|
2021
2005
|
|
2022
2006
|
<div class="method-source-code" id="wait-source">
|
2023
2007
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/wait.rb, line 31</span>
|
2024
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">wait</span>(<span class="ruby-identifier">seconds</span>)
|
2025
|
-
<span class="ruby-identifier">seconds</span> = <span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">to_i</span>
|
2026
|
-
<span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
2027
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">progress</span>(<span class="ruby-identifier">seconds</span><span class="ruby-operator">-</span><span class="ruby-identifier">i</span>)
|
2028
|
-
<span class="ruby-identifier">sleep</span>(<span class="ruby-value">1.0</span>)
|
2029
|
-
<span class="ruby-keyword">end</span>
|
2008
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">wait</span>(<span class="ruby-identifier">seconds</span>)
|
2009
|
+
<span class="ruby-identifier">seconds</span> = <span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">to_i</span>
|
2010
|
+
<span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
2011
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">progress</span>(<span class="ruby-identifier">seconds</span><span class="ruby-operator">-</span><span class="ruby-identifier">i</span>)
|
2012
|
+
<span class="ruby-identifier">sleep</span>(<span class="ruby-value">1.0</span>)
|
2013
|
+
<span class="ruby-keyword">end</span>
|
2030
2014
|
<span class="ruby-keyword">end</span></pre>
|
2031
2015
|
</div>
|
2032
2016
|
|
@@ -2058,25 +2042,24 @@ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
|
|
2058
2042
|
|
2059
2043
|
<p>For example:</p>
|
2060
2044
|
|
2061
|
-
<pre
|
2062
|
-
|
2063
|
-
|
2064
|
-
</pre>
|
2045
|
+
<pre># assuming <input type="text" name="username" />
|
2046
|
+
write name=username "John"
|
2047
|
+
# => this would type the word 'John' in the username textbox</pre>
|
2065
2048
|
|
2066
2049
|
|
2067
2050
|
|
2068
2051
|
|
2069
2052
|
<div class="method-source-code" id="write-source">
|
2070
2053
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/write.rb, line 34</span>
|
2071
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">text</span>)
|
2072
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
2073
|
-
<span class="ruby-keyword">begin</span>
|
2074
|
-
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">clear</span>
|
2075
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">UnknownError</span> <span class="ruby-comment"># user-editable
|
2076
|
-
<span class="ruby-comment"># do nothing (if this should fail, it will in the line below)
|
2077
|
-
<span class="ruby-keyword">end</span>
|
2078
|
-
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">send_keys</span>(<span class="ruby-identifier">text</span>)
|
2079
|
-
<span class="ruby-keyword">end</span>
|
2054
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">text</span>)
|
2055
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
|
2056
|
+
<span class="ruby-keyword">begin</span>
|
2057
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">clear</span>
|
2058
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Selenium</span><span class="ruby-operator">::</span><span class="ruby-constant">WebDriver</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span><span class="ruby-operator">::</span><span class="ruby-constant">UnknownError</span> <span class="ruby-comment"># user-editable...
|
2059
|
+
<span class="ruby-comment"># do nothing (if this should fail, it will in the line below)
|
2060
|
+
<span class="ruby-keyword">end</span>
|
2061
|
+
<span class="ruby-identifier">e</span>.<span class="ruby-identifier">send_keys</span>(<span class="ruby-identifier">text</span>)
|
2062
|
+
<span class="ruby-keyword">end</span>
|
2080
2063
|
<span class="ruby-keyword">end</span></pre>
|
2081
2064
|
</div>
|
2082
2065
|
|
@@ -2096,7 +2079,7 @@ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
|
|
2096
2079
|
|
2097
2080
|
<footer id="validator-badges" role="contentinfo">
|
2098
2081
|
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
2099
|
-
<p>Generated by <a href="http://
|
2100
|
-
<p>Based on <a href="http://deveiate.org/projects/Darkfish-
|
2082
|
+
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.0.
|
2083
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
2101
2084
|
</footer>
|
2102
2085
|
|