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
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
@@ -49,6 +49,11 @@ describe 'Browser' do
49
49
  end
50
50
 
51
51
  describe '#quit' do
52
+ it 'exists' do
53
+ browser.should respond_to :quit
54
+ end
55
+
56
+ =begin
52
57
  before :each do
53
58
  browser.quit
54
59
  end
@@ -76,8 +81,12 @@ describe 'Browser' do
76
81
  after :all do
77
82
  # OperaWatir::Helper.reconnect
78
83
  end
84
+ =end
85
+
79
86
  end
80
87
 
88
+
89
+
81
90
  =begin
82
91
  describe '#windows' do
83
92
  before :all do
@@ -109,19 +118,6 @@ describe 'Browser' do
109
118
  end
110
119
  =end
111
120
 
112
- describe '#version' do
113
- it 'fetches the version number of the driver' do
114
- browser.version.should match /\d{1,}\.\d{1,}\.\d{1,}/
115
- end
116
- end
117
-
118
- describe '#pid' do
119
- it 'fetches the PID from the attached browser instance' do
120
- browser.pid.should be_integer
121
- browser.pid.should_not be_zero
122
- end
123
- end
124
-
125
121
  describe '#platform' do
126
122
  it 'fetches the platform the browser is running on' do
127
123
  # TODO: Improve regexp
@@ -129,13 +125,6 @@ describe 'Browser' do
129
125
  end
130
126
  end
131
127
 
132
- describe '#build' do
133
- it 'fetches the build number of the attached browser instance' do
134
- browser.build.should be_integer
135
- browser.build.should_not be_zero
136
- end
137
- end
138
-
139
128
  describe '#path' do
140
129
  it 'fetches the full path to the binary of the attached browser' do
141
130
  # TODO: Improve regexp
@@ -153,11 +142,12 @@ describe 'Browser' do
153
142
  it 'is attached to a browser instance' do
154
143
  browser.connected?.should be_true
155
144
  end
156
-
145
+ =begin
157
146
  it 'is not attached to a browser instance' do
158
147
  browser.quit
159
148
  browser.connected?.should be_false
160
149
  end
150
+ =end
161
151
  end
162
152
 
163
153
  describe '#desktop?' do
@@ -16,8 +16,8 @@ describe 'Browser' do
16
16
 
17
17
  describe '#select_all' do
18
18
  it 'selects the value of an input field' do
19
- window.eval_js('one = document.getElementById("one");')
20
- window.eval_js('one.value.substr(one.selectionStart, one.selectionEnd - one.selectionStart)').to_s.should == 'foobar'
19
+ window.execute_script('one = document.getElementById("one");')
20
+ window.execute_script('one.value.substr(one.selectionStart, one.selectionEnd - one.selectionStart)').to_s.should == 'foobar'
21
21
  end
22
22
  end
23
23
 
File without changes
@@ -109,15 +109,6 @@ describe 'Element' do
109
109
  end
110
110
  end
111
111
 
112
- # hash
113
- describe '#visual_hash' do
114
- it 'is the MD5 hash of the screenshot of the element' do
115
- window.url = fixture('images.html')
116
- # this hash is from from Watir 1
117
- image = window.find_by_tag(:img)[1].visual_hash.should == '0x45688373bcf08d9ecf111ecb2bcb7c4e'
118
- end
119
- end
120
-
121
112
  # states
122
113
  # ------
123
114
 
@@ -436,14 +427,14 @@ describe 'Element' do
436
427
  end
437
428
  end
438
429
 
439
- describe '#trigger!' do
430
+ describe '#fire_event' do
440
431
  it 'fires the given event on the element' do
441
- window.find_by_id('link_3').first.trigger!('click')
432
+ window.find_by_id('link_3').fire_event :click
442
433
  browser.url.should include 'forms_with_input_elements.html'
443
434
  end
444
435
 
445
436
  it 'fires event handlers' do
446
- window.find_by_id('html_test').first.trigger!('dblclick')
437
+ window.find_by_id('html_test').first.fire_event :dblclick
447
438
  window.find_by_id('messages').first.text.should include 'double clicked'
448
439
  end
449
440
  end
@@ -453,4 +444,31 @@ describe 'Element' do
453
444
 
454
445
  # style
455
446
 
447
+
448
+
449
+ # drag and drop
450
+ # -------------
451
+
452
+ describe '#drag_and_drop_by' do
453
+ it 'drags an element 100 pixels right and down' do
454
+ browser.url = fixture('draggable.html')
455
+ @draggable = window.find_by_id('draggable')
456
+
457
+ @draggable.location.to_s.should == 'x100y100'
458
+ @draggable.drag_and_drop_by(100,100)
459
+ @draggable.location.to_s.should == 'x200y200'
460
+ end
461
+ end
462
+
463
+ describe '#drag_and_drop_on' do
464
+ it 'drags one element onto another, triggering the correct events' do
465
+ browser.url = fixture('draggable.html')
466
+ @draggable = window.find_by_id('draggable')
467
+ @droppable = window.find_by_id('droppable')
468
+
469
+ @draggable.drag_and_drop_on(@droppable)
470
+ @droppable.text.should include 'Om nom nom!'
471
+ end
472
+ end
473
+
456
474
  end
@@ -0,0 +1,39 @@
1
+ module WatirSpec
2
+ class Guard
3
+
4
+ attr_accessor :type, :browsers, :data
5
+
6
+ def initialize(type, browsers, data={})
7
+ self.type, self.browsers, self.data = type, browsers, data
8
+ WatirSpec.guards << self
9
+ end
10
+
11
+ def guarded?(browser)
12
+ WatirSpec.guarded? || browsers.include?(browser.name)
13
+ end
14
+
15
+ module Helpers
16
+ def deviates_on(*browsers)
17
+ guard = WatirSpec::Guard.new :deviation, browsers, :file => caller.first
18
+ yield unless guard.guarded?(OperaWatir::Helper.browser)
19
+ end
20
+
21
+ def not_compliant_on(*browsers)
22
+ guard = WatirSpec::Guard.new :non_compliance, browsers, :file => caller.first
23
+ yield unless guard.guarded?(OperaWatir::Helper.browser)
24
+ end
25
+
26
+ def compliant_on(*browsers)
27
+ guard = WatirSpec::Guard.new :compliance, browsers, :file => caller.first
28
+ yield unless guard.guarded?(OperaWatir::Helper.browser)
29
+ end
30
+
31
+ def bug(url, *browsers)
32
+ guard = WatirSpec::Guard.new :bug, browsers, :file => caller.first, :url => url
33
+ yield unless guard.guarded?(OperaWatir::Helper.browser)
34
+ end
35
+ end
36
+
37
+ end
38
+ end
39
+
File without changes
@@ -0,0 +1,91 @@
1
+ # encoding: utf-8
2
+ require 'sinatra/base'
3
+
4
+ class WatirSpec::Server < ::Sinatra::Base
5
+
6
+ set :app_file, __FILE__
7
+ set :root, File.dirname(__FILE__)
8
+ set :public, lambda { File.join(root, 'fixtures')}
9
+ set :static, true
10
+ set :run, false
11
+ set :environment, :production
12
+ set :bind, 'localhost'
13
+ set :port, 2000
14
+ set :server, %w[thin mongrel webrick]
15
+
16
+ get '/' do
17
+ self.class.name
18
+ end
19
+
20
+ get '/big' do
21
+ Class.new do
22
+ def each(&blk)
23
+ yield "<html><head><title>Big Content</title></head><body>"
24
+ string = "hello "*205
25
+ 300.times { yield string }
26
+ yield "</body></html>"
27
+ end
28
+ end.new
29
+ end
30
+
31
+ post '/post_to_me' do
32
+ "You posted the following content:\n#{ env['rack.input'].read }"
33
+ end
34
+
35
+ get '/plain_text' do
36
+ content_type 'text/plain'
37
+ 'This is text/plain'
38
+ end
39
+
40
+ get '/ajax' do
41
+ sleep 10
42
+ "A slooow ajax response"
43
+ end
44
+
45
+ get '/charset_mismatch' do
46
+ content_type 'text/html; charset=UTF-8'
47
+ %{
48
+ <html>
49
+ <head>
50
+ <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
51
+ </head>
52
+ <body>
53
+ <h1>ø</h1>
54
+ </body>
55
+ </html>
56
+ }
57
+ end
58
+
59
+ get '/octet_stream' do
60
+ content_type 'application/octet-stream'
61
+ 'This is application/octet-stream'
62
+ end
63
+
64
+ get '/set_cookie' do
65
+ content_type 'text/plain'
66
+ headers 'Set-Cookie' => "monster=/"
67
+
68
+ "C is for cookie, it's good enough for me"
69
+ end
70
+
71
+ get '/header_echo' do
72
+ content_type 'text/plain'
73
+ env.inspect
74
+ end
75
+
76
+ get '/authentication' do
77
+ auth = Rack::Auth::Basic::Request.new(env)
78
+
79
+ unless auth.provided? && auth.credentials == %w[foo bar]
80
+ headers 'WWW-Authenticate' => %(Basic realm="localhost")
81
+ halt 401, 'Authorization Required'
82
+ end
83
+
84
+ "ok"
85
+ end
86
+
87
+ get '/encodable_<stuff>' do
88
+ 'page with characters in URI that need encoding'
89
+ end
90
+
91
+ end
File without changes
@@ -121,7 +121,7 @@ describe 'Window' do
121
121
  end
122
122
 
123
123
  it 'changes when the title tag changes' do
124
- window.find_by_tag(:title).first.text = 'changed'
124
+ window.execute_script('document.title = "changed"')
125
125
  window.title.should == 'changed'
126
126
  end
127
127
  end
@@ -209,107 +209,32 @@ describe 'Window' do
209
209
 
210
210
  # click(x,y)
211
211
 
212
- describe '#type' do
213
- it 'types the given characters' do
214
- browser.url = fixture('forms_with_input_elements.html')
215
- textbox = window.find_by_id('new_user_first_name').first
216
- textbox.focus!
217
- window.type('test')
218
- textbox.attr(:value).should == 'test'
219
- end
220
-
221
- it 'sends keypress events' do
222
- browser.url = fixture('keys.html')
223
- window.type('hello')
224
- window.find_by_id('log').text.should include 'press, 104, h,'
225
- window.find_by_id('log').text.should include 'down, 69, E,'
226
- window.find_by_id('log').text.should include 'up, 79, O,'
227
- end
228
- end
229
-
230
- describe '#key' do
231
- before :each do
232
- browser.url = fixture('keys.html')
233
- end
234
-
235
- it 'presses and releases the given key' do
236
- # TODO Is this how we should send ctrl/shift/alt?
237
- window.key('ctrl')
238
-
239
- window.find_by_id('log').text.should include 'down'
240
- window.find_by_id('log').text.should include 'ctrl'
241
- window.find_by_id('log').text.should include 'up'
242
- end
243
-
244
- it 'can press the home key' do
245
- window.key('home')
246
- window.find_by_id('log').text.should include 'press, 36'
247
- end
248
-
249
- it 'can press the tab key' do
250
- window.key('tab')
251
- window.find_by_id('log').text.should include 'press, 9'
252
- end
253
-
254
- it 'tabs through fields when tab is pressed' do
255
- window.url = fixture('forms_with_input_elements.html')
256
- window.key('tab')
257
- window.find_by_id('new_user_first_name').focused?.should be_true
258
- end
259
-
260
- it 'can press the F3 key' do
261
- window.key('f3')
262
- window.find_by_id('log').text.should include 'press, 114'
263
- end
264
- end
265
-
266
- describe '#key_down' do
267
- it 'presses down the given key' do
268
- browser.url = fixture('keys.html')
269
- window.key_down('ctrl')
270
- window.key_down('shift')
271
- window.find_by_id('log').text.should include 'ctrl,shift'
272
- # Don't leave them pressed down
273
- window.key_up('ctrl')
274
- window.key_up('shift')
275
- end
276
- end
277
-
278
- describe '#key_up' do
279
- it 'releases the given key' do
280
- browser.url = fixture('keys.html')
281
- window.key_down('ctrl')
282
- window.key_up('ctrl')
283
- window.find_by_id('log').text.should include 'up, 17'
284
- end
285
- end
286
-
287
- describe '#eval_js' do
212
+ describe '#execute_script' do
288
213
  it 'executes Javascript in the page' do
289
- window.eval_js('document.title = "test"')
214
+ window.execute_script('document.title = "test"')
290
215
  window.title.should == 'test'
291
216
  end
292
217
 
293
218
  it 'returns an element when the Javascript does' do
294
- window.eval_js('document.createElement("div")').tag_name.should match /div/i
219
+ window.execute_script('document.createElement("div")').tag_name.should match /div/i
295
220
  end
296
221
 
297
222
  it 'returns a number when the Javascript does' do
298
- window.eval_js('Math.abs(-5)').should == 5
223
+ window.execute_script('Math.abs(-5)').should == 5
299
224
  end
300
225
 
301
226
  it 'returns a boolean when the Javascript does' do
302
- window.eval_js('(function(){return true;})()').should be_true
227
+ window.execute_script('(function(){return true;})()').should be_true
303
228
  end
304
229
 
305
230
  it 'returns an array when the Javascript does' do
306
- result = window.eval_js('["this", "is", "a", "test"]') # WTR-227
231
+ result = window.execute_script('["this", "is", "a", "test"]') # WTR-227
307
232
  result.length.should == 4
308
233
  result[3].should == 'test'
309
234
  end
310
235
 
311
236
  it 'returns a string when the result is not one of these types' do
312
- window.eval_js('({one:"two"}).toString()').should == '[object Object]'
237
+ window.execute_script('({one:"two"}).toString()').should == '[object Object]'
313
238
  end
314
239
  end
315
240