bauxite 0.6.18 → 0.6.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.md +293 -293
  4. data/Rakefile +128 -128
  5. data/bin/bauxite +27 -27
  6. data/doc/Bauxite.html +6 -9
  7. data/doc/Bauxite/Action.html +298 -315
  8. data/doc/Bauxite/ActionModule.html +23 -26
  9. data/doc/Bauxite/Application.html +36 -38
  10. data/doc/Bauxite/Context.html +303 -303
  11. data/doc/Bauxite/Errors.html +6 -9
  12. data/doc/Bauxite/Errors/AssertionError.html +6 -9
  13. data/doc/Bauxite/Errors/FileNotFoundError.html +6 -9
  14. data/doc/Bauxite/Errors/FormatError.html +6 -9
  15. data/doc/Bauxite/Loggers.html +6 -9
  16. data/doc/Bauxite/Loggers/CompositeLogger.html +29 -32
  17. data/doc/Bauxite/Loggers/EchoLogger.html +10 -13
  18. data/doc/Bauxite/Loggers/FileLogger.html +25 -28
  19. data/doc/Bauxite/Loggers/HtmlLogger.html +99 -102
  20. data/doc/Bauxite/Loggers/NullLogger.html +16 -19
  21. data/doc/Bauxite/Loggers/ReportLogger.html +43 -46
  22. data/doc/Bauxite/Loggers/TerminalLogger.html +76 -79
  23. data/doc/Bauxite/Loggers/XtermLogger.html +28 -31
  24. data/doc/Bauxite/Parser.html +87 -89
  25. data/doc/Bauxite/ParserModule.html +19 -22
  26. data/doc/Bauxite/Selector.html +99 -105
  27. data/doc/Bauxite/SelectorModule.html +27 -30
  28. data/doc/README_md.html +117 -103
  29. data/doc/created.rid +58 -58
  30. data/doc/fonts.css +167 -167
  31. data/doc/fonts/Lato-Light.ttf +0 -0
  32. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  33. data/doc/fonts/Lato-Regular.ttf +0 -0
  34. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  35. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  36. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  37. data/doc/images/add.png +0 -0
  38. data/doc/images/arrow_up.png +0 -0
  39. data/doc/images/brick.png +0 -0
  40. data/doc/images/brick_link.png +0 -0
  41. data/doc/images/bug.png +0 -0
  42. data/doc/images/bullet_black.png +0 -0
  43. data/doc/images/bullet_toggle_minus.png +0 -0
  44. data/doc/images/bullet_toggle_plus.png +0 -0
  45. data/doc/images/date.png +0 -0
  46. data/doc/images/delete.png +0 -0
  47. data/doc/images/find.png +0 -0
  48. data/doc/images/loadingAnimation.gif +0 -0
  49. data/doc/images/macFFBgHack.png +0 -0
  50. data/doc/images/package.png +0 -0
  51. data/doc/images/page_green.png +0 -0
  52. data/doc/images/page_white_text.png +0 -0
  53. data/doc/images/page_white_width.png +0 -0
  54. data/doc/images/plugin.png +0 -0
  55. data/doc/images/ruby.png +0 -0
  56. data/doc/images/tag_blue.png +0 -0
  57. data/doc/images/tag_green.png +0 -0
  58. data/doc/images/transparent.png +0 -0
  59. data/doc/images/wrench.png +0 -0
  60. data/doc/images/wrench_orange.png +0 -0
  61. data/doc/images/zoom.png +0 -0
  62. data/doc/index.html +117 -103
  63. data/doc/js/darkfish.js +32 -11
  64. data/doc/js/jquery.js +0 -0
  65. data/doc/js/navigation.js +0 -0
  66. data/doc/js/search.js +0 -0
  67. data/doc/js/search_index.js +1 -1
  68. data/doc/js/searcher.js +0 -0
  69. data/doc/rdoc.css +580 -580
  70. data/doc/table_of_contents.html +69 -72
  71. data/lib/bauxite.rb +28 -28
  72. data/lib/bauxite/actions/alias.rb +51 -51
  73. data/lib/bauxite/actions/assert.rb +49 -49
  74. data/lib/bauxite/actions/asserth.rb +60 -60
  75. data/lib/bauxite/actions/assertm.rb +49 -49
  76. data/lib/bauxite/actions/assertv.rb +40 -40
  77. data/lib/bauxite/actions/assertw.rb +47 -47
  78. data/lib/bauxite/actions/break.rb +39 -39
  79. data/lib/bauxite/actions/capture.rb +61 -61
  80. data/lib/bauxite/actions/click.rb +36 -36
  81. data/lib/bauxite/actions/debug.rb +103 -103
  82. data/lib/bauxite/actions/doif.rb +43 -43
  83. data/lib/bauxite/actions/dounless.rb +43 -43
  84. data/lib/bauxite/actions/echo.rb +36 -36
  85. data/lib/bauxite/actions/exec.rb +46 -46
  86. data/lib/bauxite/actions/exit.rb +35 -35
  87. data/lib/bauxite/actions/failif.rb +52 -52
  88. data/lib/bauxite/actions/js.rb +41 -41
  89. data/lib/bauxite/actions/load.rb +49 -49
  90. data/lib/bauxite/actions/open.rb +35 -35
  91. data/lib/bauxite/actions/params.rb +40 -40
  92. data/lib/bauxite/actions/replace.rb +37 -37
  93. data/lib/bauxite/actions/reset.rb +38 -38
  94. data/lib/bauxite/actions/return.rb +68 -68
  95. data/lib/bauxite/actions/ruby.rb +58 -58
  96. data/lib/bauxite/actions/select.rb +48 -48
  97. data/lib/bauxite/actions/set.rb +39 -39
  98. data/lib/bauxite/actions/setif.rb +44 -44
  99. data/lib/bauxite/actions/source.rb +44 -44
  100. data/lib/bauxite/actions/store.rb +38 -38
  101. data/lib/bauxite/actions/submit.rb +37 -37
  102. data/lib/bauxite/actions/test.rb +67 -67
  103. data/lib/bauxite/actions/tryload.rb +71 -71
  104. data/lib/bauxite/actions/wait.rb +38 -38
  105. data/lib/bauxite/actions/write.rb +44 -44
  106. data/lib/bauxite/application.rb +349 -349
  107. data/lib/bauxite/core/action.rb +199 -199
  108. data/lib/bauxite/core/context.rb +791 -791
  109. data/lib/bauxite/core/errors.rb +41 -41
  110. data/lib/bauxite/core/logger.rb +169 -169
  111. data/lib/bauxite/core/parser.rb +85 -85
  112. data/lib/bauxite/core/selector.rb +152 -152
  113. data/lib/bauxite/loggers/composite.rb +91 -91
  114. data/lib/bauxite/loggers/echo.rb +36 -36
  115. data/lib/bauxite/loggers/file.rb +68 -68
  116. data/lib/bauxite/loggers/html.rb +154 -154
  117. data/lib/bauxite/loggers/terminal.rb +134 -134
  118. data/lib/bauxite/loggers/xterm.rb +101 -101
  119. data/lib/bauxite/parsers/csv.rb +43 -43
  120. data/lib/bauxite/parsers/default.rb +42 -42
  121. data/lib/bauxite/parsers/html.rb +79 -79
  122. data/lib/bauxite/selectors/attr.rb +39 -39
  123. data/lib/bauxite/selectors/frame.rb +60 -60
  124. data/lib/bauxite/selectors/json.rb +88 -88
  125. data/lib/bauxite/selectors/sid.rb +38 -38
  126. data/lib/bauxite/selectors/smart.rb +80 -80
  127. data/lib/bauxite/selectors/window.rb +77 -77
  128. data/test/alert.bxt +3 -3
  129. data/test/alert/page.html +4 -4
  130. data/test/alias.bxt +9 -9
  131. data/test/asserth.bxt +2 -2
  132. data/test/assertv.bxt +1 -1
  133. data/test/assertw.bxt +7 -7
  134. data/test/broken.bxt.manual +0 -0
  135. data/test/bug_load_path.bxt.manual +0 -0
  136. data/test/bug_load_path/broken.bxt.manual +0 -0
  137. data/test/bug_load_path/test.bxt +0 -0
  138. data/test/capture.bxt.manual +20 -20
  139. data/test/capture/my_test.bxt +1 -1
  140. data/test/capture/page.html +6 -6
  141. data/test/capture_on_error.bxt.manual +3 -3
  142. data/test/capture_on_error/my_test.bxt +1 -1
  143. data/test/capture_on_error/page.html +2 -2
  144. data/test/debug.bxt.manual +0 -0
  145. data/test/default_selector.bxt.manual +7 -7
  146. data/test/default_selector/page.html +10 -10
  147. data/test/default_selector_var.bxt +1 -1
  148. data/test/delay.bxt +2 -2
  149. data/test/delay/page.html +4 -4
  150. data/test/doif.bxt +6 -6
  151. data/test/dounless.bxt +6 -6
  152. data/test/exec.bxt +6 -6
  153. data/test/exit.bxt +3 -3
  154. data/test/exit/test.bxt +3 -3
  155. data/test/extension.bxt.manual +4 -4
  156. data/test/extension/custom.rb +12 -12
  157. data/test/extension/page.html +4 -4
  158. data/test/failif.bxt +7 -7
  159. data/test/failif/page.html +5 -5
  160. data/test/format.bxt +17 -17
  161. data/test/format/page.html +6 -6
  162. data/test/frame.bxt +6 -6
  163. data/test/frame/child_frame.html +6 -6
  164. data/test/frame/grandchild_frame.html +4 -4
  165. data/test/frame/page.html +4 -4
  166. data/test/js.bxt +4 -4
  167. data/test/json.bxt +19 -19
  168. data/test/json/array.json +3 -3
  169. data/test/json/object.json +13 -13
  170. data/test/load.bxt +18 -18
  171. data/test/load/child.bxt +12 -12
  172. data/test/parsers.bxt +1 -1
  173. data/test/parsers.csv +7 -7
  174. data/test/parsers.html +32 -32
  175. data/test/parsers/page.html +6 -6
  176. data/test/return.bxt +1 -1
  177. data/test/return/f1.bxt +1 -1
  178. data/test/return/f2.bxt +1 -1
  179. data/test/return/f3.bxt +1 -1
  180. data/test/return/f4.bxt +2 -2
  181. data/test/ruby.bxt +1 -1
  182. data/test/ruby/custom.rb +5 -5
  183. data/test/select.bxt +9 -9
  184. data/test/select/page.html +8 -8
  185. data/test/selectors.bxt +7 -7
  186. data/test/selectors/page.html +6 -6
  187. data/test/set_builtin.bxt +5 -0
  188. data/test/set_builtin/page.html +5 -0
  189. data/test/setif.bxt +3 -3
  190. data/test/smart_selector.bxt +17 -17
  191. data/test/smart_selector/page.html +17 -17
  192. data/test/stdin.bxt +0 -0
  193. data/test/submit.bxt +4 -4
  194. data/test/submit/page.html +6 -6
  195. data/test/submit/page2.html +4 -4
  196. data/test/test.bxt.manual +6 -6
  197. data/test/test/test1.bxt +2 -2
  198. data/test/test/test2.bxt +3 -3
  199. data/test/test/test3.bxt +2 -2
  200. data/test/test/test4.bxt +1 -1
  201. data/test/test/test5.bxt +1 -1
  202. data/test/window.bxt +14 -14
  203. data/test/window/page.html +5 -5
  204. data/test/window/popup.html +4 -4
  205. metadata +5 -3
@@ -1,43 +1,43 @@
1
- #--
2
- # Copyright (c) 2014 Patricio Zavolinsky
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
21
- #++
22
-
23
- class Bauxite::Parser
24
- # Load CSV files.
25
- #
26
- # :category: Parser Methods
27
- def csv(file)
28
- return nil unless file.downcase.end_with? '.csv'
29
-
30
- File.open(file) do |f|
31
- f.read.each_line.each_with_index.map do |text,line|
32
- text = text.sub(/\r?\n$/, '')
33
- next nil if text =~ /^\s*(#|$)/
34
- begin
35
- data = CSV.parse_line(text)
36
- [ data[0], data[1..-1].map { |a| a.strip }, nil, line ]
37
- rescue StandardError => e
38
- raise "#{file} (line #{line+1}): #{e.message}"
39
- end
40
- end
41
- end.select { |item| item != nil }
42
- end
43
- end
1
+ #--
2
+ # Copyright (c) 2014 Patricio Zavolinsky
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ #++
22
+
23
+ class Bauxite::Parser
24
+ # Load CSV files.
25
+ #
26
+ # :category: Parser Methods
27
+ def csv(file)
28
+ return nil unless file.downcase.end_with? '.csv'
29
+
30
+ File.open(file) do |f|
31
+ f.read.each_line.each_with_index.map do |text,line|
32
+ text = text.sub(/\r?\n$/, '')
33
+ next nil if text =~ /^\s*(#|$)/
34
+ begin
35
+ data = CSV.parse_line(text)
36
+ [ data[0], data[1..-1].map { |a| a.strip }, nil, line ]
37
+ rescue StandardError => e
38
+ raise "#{file} (line #{line+1}): #{e.message}"
39
+ end
40
+ end
41
+ end.select { |item| item != nil }
42
+ end
43
+ end
@@ -1,42 +1,42 @@
1
- #--
2
- # Copyright (c) 2014 Patricio Zavolinsky
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
21
- #++
22
-
23
- class Bauxite::Parser
24
- # Load default Bauxite files.
25
- #
26
- # :category: Parser Methods
27
- def default(file, io = nil)
28
- return nil unless file == 'stdin' or file.match(/\.[tb]xt(\..*)?$/)
29
-
30
- return default(file, $stdin) if file == 'stdin' and not io
31
-
32
- return File.open(file) { |io| default(file, io) } unless io
33
-
34
- io.each_line.each_with_index.map do |text,line|
35
- text = text.sub(/\r?\n$/, '')
36
- next nil if text =~ /^\s*(#|$)/
37
- data = Bauxite::Context::parse_action_default(text, file, line)
38
- [ data[:action], data[:args], text, line ]
39
- end
40
- .select { |item| item != nil }
41
- end
42
- end
1
+ #--
2
+ # Copyright (c) 2014 Patricio Zavolinsky
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ #++
22
+
23
+ class Bauxite::Parser
24
+ # Load default Bauxite files.
25
+ #
26
+ # :category: Parser Methods
27
+ def default(file, io = nil)
28
+ return nil unless file == 'stdin' or file.match(/\.[tb]xt(\..*)?$/)
29
+
30
+ return default(file, $stdin) if file == 'stdin' and not io
31
+
32
+ return File.open(file) { |io| default(file, io) } unless io
33
+
34
+ io.each_line.each_with_index.map do |text,line|
35
+ text = text.sub(/\r?\n$/, '')
36
+ next nil if text =~ /^\s*(#|$)/
37
+ data = Bauxite::Context::parse_action_default(text, file, line)
38
+ [ data[:action], data[:args], text, line ]
39
+ end
40
+ .select { |item| item != nil }
41
+ end
42
+ end
@@ -1,79 +1,79 @@
1
- #--
2
- # Copyright (c) 2014 Patricio Zavolinsky
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
21
- #++
22
-
23
- class Bauxite::Parser
24
- # Load Selenium IDE HTML files.
25
- #
26
- # :category: Parser Methods
27
- def selenium_ide_html(file)
28
- return nil unless file.downcase.end_with? '.html'
29
-
30
- File.open(file) do |f|
31
- content = f.read
32
-
33
- data = content.gsub(/[\n\r]/, '')
34
- selenium_base = data.sub(/.*rel="selenium.base" href="([^"]*)".*/, '\1')
35
- base_ends_in_slash = (selenium_base[-1] == '/')
36
-
37
- data
38
- .gsub('<tr>', "\naction=")
39
- .gsub('</tr>', "\n")
40
- .each_line.grep(/^action=/)
41
- .map { |line| line.match(/^action=\s*<td>([^<]*)<\/td>\s*<td>([^<]*)<\/td>\s*<td>([^<]*)<\/td>.*$/) }
42
- .select { |match| match }
43
- .map { |match| match.captures }
44
- .map do |action|
45
- case action[0].downcase
46
- when 'open'
47
- url = action[1]
48
- url = url[1..-1] if url[0] == '/' and base_ends_in_slash # remove leading '/'
49
- action[1] = selenium_base + url
50
- when 'type'
51
- action[0] = 'write'
52
- action[1] = _selenium_ide_html_parse_selector(action[1])
53
- when 'verifytextpresent'
54
- action[0] = 'source'
55
- when 'clickandwait', 'click'
56
- action[0] = 'click'
57
- action[1] = _selenium_ide_html_parse_selector(action[1])
58
- when 'waitforpagetoload'
59
- action[0] = 'wait'
60
- action[1] = (action[1].to_i / 1000).to_s
61
- when 'assertvalue'
62
- action[0] = 'assert'
63
- action[1] = _selenium_ide_html_parse_selector(action[1])
64
- when 'waitforpopup'
65
- action = [] # remove
66
- end
67
- action = action.select { |a| a != '' }
68
- [ action[0], action[1..-1], nil, 0 ]
69
- end
70
- .select { |a| a[0] }
71
- end
72
- end
73
-
74
- private
75
- def _selenium_ide_html_parse_selector(selector)
76
- selector = 'xpath='+selector if selector[0..1] == '//'
77
- selector
78
- end
79
- end
1
+ #--
2
+ # Copyright (c) 2014 Patricio Zavolinsky
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ #++
22
+
23
+ class Bauxite::Parser
24
+ # Load Selenium IDE HTML files.
25
+ #
26
+ # :category: Parser Methods
27
+ def selenium_ide_html(file)
28
+ return nil unless file.downcase.end_with? '.html'
29
+
30
+ File.open(file) do |f|
31
+ content = f.read
32
+
33
+ data = content.gsub(/[\n\r]/, '')
34
+ selenium_base = data.sub(/.*rel="selenium.base" href="([^"]*)".*/, '\1')
35
+ base_ends_in_slash = (selenium_base[-1] == '/')
36
+
37
+ data
38
+ .gsub('<tr>', "\naction=")
39
+ .gsub('</tr>', "\n")
40
+ .each_line.grep(/^action=/)
41
+ .map { |line| line.match(/^action=\s*<td>([^<]*)<\/td>\s*<td>([^<]*)<\/td>\s*<td>([^<]*)<\/td>.*$/) }
42
+ .select { |match| match }
43
+ .map { |match| match.captures }
44
+ .map do |action|
45
+ case action[0].downcase
46
+ when 'open'
47
+ url = action[1]
48
+ url = url[1..-1] if url[0] == '/' and base_ends_in_slash # remove leading '/'
49
+ action[1] = selenium_base + url
50
+ when 'type'
51
+ action[0] = 'write'
52
+ action[1] = _selenium_ide_html_parse_selector(action[1])
53
+ when 'verifytextpresent'
54
+ action[0] = 'source'
55
+ when 'clickandwait', 'click'
56
+ action[0] = 'click'
57
+ action[1] = _selenium_ide_html_parse_selector(action[1])
58
+ when 'waitforpagetoload'
59
+ action[0] = 'wait'
60
+ action[1] = (action[1].to_i / 1000).to_s
61
+ when 'assertvalue'
62
+ action[0] = 'assert'
63
+ action[1] = _selenium_ide_html_parse_selector(action[1])
64
+ when 'waitforpopup'
65
+ action = [] # remove
66
+ end
67
+ action = action.select { |a| a != '' }
68
+ [ action[0], action[1..-1], nil, 0 ]
69
+ end
70
+ .select { |a| a[0] }
71
+ end
72
+ end
73
+
74
+ private
75
+ def _selenium_ide_html_parse_selector(selector)
76
+ selector = 'xpath='+selector if selector[0..1] == '//'
77
+ selector
78
+ end
79
+ end
@@ -1,39 +1,39 @@
1
- #--
2
- # Copyright (c) 2014 Patricio Zavolinsky
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
21
- #++
22
-
23
- class Bauxite::Selector
24
- # Select an element by attribute value.
25
- #
26
- # The attribute selector syntax is:
27
- # attr=name:value
28
- #
29
- # For example:
30
- # # assuming <div custom="true">foo</div>
31
- # assert attr=custom:true "foo"
32
- # # => matches the element above.
33
- #
34
- # :category: Selector Methods
35
- def attr(arg, &block)
36
- data = arg.split(':', 2)
37
- selenium_find(:css, "[#{data[0]}='#{data[1]}']", &block)
38
- end
39
- end
1
+ #--
2
+ # Copyright (c) 2014 Patricio Zavolinsky
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ #++
22
+
23
+ class Bauxite::Selector
24
+ # Select an element by attribute value.
25
+ #
26
+ # The attribute selector syntax is:
27
+ # attr=name:value
28
+ #
29
+ # For example:
30
+ # # assuming <div custom="true">foo</div>
31
+ # assert attr=custom:true "foo"
32
+ # # => matches the element above.
33
+ #
34
+ # :category: Selector Methods
35
+ def attr(arg, &block)
36
+ data = arg.split(':', 2)
37
+ selenium_find(:css, "[#{data[0]}='#{data[1]}']", &block)
38
+ end
39
+ end
@@ -1,60 +1,60 @@
1
- #--
2
- # Copyright (c) 2014 Patricio Zavolinsky
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
21
- #++
22
-
23
- class Bauxite::Selector
24
- # Change the selector scope to the given frame and finds an element in that
25
- # frame.
26
- #
27
- # This is a composite selector. The frame selector syntax is:
28
- # frame=|frame_selector|child_selector
29
- #
30
- # Where +frame_selector+ is any selector available that matches the target
31
- # frame, +child_selector+ is any selector available that matches the target
32
- # element inside the target frame.
33
- #
34
- # Note that the '|' character can be replaced with any single-character
35
- # delimiter.
36
- #
37
- # Also note that frame selectors can be embedded to select a frame inside
38
- # a frame. To accompilish this, +child_selector+ can be a frame selector.
39
- #
40
- # For example:
41
- # # assuming <iframe class="myframe">
42
- # # <div id="child">foo</div>
43
- # # </iframe>
44
- # assert "frame=|css=.myframe|child" "foo"
45
- # # => matches the 'child' element above.
46
- #
47
- # :category: Selector Methods
48
- def frame(arg, &block)
49
- delimiter = arg[0]
50
- items = arg[1..-1].split(delimiter, 2)
51
- find(items[0]) do |f|
52
- begin
53
- @ctx.driver.switch_to.frame f
54
- find(items[1], &block)
55
- ensure
56
- @ctx.driver.switch_to.default_content
57
- end
58
- end
59
- end
60
- end
1
+ #--
2
+ # Copyright (c) 2014 Patricio Zavolinsky
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ #++
22
+
23
+ class Bauxite::Selector
24
+ # Change the selector scope to the given frame and finds an element in that
25
+ # frame.
26
+ #
27
+ # This is a composite selector. The frame selector syntax is:
28
+ # frame=|frame_selector|child_selector
29
+ #
30
+ # Where +frame_selector+ is any selector available that matches the target
31
+ # frame, +child_selector+ is any selector available that matches the target
32
+ # element inside the target frame.
33
+ #
34
+ # Note that the '|' character can be replaced with any single-character
35
+ # delimiter.
36
+ #
37
+ # Also note that frame selectors can be embedded to select a frame inside
38
+ # a frame. To accompilish this, +child_selector+ can be a frame selector.
39
+ #
40
+ # For example:
41
+ # # assuming <iframe class="myframe">
42
+ # # <div id="child">foo</div>
43
+ # # </iframe>
44
+ # assert "frame=|css=.myframe|child" "foo"
45
+ # # => matches the 'child' element above.
46
+ #
47
+ # :category: Selector Methods
48
+ def frame(arg, &block)
49
+ delimiter = arg[0]
50
+ items = arg[1..-1].split(delimiter, 2)
51
+ find(items[0]) do |f|
52
+ begin
53
+ @ctx.driver.switch_to.frame f
54
+ find(items[1], &block)
55
+ ensure
56
+ @ctx.driver.switch_to.default_content
57
+ end
58
+ end
59
+ end
60
+ end