operawatir 0.4-jruby → 0.4.1-jruby

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. data/.gitmodules +3 -3
  2. data/AUTHORS +1 -0
  3. data/CHANGES +454 -0
  4. data/README.md +67 -50
  5. data/Rakefile +6 -10
  6. data/VERSION +1 -1
  7. data/bin/desktopwatir +52 -29
  8. data/bin/operawatir +50 -18
  9. data/lib/operadriver/client-combined-nodeps.jar +0 -0
  10. data/lib/operadriver/webdriver-opera.jar +0 -0
  11. data/lib/operawatir.rb +8 -1
  12. data/lib/operawatir/browser.rb +35 -15
  13. data/lib/operawatir/collection.rb +2 -2
  14. data/lib/operawatir/compat.rb +3 -2
  15. data/lib/operawatir/compat/browser.rb +0 -5
  16. data/lib/operawatir/compat/collection.rb +15 -0
  17. data/lib/operawatir/compat/element.rb +72 -21
  18. data/lib/operawatir/compat/element_finders.rb +6 -0
  19. data/lib/operawatir/compat/selector.rb +7 -0
  20. data/lib/operawatir/compat/window.rb +49 -0
  21. data/lib/operawatir/desktop_browser.rb +88 -14
  22. data/lib/operawatir/desktop_common.rb +0 -2
  23. data/lib/operawatir/desktop_container.rb +82 -29
  24. data/lib/operawatir/desktop_helper.rb +2 -0
  25. data/lib/operawatir/element.rb +49 -25
  26. data/lib/operawatir/helper.rb +5 -3
  27. data/lib/operawatir/keys.rb +19 -6
  28. data/lib/operawatir/preferences.rb +315 -78
  29. data/lib/operawatir/quickwidgets.rb +2 -1
  30. data/lib/operawatir/quickwidgets/quick_addressfield.rb +12 -0
  31. data/lib/operawatir/quickwidgets/quick_button.rb +8 -2
  32. data/lib/operawatir/quickwidgets/quick_checkbox.rb +5 -5
  33. data/lib/operawatir/quickwidgets/quick_editfield.rb +8 -5
  34. data/lib/operawatir/quickwidgets/quick_find.rb +11 -0
  35. data/lib/operawatir/quickwidgets/quick_griditem.rb +11 -0
  36. data/lib/operawatir/quickwidgets/quick_gridlayout.rb +11 -0
  37. data/lib/operawatir/quickwidgets/quick_searchfield.rb +7 -1
  38. data/lib/operawatir/quickwidgets/quick_tab.rb +0 -1
  39. data/lib/operawatir/quickwidgets/quick_treeitem.rb +22 -1
  40. data/lib/operawatir/quickwidgets/quick_widget.rb +62 -23
  41. data/lib/operawatir/quickwidgets/quick_window.rb +32 -2
  42. data/lib/operawatir/screenshot.rb +46 -0
  43. data/lib/operawatir/version.rb +6 -4
  44. data/lib/operawatir/window.rb +53 -67
  45. data/operawatir.gemspec +310 -245
  46. data/spec/operawatir/README.md +4 -0
  47. data/spec/operawatir/core/browser_spec.rb +82 -0
  48. data/spec/operawatir/core/element_spec.rb +88 -0
  49. data/spec/operawatir/core/preferences_spec.rb +438 -0
  50. data/spec/operawatir/core/screenshot_spec.rb +76 -0
  51. data/spec/{new_watirspec → operawatir/core}/spatnav_spec.rb +3 -3
  52. data/spec/operawatir/core/window_spec.rb +76 -0
  53. data/spec/operawatir/desktop/desktopbrowser_spec.rb +316 -0
  54. data/spec/operawatir/desktop/quickaddressfield_spec.rb +59 -0
  55. data/spec/operawatir/desktop/quickbutton_spec.rb +248 -0
  56. data/spec/operawatir/desktop/quickcheckbox_spec.rb +36 -0
  57. data/spec/operawatir/desktop/quickdialogtab_spec.rb +30 -0
  58. data/spec/operawatir/desktop/quickdropdown_spec.rb +39 -0
  59. data/spec/operawatir/desktop/quickeditfield_spec.rb +51 -0
  60. data/spec/operawatir/desktop/quickfind_spec.rb +30 -0
  61. data/spec/operawatir/desktop/quickgriditem_spec.rb +16 -0
  62. data/spec/operawatir/desktop/quickgridlayout_spec.rb +15 -0
  63. data/spec/operawatir/desktop/quicklabel_spec.rb +28 -0
  64. data/spec/operawatir/desktop/quickradiobutton_spec.rb +24 -0
  65. data/spec/operawatir/desktop/quicksearchfield_spec.rb +26 -0
  66. data/spec/operawatir/desktop/quicktab_spec.rb +86 -0
  67. data/spec/operawatir/desktop/quickthumbnail_spec.rb +37 -0
  68. data/spec/operawatir/desktop/quicktreeitem_spec.rb +135 -0
  69. data/spec/operawatir/desktop/quicktreeview_spec.rb +30 -0
  70. data/spec/operawatir/desktop/quickwidget_spec.rb +101 -0
  71. data/spec/operawatir/desktop/quickwindow_spec.rb +108 -0
  72. data/spec/operawatir/desktop/shared/shared.rb +138 -0
  73. data/spec/operawatir/fixtures/boxes.html +22 -0
  74. data/spec/operawatir/fixtures/browsers.svg +367 -0
  75. data/spec/operawatir/fixtures/frames.html +13 -0
  76. data/spec/operawatir/fixtures/grid.html +29 -0
  77. data/spec/operawatir/fixtures/input_fields_value.html +6 -0
  78. data/spec/operawatir/fixtures/onclick.html +20 -0
  79. data/spec/operawatir/fixtures/paragraphs.html +15 -0
  80. data/spec/operawatir/fixtures/two_input_fields.html +6 -0
  81. data/spec/{new_watirspec → operawatir}/guards.rb +0 -0
  82. data/spec/operawatir/matchers.rb +68 -0
  83. data/spec/{legacy_watirspec → operawatir}/server.rb +0 -0
  84. data/spec/operawatir/watirspec.rake +43 -0
  85. data/spec/operawatir/watirspec_desktophelper.rb +14 -0
  86. data/spec/operawatir/watirspec_helper.rb +62 -0
  87. data/spec/{legacy_watirspec → watir2}/area_spec.rb +0 -0
  88. data/spec/{legacy_watirspec → watir2}/areas_spec.rb +0 -0
  89. data/spec/{legacy_watirspec → watir2}/browser_spec.rb +2 -0
  90. data/spec/{legacy_watirspec → watir2}/button_spec.rb +0 -0
  91. data/spec/{legacy_watirspec → watir2}/buttons_spec.rb +0 -0
  92. data/spec/{legacy_watirspec → watir2}/checkbox_spec.rb +0 -0
  93. data/spec/{legacy_watirspec → watir2}/checkboxes_spec.rb +0 -0
  94. data/spec/{legacy_watirspec → watir2}/collections_spec.rb +0 -0
  95. data/spec/{legacy_watirspec → watir2}/dd_spec.rb +0 -0
  96. data/spec/{legacy_watirspec → watir2}/dds_spec.rb +0 -0
  97. data/spec/{legacy_watirspec → watir2}/del_spec.rb +0 -0
  98. data/spec/{legacy_watirspec → watir2}/dels_spec.rb +0 -0
  99. data/spec/{legacy_watirspec → watir2}/div_spec.rb +0 -0
  100. data/spec/{legacy_watirspec → watir2}/divs_spec.rb +0 -0
  101. data/spec/{legacy_watirspec → watir2}/dl_spec.rb +0 -0
  102. data/spec/{legacy_watirspec → watir2}/dls_spec.rb +0 -0
  103. data/spec/{legacy_watirspec → watir2}/dt_spec.rb +0 -0
  104. data/spec/{legacy_watirspec → watir2}/dts_spec.rb +0 -0
  105. data/spec/watir2/element_spec.rb +155 -0
  106. data/spec/{legacy_watirspec → watir2}/em_spec.rb +0 -0
  107. data/spec/{legacy_watirspec → watir2}/ems_spec.rb +0 -0
  108. data/spec/{legacy_watirspec → watir2}/filefield_spec.rb +0 -0
  109. data/spec/{legacy_watirspec → watir2}/filefields_spec.rb +0 -0
  110. data/spec/{legacy_watirspec → watir2}/fixtures/2000_spans.html +0 -0
  111. data/spec/{legacy_watirspec → watir2}/fixtures/bug_duplicate_attributes.html +0 -0
  112. data/spec/{legacy_watirspec → watir2}/fixtures/bug_javascript_001.html +0 -0
  113. data/spec/{legacy_watirspec → watir2}/fixtures/buttons_with_duplicate_ids.html +0 -0
  114. data/spec/{legacy_watirspec → watir2}/fixtures/collections.html +0 -0
  115. data/spec/{legacy_watirspec → watir2}/fixtures/definition_lists.html +0 -0
  116. data/spec/{legacy_watirspec → watir2}/fixtures/euc-jp_text.html +0 -0
  117. data/spec/{legacy_watirspec → watir2}/fixtures/forms_with_input_elements.html +0 -0
  118. data/spec/{legacy_watirspec → watir2}/fixtures/frame_1.html +0 -0
  119. data/spec/{legacy_watirspec → watir2}/fixtures/frame_2.html +0 -0
  120. data/spec/{legacy_watirspec → watir2}/fixtures/frames.html +0 -0
  121. data/spec/{legacy_watirspec → watir2}/fixtures/iframes.html +0 -0
  122. data/spec/{legacy_watirspec → watir2}/fixtures/images.html +0 -0
  123. data/spec/{legacy_watirspec → watir2}/fixtures/images/1.gif +0 -0
  124. data/spec/{legacy_watirspec → watir2}/fixtures/images/2.gif +0 -0
  125. data/spec/{legacy_watirspec → watir2}/fixtures/images/3.gif +0 -0
  126. data/spec/{legacy_watirspec → watir2}/fixtures/images/button.jpg +0 -0
  127. data/spec/{legacy_watirspec → watir2}/fixtures/images/circle.jpg +0 -0
  128. data/spec/{legacy_watirspec → watir2}/fixtures/images/map.gif +0 -0
  129. data/spec/{legacy_watirspec → watir2}/fixtures/images/map2.gif +0 -0
  130. data/spec/{legacy_watirspec → watir2}/fixtures/images/minus.gif +0 -0
  131. data/spec/{legacy_watirspec → watir2}/fixtures/images/originaltriangle.jpg +0 -0
  132. data/spec/{legacy_watirspec → watir2}/fixtures/images/plus.gif +0 -0
  133. data/spec/{legacy_watirspec → watir2}/fixtures/images/square.jpg +0 -0
  134. data/spec/{legacy_watirspec → watir2}/fixtures/images/triangle.jpg +0 -0
  135. data/spec/{legacy_watirspec → watir2}/fixtures/iso-2022-jp_text.html +0 -0
  136. data/spec/{legacy_watirspec → watir2}/fixtures/javascript/helpers.js +0 -0
  137. data/spec/{legacy_watirspec → watir2}/fixtures/jquery.html +0 -0
  138. data/spec/{legacy_watirspec → watir2}/fixtures/latin1_text.html +0 -0
  139. data/spec/{legacy_watirspec → watir2}/fixtures/multiple_ids.html +0 -0
  140. data/spec/{legacy_watirspec → watir2}/fixtures/non_control_elements.html +0 -0
  141. data/spec/{legacy_watirspec → watir2}/fixtures/parser_bug_001.html +0 -0
  142. data/spec/{legacy_watirspec → watir2}/fixtures/prevent_form_submit.html +0 -0
  143. data/spec/{legacy_watirspec → watir2}/fixtures/right_click.html +0 -0
  144. data/spec/{legacy_watirspec → watir2}/fixtures/shift_jis_text.html +0 -0
  145. data/spec/{legacy_watirspec → watir2}/fixtures/tables.html +0 -0
  146. data/spec/{legacy_watirspec → watir2}/fixtures/timeout.html +0 -0
  147. data/spec/{legacy_watirspec → watir2}/fixtures/timeout_window_location.html +0 -0
  148. data/spec/{legacy_watirspec → watir2}/fixtures/tiny_mce.html +0 -0
  149. data/spec/{legacy_watirspec → watir2}/fixtures/utf8_text.html +0 -0
  150. data/spec/{legacy_watirspec → watir2}/fixtures/watirspec.css +0 -0
  151. data/spec/{legacy_watirspec → watir2}/form_spec.rb +0 -0
  152. data/spec/{legacy_watirspec → watir2}/forms_spec.rb +0 -0
  153. data/spec/{legacy_watirspec → watir2}/frame_spec.rb +0 -0
  154. data/spec/{legacy_watirspec → watir2}/frames_spec.rb +0 -0
  155. data/spec/{legacy_watirspec → watir2}/guards.rb +0 -0
  156. data/spec/{legacy_watirspec → watir2}/hidden_spec.rb +0 -0
  157. data/spec/{legacy_watirspec → watir2}/hiddens_spec.rb +0 -0
  158. data/spec/{legacy_watirspec → watir2}/hn_spec.rb +0 -0
  159. data/spec/{legacy_watirspec → watir2}/hns_spec.rb +0 -0
  160. data/spec/{legacy_watirspec → watir2}/image_spec.rb +0 -0
  161. data/spec/{legacy_watirspec → watir2}/images_spec.rb +0 -0
  162. data/spec/{legacy_watirspec → watir2}/ins_spec.rb +0 -0
  163. data/spec/{legacy_watirspec → watir2}/inses_spec.rb +0 -0
  164. data/spec/{legacy_watirspec → watir2}/label_spec.rb +0 -0
  165. data/spec/{legacy_watirspec → watir2}/labels_spec.rb +0 -0
  166. data/spec/{legacy_watirspec → watir2}/li_spec.rb +0 -0
  167. data/spec/{legacy_watirspec → watir2}/link_spec.rb +0 -0
  168. data/spec/{legacy_watirspec → watir2}/links_spec.rb +0 -0
  169. data/spec/{legacy_watirspec → watir2}/lis_spec.rb +0 -0
  170. data/spec/{legacy_watirspec → watir2}/map_spec.rb +0 -0
  171. data/spec/{legacy_watirspec → watir2}/maps_spec.rb +0 -0
  172. data/spec/{legacy_watirspec → watir2}/meta_spec.rb +0 -0
  173. data/spec/{legacy_watirspec → watir2}/metas_spec.rb +0 -0
  174. data/spec/{legacy_watirspec → watir2}/ol_spec.rb +0 -0
  175. data/spec/{legacy_watirspec → watir2}/ols_spec.rb +0 -0
  176. data/spec/{legacy_watirspec → watir2}/option_spec.rb +0 -0
  177. data/spec/{legacy_watirspec → watir2}/p_spec.rb +0 -0
  178. data/spec/{legacy_watirspec → watir2}/pre_spec.rb +0 -0
  179. data/spec/{legacy_watirspec → watir2}/pres_spec.rb +0 -0
  180. data/spec/{legacy_watirspec → watir2}/ps_spec.rb +0 -0
  181. data/spec/{legacy_watirspec → watir2}/radio_spec.rb +0 -0
  182. data/spec/{legacy_watirspec → watir2}/radios_spec.rb +0 -0
  183. data/spec/{legacy_watirspec → watir2}/select_list_spec.rb +84 -71
  184. data/spec/{legacy_watirspec → watir2}/select_lists_spec.rb +0 -0
  185. data/spec/{new_watirspec → watir2}/server.rb +0 -0
  186. data/spec/{legacy_watirspec → watir2}/span_spec.rb +0 -0
  187. data/spec/{legacy_watirspec → watir2}/spans_spec.rb +0 -0
  188. data/spec/{legacy_watirspec → watir2}/spec_helper.rb +0 -0
  189. data/spec/{legacy_watirspec → watir2}/strong_spec.rb +0 -0
  190. data/spec/{legacy_watirspec → watir2}/strongs_spec.rb +0 -0
  191. data/spec/{legacy_watirspec → watir2}/table_bodies_spec.rb +0 -0
  192. data/spec/{legacy_watirspec → watir2}/table_body_spec.rb +0 -0
  193. data/spec/{legacy_watirspec → watir2}/table_cell_spec.rb +0 -0
  194. data/spec/{legacy_watirspec → watir2}/table_cells_spec.rb +0 -0
  195. data/spec/{legacy_watirspec → watir2}/table_footer_spec.rb +0 -0
  196. data/spec/{legacy_watirspec → watir2}/table_footers_spec.rb +0 -0
  197. data/spec/{legacy_watirspec → watir2}/table_header_spec.rb +0 -0
  198. data/spec/{legacy_watirspec → watir2}/table_headers_spec.rb +0 -0
  199. data/spec/{legacy_watirspec → watir2}/table_row_spec.rb +0 -0
  200. data/spec/{legacy_watirspec → watir2}/table_rows_spec.rb +0 -0
  201. data/spec/{legacy_watirspec → watir2}/table_spec.rb +0 -0
  202. data/spec/{legacy_watirspec → watir2}/tables_spec.rb +0 -0
  203. data/spec/{legacy_watirspec → watir2}/text_field_spec.rb +0 -0
  204. data/spec/{legacy_watirspec → watir2}/text_fields_spec.rb +0 -0
  205. data/spec/{legacy_watirspec → watir2}/ul_spec.rb +0 -0
  206. data/spec/{legacy_watirspec → watir2}/uls_spec.rb +0 -0
  207. data/spec/{legacy_watirspec → watir2}/watir_compatibility_spec.rb +0 -0
  208. data/spec/{legacy_watirspec → watir2}/watirspec_helper.rb +0 -0
  209. data/spec/{new_watirspec → watir3}/browser_spec.rb +11 -21
  210. data/spec/{new_watirspec → watir3}/clipboard_spec.rb +2 -2
  211. data/spec/{new_watirspec → watir3}/collection_spec.rb +0 -0
  212. data/spec/{new_watirspec → watir3}/element_spec.rb +30 -12
  213. data/spec/watir3/guards.rb +39 -0
  214. data/spec/{new_watirspec → watir3}/keys_spec.rb +0 -0
  215. data/spec/watir3/server.rb +91 -0
  216. data/spec/{new_watirspec → watir3}/watirspec_helper.rb +0 -0
  217. data/spec/{new_watirspec → watir3}/window_spec.rb +8 -83
  218. metadata +315 -280
  219. data/lib/operadriver/selenium-common.jar +0 -0
  220. data/spec/legacy_watirspec/element_spec.rb +0 -86
  221. data/spec/new_watirspec/preferences_spec.rb +0 -144
  222. data/spec/new_watirspec/screenshot_spec.rb +0 -34
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html>
3
+ <meta charset="utf-8" />
4
+ <title>Frames</title>
5
+
6
+ <p>
7
+ foobar
8
+ </p>
9
+
10
+ <iframe name="test" src="paragraphs.html">
11
+ Your browser does not support frames.
12
+ </iframe>
13
+ </html>
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <meta charset='utf-8'>
3
+ <title>A grid of links with algebraic notation</title>
4
+
5
+ <table>
6
+ <tr>
7
+ <td><a href='#A3'>A3</a></td>
8
+ <td><a href='#B3'>B3</a></td>
9
+ <td><a href='#C3'>C3</a></td>
10
+ </tr>
11
+ <tr>
12
+ <td><a href='#A2'>A2</a></td>
13
+ <td><a href='#B2'>B2</a></td>
14
+ <td><a href='#C2'>C2</a></td>
15
+ </tr>
16
+ <tr>
17
+ <td><a href='#A1'>A1</a></td>
18
+ <td><a href='#B1'>B1</a></td>
19
+ <td><a href='#C1'>C1</a></td>
20
+ </tr>
21
+
22
+
23
+
24
+ </table>
25
+
26
+
27
+
28
+
29
+
@@ -0,0 +1,6 @@
1
+ <!DOCTYPE html>
2
+ <meta charset='utf-8'>
3
+ <title>Simple page with two input fields, of which one has a value</title>
4
+
5
+ <p><input id='one' value='foobar'></p>
6
+ <p><input id='two'></p>
@@ -0,0 +1,20 @@
1
+ <!doctype html>
2
+ <meta charset="utf-8" />
3
+ <title>onclick</title>
4
+
5
+ <p>
6
+ <button onclick="clickme()">Click me</button>
7
+ </p>
8
+
9
+ <p id="clicks"></p>
10
+
11
+ <script>
12
+
13
+ var clicks = 0;
14
+
15
+ function clickme() {
16
+ clicks++;
17
+ document.getElementById('clicks').innerHTML = clicks;
18
+ }
19
+
20
+ </script>
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <meta charset="utf-8" />
3
+ <title>Paragraphs</title>
4
+
5
+ <p id="first">
6
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.
7
+ </p>
8
+
9
+ <p id="second">
10
+ Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.
11
+ </p>
12
+
13
+ <p id="third">
14
+ Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.
15
+ </p>
@@ -0,0 +1,6 @@
1
+ <!DOCTYPE html>
2
+ <meta charset='utf-8'>
3
+ <title>Simple page with two input fields</title>
4
+
5
+ <p><input name='one'></p>
6
+ <p><input name='two'></p>
File without changes
@@ -0,0 +1,68 @@
1
+ RSpec::Matchers.define :close_window do
2
+ match do |actual|
3
+ actual > 0
4
+ end
5
+
6
+ failure_message_for_should do |window_id|
7
+ "expected close_window to close window, but window_id returned is not valid: #{window_id}"
8
+ end
9
+ end
10
+
11
+ RSpec::Matchers.define :close_dialog do |expected|
12
+ match do |window_id|
13
+ window_id > 0
14
+ end
15
+
16
+ failure_message_for_should do |window_id|
17
+ "expected close_dialog to close dialog, but window_id returned is not valid: #{window_id}"
18
+ end
19
+ end
20
+
21
+ RSpec::Matchers.define :open_window do
22
+ match do |actual|
23
+ actual > 0
24
+ end
25
+
26
+ failure_message_for_should do |window_id|
27
+ "expected open_window to open window, but window_id returned is not valid: #{window_id}"
28
+ end
29
+ end
30
+
31
+ RSpec::Matchers.define :open_dialog do
32
+ match do |actual|
33
+ actual > 0
34
+ end
35
+
36
+ failure_message_for_should do |window_id|
37
+ "expected open_dialog to close dialog, but window_id returned is not valid: #{window_id}"
38
+ end
39
+ end
40
+
41
+
42
+ RSpec::Matchers.define :load_window do
43
+ match do |actual|
44
+ actual > 0
45
+ end
46
+
47
+ failure_message_for_should do |window_id|
48
+ "expected load... to load in window, but window_id returned is not valid: #{window_id}"
49
+ end
50
+ end
51
+
52
+ RSpec::Matchers.define :load_page do
53
+ match do |actual|
54
+ actual > 0
55
+ end
56
+
57
+ failure_message_for_should do |window_id|
58
+ "expected load_page to load page, but window_id returned is not valid: #{window_id}"
59
+ end
60
+ end
61
+
62
+ =begin
63
+ RSpec::Matchers.define :load do |expected|
64
+ match do |actual|
65
+ expected == actual
66
+ end
67
+ end
68
+ =end
File without changes
@@ -0,0 +1,43 @@
1
+ begin
2
+ require 'rspec'
3
+ rescue LoadError
4
+ begin
5
+ require 'rubygems'
6
+ require 'rspec'
7
+ rescue LoadError
8
+ puts <<-EOS
9
+ To use rspec for testing you must install rspec gem:
10
+ gem install rspec
11
+ EOS
12
+ exit(0)
13
+ end
14
+ end
15
+
16
+ require 'rspec/core/rake_task'
17
+ namespace :watirspec do
18
+ desc "Run the specs under #{File.dirname(__FILE__)}"
19
+ RSpec::Core::RakeTask.new(:run) do |t|
20
+ t.pattern = "#{File.dirname(__FILE__)}/*_spec.rb"
21
+ end
22
+ end
23
+
24
+
25
+ namespace :watirspec do
26
+ def watirspec_config; "#{File.dirname(__FILE__)}/.git/config"; end
27
+
28
+ #
29
+ # stolen from rubinius
30
+ #
31
+
32
+ desc 'Switch to the committer url for watirspec'
33
+ task :committer do
34
+ system "git config --file #{watirspec_config} remote.origin.url git@github.com:jarib/watirspec.git"
35
+ puts "\nYou're now accessing watirspec via the committer URL."
36
+ end
37
+
38
+ desc "Switch to the watirspec anonymous URL"
39
+ task :anon do
40
+ system "git config --file #{watirspec_config} remote.origin.url git://github.com/jarib/watirspec.git"
41
+ puts "\nYou're now accessing watirspec via the anonymous URL."
42
+ end
43
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'watirspec_helper'
6
+ #require 'operawatir/desktop_helper'
7
+
8
+ module WatirSpec
9
+ module Helpers
10
+ def browser
11
+ OperaWatir::DesktopHelper.browser
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+ require 'rspec'
5
+
6
+ require 'guards'
7
+ require 'server'
8
+
9
+ require 'operawatir/helper'
10
+
11
+ OperaWatir.api = 2
12
+
13
+ RSpec.configure do |config|
14
+ config.mock_with :rr
15
+ end
16
+
17
+ module WatirSpec
18
+ extend self
19
+
20
+ attr_accessor :args, :guarded
21
+
22
+ def host
23
+ "http://#{Server.bind}:#{Server.port}"
24
+ end
25
+ alias_method :files, :host
26
+
27
+ def guards
28
+ @guards ||= []
29
+ end
30
+
31
+ def guarded?
32
+ !!@guarded
33
+ end
34
+
35
+ module Helpers
36
+ def browser
37
+ OperaWatir::Helper.browser
38
+ end
39
+
40
+ def window
41
+ browser.active_window
42
+ end
43
+
44
+ def fixture(*paths)
45
+ [WatirSpec.host, *paths].join('/')
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ include OperaWatir::DesktopExceptions
52
+
53
+ include WatirSpec::Guard::Helpers
54
+
55
+ RSpec.configure do |config|
56
+ config.include WatirSpec::Helpers
57
+
58
+ config.before(:suite) do
59
+ Thread.new { WatirSpec::Server.run! }
60
+ end
61
+ end
62
+
File without changes
File without changes
@@ -9,11 +9,13 @@ describe "Browser" do
9
9
  browser.should exist
10
10
  end
11
11
 
12
+ =begin
12
13
  it "returns false after IE#close" do
13
14
  b = WatirSpec.new_browser
14
15
  b.close
15
16
  b.should_not exist
16
17
  end
18
+ =end
17
19
  end
18
20
 
19
21
  describe "#html" do
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,155 @@
1
+ # encoding: utf-8
2
+ require File.expand_path("../spec_helper", __FILE__)
3
+
4
+ describe "Element" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
8
+ end
9
+ =begin
10
+ describe ".new" do
11
+ it "finds elements matching the conditions when given a hash of :how => 'what' arguments" do
12
+ browser.checkbox(:name => 'new_user_interests', :title => 'Dancing is fun!').value.should == 'dancing'
13
+ browser.text_field(:class_name => 'name', :index => 1).id.should == 'new_user_last_name'
14
+ end
15
+
16
+ it "raises UnknownObjectException with a sane error message when given a hash of :how => 'what' arguments (non-existing object)" do
17
+ lambda { browser.text_field(:index => 100, :name => "foo").id }.should raise_error(UnknownObjectException)
18
+ end
19
+
20
+ it "raises ArgumentError if given the wrong number of arguments" do
21
+ container = mock("container").as_null_object
22
+ lambda { Element.new(container, 1,2,3,4) }.should raise_error(ArgumentError)
23
+ lambda { Element.new(container, "foo") }.should raise_error(ArgumentError)
24
+ end
25
+ end
26
+
27
+ describe "#== and #eql?" do
28
+ before { browser.goto(WatirSpec.files + "/definition_lists.html") }
29
+
30
+ it "returns true if the two elements point to the same DOM element" do
31
+ a = browser.dl(:id => "experience-list")
32
+ b = browser.dl
33
+
34
+ a.should == b
35
+ a.should eql(b)
36
+ end
37
+
38
+ it "returns false if the two elements are not the same" do
39
+ a = browser.dls[0]
40
+ b = browser.dls[1]
41
+
42
+ a.should_not == b
43
+ a.should_not eql(b)
44
+ end
45
+
46
+ it "returns false if the other object is not an Element" do
47
+ browser.dl.should_not == 1
48
+ end
49
+ end
50
+
51
+ describe "data-* attributes" do
52
+ before { browser.goto("file://" + File.expand_path("html/data_attributes.html", File.dirname(__FILE__))) }
53
+
54
+ bug "http://github.com/jarib/celerity/issues#issue/27", :celerity do
55
+ it "finds elements by a data-* attribute" do
56
+ browser.p(:data_type => "ruby-library").should exist
57
+ end
58
+
59
+ it "returns the value of a data-* attribute" do
60
+ browser.p.data_type.should == "ruby-library"
61
+ end
62
+ end
63
+ end
64
+ =end
65
+ describe "finding with unknown tag name" do
66
+ it "finds an element by xpath" do
67
+ browser.element(:xpath => "//*[@for='new_user_first_name']").should exist
68
+ end
69
+
70
+ it "finds an element by arbitrary attribute" do
71
+ browser.element(:id => "new_user").should exist
72
+ end
73
+ =begin
74
+ it "finds several elements by xpath" do
75
+ browser.elements(:xpath => "//a").length.should == 1
76
+ end
77
+
78
+ it "finds finds several elements by arbitrary attribute" do
79
+ browser.elements(:name => /^new_user/).length.should == 30
80
+ end
81
+ =end
82
+ end
83
+ =begin
84
+ describe "#to_subtype" do
85
+ it "returns a more precise subtype of Element (input element)" do
86
+ el = browser.element(:xpath => "//input[@type='radio']").to_subtype
87
+ el.should be_kind_of(Watir::Radio)
88
+ end
89
+
90
+ it "returns a more precise subtype of Element" do
91
+ el = browser.element(:xpath => "//*[@id='messages']").to_subtype
92
+ el.should be_kind_of(Watir::Div)
93
+ end
94
+ end
95
+
96
+ describe "#focus" do
97
+ bug "http://code.google.com/p/selenium/issues/detail?id=157", [:webdriver, :firefox] do
98
+ it "fires the onfocus event for the given element" do
99
+ tf = browser.text_field(:id, "new_user_occupation")
100
+ tf.value.should == "Developer"
101
+ tf.focus
102
+ browser.div(:id, "onfocus_test").text.should == "changed by onfocus event"
103
+ end
104
+ end
105
+ end
106
+
107
+ describe "#fire_event" do
108
+ it "should fire the given event" do
109
+ browser.div(:id, "onfocus_test").text.should be_empty
110
+ browser.text_field(:id, "new_user_occupation").fire_event('onfocus')
111
+ browser.div(:id, "onfocus_test").text.should == "changed by onfocus event"
112
+ end
113
+ end
114
+
115
+ describe "#parent" do
116
+ bug "http://github.com/jarib/celerity/issues#issue/28", :celerity do
117
+ it "gets the parent of this element" do
118
+ browser.text_field(:id, "new_user_email").parent.should be_instance_of(FieldSet)
119
+ end
120
+ end
121
+ end
122
+
123
+ describe "#visible?" do
124
+ it "returns true if the element is visible" do
125
+ browser.text_field(:id, "new_user_email").should be_visible
126
+ end
127
+
128
+ it "returns false if the element is input element where type == 'hidden'" do
129
+ browser.text_field(:id, "new_user_interests_dolls").should_not be_visible
130
+ end
131
+
132
+ it "returns false if the element has style='display: none;'" do
133
+ browser.div(:id, 'changed_language').should_not be_visible
134
+ end
135
+
136
+ it "returns false if the element has style='visibility: hidden;" do
137
+ browser.div(:id, 'wants_newsletter').should_not be_visible
138
+ end
139
+
140
+ it "returns false if one of the parent elements is hidden" do
141
+ browser.div(:id, 'hidden_parent').should_not be_visible
142
+ end
143
+ end
144
+
145
+ describe "#exist?" do
146
+ it "doesn't raise when called on nested elements" do
147
+ browser.div(:id, 'no_such_div').link(:id, 'no_such_id').should_not exist
148
+ end
149
+
150
+ it "raises ArgumentError error if selector hash with :xpath has multiple entries" do
151
+ lambda { browser.div(:xpath => "//div", :class => "foo").exists? }.should raise_error(ArgumentError)
152
+ end
153
+ end
154
+ =end
155
+ end