watir 6.14.0 → 6.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +24 -6
  3. data/CHANGES.md +10 -0
  4. data/Gemfile +0 -2
  5. data/README.md +1 -1
  6. data/Rakefile +2 -2
  7. data/lib/watir.rb +2 -3
  8. data/lib/watir/adjacent.rb +2 -2
  9. data/lib/watir/alert.rb +5 -9
  10. data/lib/watir/attribute_helper.rb +2 -3
  11. data/lib/watir/browser.rb +5 -17
  12. data/lib/watir/capabilities.rb +11 -0
  13. data/lib/watir/cell_container.rb +2 -2
  14. data/lib/watir/container.rb +7 -8
  15. data/lib/watir/cookies.rb +2 -12
  16. data/lib/watir/element_collection.rb +2 -2
  17. data/lib/watir/elements/button.rb +2 -11
  18. data/lib/watir/elements/element.rb +43 -25
  19. data/lib/watir/elements/hidden.rb +1 -1
  20. data/lib/watir/elements/iframe.rb +7 -5
  21. data/lib/watir/elements/option.rb +2 -13
  22. data/lib/watir/elements/select.rb +6 -22
  23. data/lib/watir/elements/table.rb +2 -2
  24. data/lib/watir/exception.rb +1 -2
  25. data/lib/watir/generator/base/idl_sorter.rb +1 -1
  26. data/lib/watir/generator/base/spec_extractor.rb +2 -2
  27. data/lib/watir/generator/base/visitor.rb +1 -1
  28. data/lib/watir/generator/html/generator.rb +0 -1
  29. data/lib/watir/generator/html/spec_extractor.rb +1 -1
  30. data/lib/watir/generator/html/visitor.rb +1 -1
  31. data/lib/watir/generator/svg/spec_extractor.rb +1 -1
  32. data/lib/watir/generator/svg/visitor.rb +1 -1
  33. data/lib/watir/js_execution.rb +11 -0
  34. data/lib/watir/js_snippets.rb +1 -1
  35. data/lib/watir/js_snippets/elementObscured.js +14 -0
  36. data/lib/watir/js_snippets/selectedText.js +17 -0
  37. data/lib/watir/legacy_wait.rb +5 -5
  38. data/lib/watir/locators.rb +16 -5
  39. data/lib/watir/locators/anchor/selector_builder.rb +38 -0
  40. data/lib/watir/locators/button/locator.rb +14 -12
  41. data/lib/watir/locators/button/selector_builder.rb +0 -22
  42. data/lib/watir/locators/button/selector_builder/xpath.rb +67 -12
  43. data/lib/watir/locators/button/validator.rb +2 -1
  44. data/lib/watir/locators/cell/selector_builder.rb +0 -14
  45. data/lib/watir/locators/cell/selector_builder/xpath.rb +21 -0
  46. data/lib/watir/locators/element/locator.rb +60 -153
  47. data/lib/watir/locators/element/selector_builder.rb +103 -84
  48. data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +66 -0
  49. data/lib/watir/locators/element/selector_builder/xpath.rb +195 -82
  50. data/lib/watir/locators/element/selector_builder/xpath_support.rb +27 -0
  51. data/lib/watir/locators/element/validator.rb +2 -9
  52. data/lib/watir/locators/row/selector_builder.rb +5 -22
  53. data/lib/watir/locators/row/selector_builder/xpath.rb +53 -0
  54. data/lib/watir/locators/text_area/selector_builder.rb +1 -1
  55. data/lib/watir/locators/text_area/selector_builder/xpath.rb +19 -0
  56. data/lib/watir/locators/text_field/locator.rb +11 -8
  57. data/lib/watir/locators/text_field/selector_builder.rb +0 -23
  58. data/lib/watir/locators/text_field/selector_builder/xpath.rb +33 -4
  59. data/lib/watir/locators/text_field/validator.rb +4 -4
  60. data/lib/watir/radio_set.rb +5 -5
  61. data/lib/watir/row_container.rb +2 -2
  62. data/lib/watir/user_editable.rb +2 -2
  63. data/lib/watir/version.rb +1 -1
  64. data/lib/watir/wait.rb +24 -37
  65. data/lib/watir/window.rb +11 -8
  66. data/lib/watirspec/remote_server.rb +3 -1
  67. data/spec/locator_spec_helper.rb +1 -1
  68. data/spec/spec_helper.rb +25 -1
  69. data/spec/unit/anchor_locator_spec.rb +68 -0
  70. data/spec/unit/capabilities_spec.rb +27 -0
  71. data/spec/unit/element_locator_spec.rb +184 -101
  72. data/spec/unit/logger_spec.rb +5 -0
  73. data/spec/watirspec/adjacent_spec.rb +34 -34
  74. data/spec/watirspec/after_hooks_spec.rb +78 -35
  75. data/spec/watirspec/alert_spec.rb +10 -0
  76. data/spec/watirspec/browser_spec.rb +27 -1
  77. data/spec/watirspec/element_hidden_spec.rb +6 -0
  78. data/spec/watirspec/elements/button_spec.rb +5 -11
  79. data/spec/watirspec/elements/buttons_spec.rb +1 -1
  80. data/spec/watirspec/elements/checkbox_spec.rb +2 -15
  81. data/spec/watirspec/elements/date_time_field_spec.rb +6 -1
  82. data/spec/watirspec/elements/dd_spec.rb +0 -17
  83. data/spec/watirspec/elements/del_spec.rb +0 -14
  84. data/spec/watirspec/elements/div_spec.rb +0 -18
  85. data/spec/watirspec/elements/dl_spec.rb +0 -17
  86. data/spec/watirspec/elements/dt_spec.rb +0 -17
  87. data/spec/watirspec/elements/element_spec.rb +177 -17
  88. data/spec/watirspec/elements/elements_spec.rb +7 -6
  89. data/spec/watirspec/elements/em_spec.rb +0 -13
  90. data/spec/watirspec/elements/filefield_spec.rb +0 -11
  91. data/spec/watirspec/elements/form_spec.rb +6 -0
  92. data/spec/watirspec/elements/hn_spec.rb +0 -14
  93. data/spec/watirspec/elements/iframe_spec.rb +15 -0
  94. data/spec/watirspec/elements/ins_spec.rb +0 -14
  95. data/spec/watirspec/elements/labels_spec.rb +1 -1
  96. data/spec/watirspec/elements/li_spec.rb +0 -14
  97. data/spec/watirspec/elements/link_spec.rb +22 -14
  98. data/spec/watirspec/elements/links_spec.rb +13 -0
  99. data/spec/watirspec/elements/list_spec.rb +15 -0
  100. data/spec/watirspec/elements/ol_spec.rb +0 -14
  101. data/spec/watirspec/elements/option_spec.rb +0 -10
  102. data/spec/watirspec/elements/p_spec.rb +0 -14
  103. data/spec/watirspec/elements/pre_spec.rb +0 -14
  104. data/spec/watirspec/elements/radio_spec.rb +0 -14
  105. data/spec/watirspec/elements/select_list_spec.rb +0 -10
  106. data/spec/watirspec/elements/span_spec.rb +4 -15
  107. data/spec/watirspec/elements/strong_spec.rb +4 -15
  108. data/spec/watirspec/elements/table_nesting_spec.rb +1 -1
  109. data/spec/watirspec/elements/table_spec.rb +7 -0
  110. data/spec/watirspec/elements/text_field_spec.rb +10 -2
  111. data/spec/watirspec/elements/text_fields_spec.rb +1 -1
  112. data/spec/watirspec/elements/tr_spec.rb +1 -1
  113. data/spec/watirspec/elements/ul_spec.rb +0 -14
  114. data/spec/watirspec/html/closeable.html +8 -0
  115. data/spec/watirspec/html/forms_with_input_elements.html +28 -23
  116. data/spec/watirspec/html/nested_elements.html +9 -9
  117. data/spec/watirspec/html/obscured.html +34 -0
  118. data/spec/watirspec/html/tables.html +13 -13
  119. data/spec/watirspec/radio_set_spec.rb +5 -0
  120. data/spec/watirspec/selector_builder/button_spec.rb +254 -0
  121. data/spec/watirspec/selector_builder/cell_spec.rb +93 -0
  122. data/spec/watirspec/selector_builder/element_spec.rb +639 -0
  123. data/spec/watirspec/selector_builder/row_spec.rb +150 -0
  124. data/spec/watirspec/selector_builder/text_spec.rb +170 -0
  125. data/spec/watirspec/support/rspec_matchers.rb +6 -1
  126. data/spec/watirspec/user_editable_spec.rb +4 -0
  127. data/spec/watirspec/wait_spec.rb +65 -14
  128. data/spec/watirspec/window_switching_spec.rb +54 -1
  129. data/spec/watirspec_helper.rb +2 -0
  130. data/watir.gemspec +7 -1
  131. metadata +86 -8
  132. data/lib/watir/locators/text_area/locator.rb +0 -13
  133. data/lib/watir/xpath_support.rb +0 -18
@@ -226,7 +226,18 @@ describe 'Window' do
226
226
  browser.window(title: 'closeable window').use
227
227
  browser.a(id: 'close').click
228
228
  Watir::Wait.until { browser.windows.size == 1 }
229
- expect(browser.window).to_not be_present
229
+ expect(browser.window).to_not exist
230
+ end
231
+
232
+ it 'returns false if window closes during iteration' do
233
+ browser.window(title: 'closeable window').use
234
+ original_handle = browser.original_window.instance_variable_get('@handle')
235
+ handles = browser.windows.map { |w| w.instance_variable_get('@handle') }
236
+
237
+ browser.a(id: 'close').click
238
+ Watir::Wait.until { browser.windows.size == 1 }
239
+ allow(browser.wd).to receive(:window_handles).and_return(handles, [original_handle])
240
+ expect(browser.window(title: 'closeable window')).to_not exist
230
241
  end
231
242
  end
232
243
  end
@@ -272,6 +283,48 @@ describe 'Window' do
272
283
  end
273
284
  end
274
285
  end
286
+
287
+ it 'raises an exception when using an element on a closed window' do
288
+ window = browser.window(title: 'closeable window')
289
+ window.use
290
+ browser.a(id: 'close').click
291
+ msg = 'browser window was closed'
292
+ expect { browser.a.text }.to raise_exception(Watir::Exception::NoMatchingWindowFoundException, msg)
293
+ end
294
+
295
+ it 'raises an exception when locating a closed window' do
296
+ browser.window(title: 'closeable window').use
297
+ handles = browser.windows.map(&:handle)
298
+ browser.a(id: 'close').click
299
+ allow(browser.wd).to receive(:window_handles).and_return(handles, [browser.original_window.handle])
300
+ expect { browser.window(title: 'closeable window').use }.to raise_no_matching_window_exception
301
+ end
302
+
303
+ it 'raises an exception when locating a window closed during lookup' do
304
+ browser.window(title: 'closeable window').use
305
+ browser.a(id: 'close-delay').click
306
+
307
+ begin
308
+ module Watir
309
+ class Browser
310
+ alias title_old title
311
+
312
+ def title
313
+ sleep 0.5
314
+ title_old
315
+ end
316
+ end
317
+ end
318
+
319
+ expect { browser.window(title: 'closeable window').use }.to raise_no_matching_window_exception
320
+ ensure
321
+ module Watir
322
+ class Browser
323
+ alias title title_old
324
+ end
325
+ end
326
+ end
327
+ end
275
328
  end
276
329
 
277
330
  bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1223277', :firefox do
@@ -1,6 +1,8 @@
1
1
  require 'watirspec'
2
2
  require 'spec_helper'
3
3
 
4
+ Watir.default_timeout = 8
5
+
4
6
  if ENV['SELENIUM_STATS'] == 'true'
5
7
  require 'selenium_statistics'
6
8
  at_exit { SeleniumStatistics.print_results }
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.require_paths = ['lib']
28
28
 
29
29
  s.add_dependency 'selenium-webdriver', '~> 3.4', '>= 3.4.1'
30
+ s.add_runtime_dependency 'regexp_parser', '~>1.2'
30
31
 
31
32
  s.add_development_dependency 'activesupport', '~> 4.0', '>= 4.1.11' # for pluralization during code generation
32
33
  s.add_development_dependency 'coveralls'
@@ -35,9 +36,14 @@ Gem::Specification.new do |s|
35
36
  s.add_development_dependency 'pry'
36
37
  s.add_development_dependency 'rake', '~> 0.9.2'
37
38
  s.add_development_dependency 'rspec', '~> 3.0'
39
+ s.add_development_dependency 'rspec-retry'
38
40
  s.add_development_dependency 'rubocop', '~> 0.59'
39
41
  s.add_development_dependency 'selenium_statistics'
40
- s.add_development_dependency 'webdrivers', '~> 3.4'
42
+ s.add_development_dependency 'simplecov'
43
+ s.add_development_dependency 'simplecov-console'
44
+ # This forces chromedriver 2.42 since 2.43 breaks some alert / windows things
45
+ # https://bugs.chromium.org/p/chromedriver/issues/detail?id=2615
46
+ s.add_development_dependency 'webdrivers', '= 3.4.1'
41
47
  s.add_development_dependency 'webidl', '>= 0.2.2'
42
48
  s.add_development_dependency 'yard', '> 0.8.2.1'
43
49
  s.add_development_dependency 'yard-doctest', '>= 0.1.8'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.14.0
4
+ version: 6.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rodionov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-09-14 00:00:00.000000000 Z
12
+ date: 2018-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: selenium-webdriver
@@ -31,6 +31,20 @@ dependencies:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.4.1
34
+ - !ruby/object:Gem::Dependency
35
+ name: regexp_parser
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
34
48
  - !ruby/object:Gem::Dependency
35
49
  name: activesupport
36
50
  requirement: !ruby/object:Gem::Requirement
@@ -135,6 +149,20 @@ dependencies:
135
149
  - - "~>"
136
150
  - !ruby/object:Gem::Version
137
151
  version: '3.0'
152
+ - !ruby/object:Gem::Dependency
153
+ name: rspec-retry
154
+ requirement: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ type: :development
160
+ prerelease: false
161
+ version_requirements: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
138
166
  - !ruby/object:Gem::Dependency
139
167
  name: rubocop
140
168
  requirement: !ruby/object:Gem::Requirement
@@ -163,20 +191,48 @@ dependencies:
163
191
  - - ">="
164
192
  - !ruby/object:Gem::Version
165
193
  version: '0'
194
+ - !ruby/object:Gem::Dependency
195
+ name: simplecov
196
+ requirement: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ type: :development
202
+ prerelease: false
203
+ version_requirements: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ - !ruby/object:Gem::Dependency
209
+ name: simplecov-console
210
+ requirement: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ type: :development
216
+ prerelease: false
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
166
222
  - !ruby/object:Gem::Dependency
167
223
  name: webdrivers
168
224
  requirement: !ruby/object:Gem::Requirement
169
225
  requirements:
170
- - - "~>"
226
+ - - '='
171
227
  - !ruby/object:Gem::Version
172
- version: '3.4'
228
+ version: 3.4.1
173
229
  type: :development
174
230
  prerelease: false
175
231
  version_requirements: !ruby/object:Gem::Requirement
176
232
  requirements:
177
- - - "~>"
233
+ - - '='
178
234
  - !ruby/object:Gem::Version
179
- version: '3.4'
235
+ version: 3.4.1
180
236
  - !ruby/object:Gem::Dependency
181
237
  name: webidl
182
238
  requirement: !ruby/object:Gem::Requirement
@@ -304,6 +360,7 @@ files:
304
360
  - lib/watir/js_snippets.rb
305
361
  - lib/watir/js_snippets/attributeValues.js
306
362
  - lib/watir/js_snippets/backgroundColor.js
363
+ - lib/watir/js_snippets/elementObscured.js
307
364
  - lib/watir/js_snippets/fireEvent.js
308
365
  - lib/watir/js_snippets/focus.js
309
366
  - lib/watir/js_snippets/getInnerHtml.js
@@ -316,24 +373,30 @@ files:
316
373
  - lib/watir/js_snippets/selectOptionsValue.js
317
374
  - lib/watir/js_snippets/selectText.js
318
375
  - lib/watir/js_snippets/selectedOptions.js
376
+ - lib/watir/js_snippets/selectedText.js
319
377
  - lib/watir/js_snippets/setText.js
320
378
  - lib/watir/js_snippets/setValue.js
321
379
  - lib/watir/legacy_wait.rb
322
380
  - lib/watir/locators.rb
381
+ - lib/watir/locators/anchor/selector_builder.rb
323
382
  - lib/watir/locators/button/locator.rb
324
383
  - lib/watir/locators/button/selector_builder.rb
325
384
  - lib/watir/locators/button/selector_builder/xpath.rb
326
385
  - lib/watir/locators/button/validator.rb
327
386
  - lib/watir/locators/cell/locator.rb
328
387
  - lib/watir/locators/cell/selector_builder.rb
388
+ - lib/watir/locators/cell/selector_builder/xpath.rb
329
389
  - lib/watir/locators/element/locator.rb
330
390
  - lib/watir/locators/element/selector_builder.rb
391
+ - lib/watir/locators/element/selector_builder/regexp_disassembler.rb
331
392
  - lib/watir/locators/element/selector_builder/xpath.rb
393
+ - lib/watir/locators/element/selector_builder/xpath_support.rb
332
394
  - lib/watir/locators/element/validator.rb
333
395
  - lib/watir/locators/row/locator.rb
334
396
  - lib/watir/locators/row/selector_builder.rb
335
- - lib/watir/locators/text_area/locator.rb
397
+ - lib/watir/locators/row/selector_builder/xpath.rb
336
398
  - lib/watir/locators/text_area/selector_builder.rb
399
+ - lib/watir/locators/text_area/selector_builder/xpath.rb
337
400
  - lib/watir/locators/text_field/locator.rb
338
401
  - lib/watir/locators/text_field/selector_builder.rb
339
402
  - lib/watir/locators/text_field/selector_builder/xpath.rb
@@ -348,7 +411,6 @@ files:
348
411
  - lib/watir/wait.rb
349
412
  - lib/watir/wait/timer.rb
350
413
  - lib/watir/window.rb
351
- - lib/watir/xpath_support.rb
352
414
  - lib/watirspec.rb
353
415
  - lib/watirspec/guards.rb
354
416
  - lib/watirspec/implementation.rb
@@ -360,6 +422,8 @@ files:
360
422
  - spec/implementation_spec.rb
361
423
  - spec/locator_spec_helper.rb
362
424
  - spec/spec_helper.rb
425
+ - spec/unit/anchor_locator_spec.rb
426
+ - spec/unit/capabilities_spec.rb
363
427
  - spec/unit/container_spec.rb
364
428
  - spec/unit/element_locator_spec.rb
365
429
  - spec/unit/logger_spec.rb
@@ -510,6 +574,7 @@ files:
510
574
  - spec/watirspec/html/nested_iframes.html
511
575
  - spec/watirspec/html/nested_tables.html
512
576
  - spec/watirspec/html/non_control_elements.html
577
+ - spec/watirspec/html/obscured.html
513
578
  - spec/watirspec/html/removed_element.html
514
579
  - spec/watirspec/html/right_click.html
515
580
  - spec/watirspec/html/special_chars.html
@@ -522,6 +587,11 @@ files:
522
587
  - spec/watirspec/radio_set_spec.rb
523
588
  - spec/watirspec/relaxed_locate_spec.rb
524
589
  - spec/watirspec/screenshot_spec.rb
590
+ - spec/watirspec/selector_builder/button_spec.rb
591
+ - spec/watirspec/selector_builder/cell_spec.rb
592
+ - spec/watirspec/selector_builder/element_spec.rb
593
+ - spec/watirspec/selector_builder/row_spec.rb
594
+ - spec/watirspec/selector_builder/text_spec.rb
525
595
  - spec/watirspec/special_chars_spec.rb
526
596
  - spec/watirspec/support/rspec_matchers.rb
527
597
  - spec/watirspec/user_editable_spec.rb
@@ -561,6 +631,8 @@ test_files:
561
631
  - spec/implementation_spec.rb
562
632
  - spec/locator_spec_helper.rb
563
633
  - spec/spec_helper.rb
634
+ - spec/unit/anchor_locator_spec.rb
635
+ - spec/unit/capabilities_spec.rb
564
636
  - spec/unit/container_spec.rb
565
637
  - spec/unit/element_locator_spec.rb
566
638
  - spec/unit/logger_spec.rb
@@ -711,6 +783,7 @@ test_files:
711
783
  - spec/watirspec/html/nested_iframes.html
712
784
  - spec/watirspec/html/nested_tables.html
713
785
  - spec/watirspec/html/non_control_elements.html
786
+ - spec/watirspec/html/obscured.html
714
787
  - spec/watirspec/html/removed_element.html
715
788
  - spec/watirspec/html/right_click.html
716
789
  - spec/watirspec/html/special_chars.html
@@ -723,6 +796,11 @@ test_files:
723
796
  - spec/watirspec/radio_set_spec.rb
724
797
  - spec/watirspec/relaxed_locate_spec.rb
725
798
  - spec/watirspec/screenshot_spec.rb
799
+ - spec/watirspec/selector_builder/button_spec.rb
800
+ - spec/watirspec/selector_builder/cell_spec.rb
801
+ - spec/watirspec/selector_builder/element_spec.rb
802
+ - spec/watirspec/selector_builder/row_spec.rb
803
+ - spec/watirspec/selector_builder/text_spec.rb
726
804
  - spec/watirspec/special_chars_spec.rb
727
805
  - spec/watirspec/support/rspec_matchers.rb
728
806
  - spec/watirspec/user_editable_spec.rb
@@ -1,13 +0,0 @@
1
- module Watir
2
- module Locators
3
- class TextArea
4
- class Locator < Element::Locator
5
- private
6
-
7
- def can_convert_regexp_to_contains?
8
- false
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,18 +0,0 @@
1
- module Watir
2
- module XpathSupport
3
- def self.escape(value)
4
- if value.include? "'"
5
- parts = value.split("'", -1).map { |part| "'#{part}'" }
6
- string = parts.join(%(,"'",))
7
-
8
- "concat(#{string})"
9
- else
10
- "'#{value}'"
11
- end
12
- end
13
-
14
- def self.downcase(value)
15
- "translate(#{value},'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"
16
- end
17
- end # XpathSupport
18
- end # Watir