watir 6.16.5 → 6.19.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +5 -5
  2. data/.github/actions/enable-safari/action.yml +11 -0
  3. data/.github/actions/install-chrome/action.yml +11 -0
  4. data/.github/workflows/linux.yml +61 -0
  5. data/.github/workflows/mac.yml +55 -0
  6. data/.github/workflows/unit.yml +37 -0
  7. data/.github/workflows/windows.yml +39 -0
  8. data/.rubocop.yml +32 -107
  9. data/.rubocop_todo.yml +36 -0
  10. data/CHANGES.md +52 -0
  11. data/Gemfile +3 -1
  12. data/LICENSE +2 -2
  13. data/README.md +9 -10
  14. data/Rakefile +4 -4
  15. data/lib/watir/adjacent.rb +8 -10
  16. data/lib/watir/after_hooks.rb +4 -4
  17. data/lib/watir/alert.rb +1 -0
  18. data/lib/watir/attribute_helper.rb +2 -0
  19. data/lib/watir/browser.rb +7 -3
  20. data/lib/watir/capabilities.rb +245 -97
  21. data/lib/watir/cookies.rb +3 -1
  22. data/lib/watir/element_collection.rb +21 -6
  23. data/lib/watir/elements/element.rb +66 -53
  24. data/lib/watir/elements/file_field.rb +1 -0
  25. data/lib/watir/elements/html_elements.rb +0 -1
  26. data/lib/watir/elements/iframe.rb +4 -3
  27. data/lib/watir/elements/link.rb +0 -9
  28. data/lib/watir/elements/radio.rb +1 -1
  29. data/lib/watir/elements/select.rb +22 -7
  30. data/lib/watir/generator/base/spec_extractor.rb +4 -4
  31. data/lib/watir/generator/html/generator.rb +1 -1
  32. data/lib/watir/has_window.rb +17 -15
  33. data/lib/watir/http_client.rb +17 -0
  34. data/lib/watir/js_execution.rb +3 -3
  35. data/lib/watir/js_snippets.rb +2 -2
  36. data/lib/watir/legacy_wait.rb +1 -1
  37. data/lib/watir/locators/element/selector_builder/xpath.rb +50 -15
  38. data/lib/watir/locators/element/selector_builder.rb +12 -13
  39. data/lib/watir/locators/text_field/selector_builder/xpath.rb +3 -1
  40. data/lib/watir/locators.rb +1 -3
  41. data/lib/watir/logger.rb +7 -20
  42. data/lib/watir/radio_set.rb +2 -2
  43. data/lib/watir/user_editable.rb +6 -2
  44. data/lib/watir/version.rb +1 -1
  45. data/lib/watir/wait/timer.rb +1 -1
  46. data/lib/watir/wait.rb +2 -0
  47. data/lib/watir/window.rb +8 -4
  48. data/lib/watir/window_collection.rb +114 -0
  49. data/lib/watir-webdriver.rb +1 -1
  50. data/lib/watir.rb +3 -1
  51. data/lib/watirspec/guards.rb +1 -1
  52. data/lib/watirspec/implementation.rb +3 -5
  53. data/lib/watirspec/rake_tasks.rb +2 -0
  54. data/lib/watirspec/runner.rb +6 -2
  55. data/lib/watirspec/server.rb +1 -1
  56. data/lib/watirspec.rb +2 -1
  57. data/spec/spec_helper.rb +2 -7
  58. data/spec/unit/capabilities_spec.rb +1234 -18
  59. data/spec/unit/container_spec.rb +1 -1
  60. data/spec/unit/logger_spec.rb +5 -7
  61. data/spec/unit/match_elements/element_spec.rb +17 -15
  62. data/spec/unit/selector_builder/button_spec.rb +16 -15
  63. data/spec/unit/selector_builder/element_spec.rb +58 -9
  64. data/spec/unit/selector_builder/text_field_spec.rb +14 -14
  65. data/spec/unit/unit_helper.rb +2 -4
  66. data/spec/watirspec/after_hooks_spec.rb +58 -68
  67. data/spec/watirspec/alert_spec.rb +69 -79
  68. data/spec/watirspec/browser_spec.rb +51 -48
  69. data/spec/watirspec/cookies_spec.rb +52 -37
  70. data/spec/watirspec/drag_and_drop_spec.rb +14 -38
  71. data/spec/watirspec/elements/button_spec.rb +2 -0
  72. data/spec/watirspec/elements/buttons_spec.rb +1 -1
  73. data/spec/watirspec/elements/checkbox_spec.rb +8 -4
  74. data/spec/watirspec/elements/date_field_spec.rb +18 -9
  75. data/spec/watirspec/elements/date_time_field_spec.rb +3 -4
  76. data/spec/watirspec/elements/div_spec.rb +62 -54
  77. data/spec/watirspec/elements/element_spec.rb +73 -88
  78. data/spec/watirspec/elements/elements_spec.rb +12 -3
  79. data/spec/watirspec/elements/filefield_spec.rb +25 -50
  80. data/spec/watirspec/elements/form_spec.rb +6 -8
  81. data/spec/watirspec/elements/frame_spec.rb +10 -13
  82. data/spec/watirspec/elements/iframe_spec.rb +12 -9
  83. data/spec/watirspec/elements/iframes_spec.rb +2 -2
  84. data/spec/watirspec/elements/link_spec.rb +23 -12
  85. data/spec/watirspec/elements/links_spec.rb +11 -3
  86. data/spec/watirspec/elements/option_spec.rb +15 -17
  87. data/spec/watirspec/elements/select_list_spec.rb +222 -117
  88. data/spec/watirspec/elements/text_field_spec.rb +8 -4
  89. data/spec/watirspec/elements/tr_spec.rb +0 -9
  90. data/spec/watirspec/html/forms_with_input_elements.html +1 -0
  91. data/spec/watirspec/html/iframes.html +3 -0
  92. data/spec/watirspec/html/non_control_elements.html +4 -4
  93. data/spec/watirspec/html/right_click.html +12 -0
  94. data/spec/watirspec/html/special_chars.html +3 -0
  95. data/spec/watirspec/html/wait.html +6 -6
  96. data/spec/watirspec/html/window_switching.html +10 -0
  97. data/spec/watirspec/legacy_wait_spec.rb +216 -0
  98. data/spec/watirspec/special_chars_spec.rb +10 -0
  99. data/spec/watirspec/support/rspec_matchers.rb +33 -14
  100. data/spec/watirspec/user_editable_spec.rb +1 -1
  101. data/spec/watirspec/wait_spec.rb +257 -305
  102. data/spec/watirspec/window_switching_spec.rb +347 -211
  103. data/spec/watirspec_helper.rb +17 -20
  104. data/support/doctest_helper.rb +0 -2
  105. data/watir.gemspec +6 -7
  106. metadata +37 -26
  107. data/.travis.yml +0 -84
  108. data/appveyor.yml +0 -12
  109. data/lib/watir/elements/area.rb +0 -10
  110. data/spec/watirspec/relaxed_locate_spec.rb +0 -113
@@ -1,110 +1,100 @@
1
1
  require 'watirspec_helper'
2
2
 
3
- not_compliant_on :headless do
4
- describe 'Alert API' do
5
- before do
6
- browser.goto WatirSpec.url_for('alerts.html')
7
- end
3
+ describe 'Alert API' do
4
+ before do
5
+ browser.goto WatirSpec.url_for('alerts.html')
6
+ end
8
7
 
9
- after do
10
- browser.alert.ok if browser.alert.exists?
11
- end
8
+ after do
9
+ browser.alert.ok if browser.alert.exists?
10
+ end
12
11
 
13
- compliant_on :relaxed_locate do
14
- context 'Relaxed Waits' do
15
- context 'when acting on an alert' do
16
- it 'raises exception after timing out' do
17
- expect { browser.alert.text }.to wait_and_raise_unknown_object_exception
18
- end
12
+ compliant_on :relaxed_locate do
13
+ context 'Relaxed Waits' do
14
+ context 'when acting on an alert' do
15
+ it 'raises exception after timing out' do
16
+ expect { browser.alert.text }.to wait_and_raise_unknown_object_exception
19
17
  end
20
18
  end
21
19
  end
20
+ end
22
21
 
23
- context 'alert' do
24
- describe '#text' do
25
- it 'returns text of alert' do
26
- browser.button(id: 'alert').click
27
- expect(browser.alert.text).to include('ok')
28
- end
22
+ context 'alert' do
23
+ describe '#text' do
24
+ it 'returns text of alert' do
25
+ browser.button(id: 'alert').click
26
+ expect(browser.alert.text).to include('ok')
29
27
  end
28
+ end
30
29
 
31
- describe '#exists?' do
32
- it 'returns false if alert is not present' do
33
- expect(browser.alert).to_not exist
34
- end
30
+ describe '#exists?' do
31
+ it 'returns false if alert is not present' do
32
+ expect(browser.alert).to_not exist
33
+ end
35
34
 
36
- bug 'Alert exception not thrown, so Browser#inspect hangs', :safari do
37
- it 'returns true if alert is present' do
38
- browser.button(id: 'alert').click
39
- browser.wait_until(timeout: 10) { browser.alert.exists? }
40
- end
41
- end
35
+ it 'returns true if alert is present' do
36
+ browser.button(id: 'alert').click
37
+ browser.wait_until(timeout: 10) { browser.alert.exists? }
42
38
  end
39
+ end
43
40
 
44
- describe '#ok' do
45
- not_compliant_on :safari do
46
- it 'closes alert' do
47
- browser.button(id: 'alert').click
48
- browser.alert.ok
49
- expect(browser.alert).to_not exist
50
- end
51
- end
41
+ describe '#ok' do
42
+ it 'closes alert' do
43
+ browser.button(id: 'alert').click
44
+ browser.alert.ok
45
+ expect(browser.alert).to_not exist
52
46
  end
47
+ end
53
48
 
54
- bug 'https://code.google.com/p/chromedriver/issues/detail?id=26', [:chrome, :macosx] do
55
- not_compliant_on :safari do
56
- describe '#close' do
57
- it 'closes alert' do
58
- browser.button(id: 'alert').click
59
- browser.alert.close
60
- expect(browser.alert).to_not exist
61
- end
62
- end
63
- end
49
+ describe '#close' do
50
+ it 'closes alert' do
51
+ browser.button(id: 'alert').click
52
+ browser.alert.close
53
+ expect(browser.alert).to_not exist
64
54
  end
55
+ end
65
56
 
66
- not_compliant_on :relaxed_locate do
67
- describe 'wait_until_present' do
68
- it 'waits until alert is present and goes on' do
69
- browser.button(id: 'timeout-alert').click
70
- browser.alert.wait_until_present.ok
57
+ not_compliant_on :relaxed_locate do
58
+ describe 'wait_until_present' do
59
+ it 'waits until alert is present and goes on' do
60
+ browser.button(id: 'timeout-alert').click
61
+ browser.alert.wait_until_present.ok
71
62
 
72
- expect(browser.alert).to_not exist
73
- end
63
+ expect(browser.alert).to_not exist
64
+ end
74
65
 
75
- it 'raises error if alert is not present after timeout' do
76
- expect { browser.alert.wait_until_present.ok }.to raise_timeout_exception
77
- end
66
+ it 'raises error if alert is not present after timeout' do
67
+ expect { browser.alert.wait_until_present.ok }.to raise_timeout_exception
78
68
  end
79
69
  end
80
70
  end
71
+ end
81
72
 
82
- context 'confirm' do
83
- describe '#ok' do
84
- it 'accepts confirm' do
85
- browser.button(id: 'confirm').click
86
- browser.alert.ok
87
- expect(browser.button(id: 'confirm').value).to eq 'true'
88
- end
73
+ context 'confirm' do
74
+ describe '#ok' do
75
+ it 'accepts confirm' do
76
+ browser.button(id: 'confirm').click
77
+ browser.alert.ok
78
+ expect(browser.button(id: 'confirm').value).to eq 'true'
89
79
  end
80
+ end
90
81
 
91
- describe '#close' do
92
- it 'cancels confirm' do
93
- browser.button(id: 'confirm').click
94
- browser.alert.close
95
- expect(browser.button(id: 'confirm').value).to eq 'false'
96
- end
82
+ describe '#close' do
83
+ it 'cancels confirm' do
84
+ browser.button(id: 'confirm').click
85
+ browser.alert.close
86
+ expect(browser.button(id: 'confirm').value).to eq 'false'
97
87
  end
98
88
  end
89
+ end
99
90
 
100
- context 'prompt' do
101
- describe '#set' do
102
- it 'enters text to prompt' do
103
- browser.button(id: 'prompt').click
104
- browser.alert.set 'My Name'
105
- browser.alert.ok
106
- expect(browser.button(id: 'prompt').value).to eq 'My Name'
107
- end
91
+ context 'prompt' do
92
+ describe '#set' do
93
+ it 'enters text to prompt' do
94
+ browser.button(id: 'prompt').click
95
+ browser.alert.set 'My Name'
96
+ browser.alert.ok
97
+ expect(browser.button(id: 'prompt').value).to eq 'My Name'
108
98
  end
109
99
  end
110
100
  end
@@ -12,17 +12,15 @@ describe 'Browser' do
12
12
  expect(browser).to exist
13
13
  end
14
14
 
15
- bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1223277', :firefox do
16
- not_compliant_on :headless do
17
- it 'returns false if window is closed' do
18
- browser.goto WatirSpec.url_for('window_switching.html')
19
- browser.a(id: 'open').click
20
- Watir::Wait.until { browser.windows.size == 2 }
21
- browser.window(title: 'closeable window').use
22
- browser.a(id: 'close').click
23
- Watir::Wait.until { browser.windows.size == 1 }
24
- expect(browser.exists?).to be false
25
- end
15
+ bug 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException', :safari do
16
+ it 'returns false if window is closed' do
17
+ browser.goto WatirSpec.url_for('window_switching.html')
18
+ browser.a(id: 'open').click
19
+ Watir::Wait.until { browser.windows.size == 2 }
20
+ browser.window(title: 'closeable window').use
21
+ browser.a(id: 'close').click
22
+ Watir::Wait.until { browser.windows.size == 1 }
23
+ expect(browser.exists?).to be false
26
24
  end
27
25
  end
28
26
 
@@ -74,7 +72,7 @@ describe 'Browser' do
74
72
  end
75
73
  end
76
74
 
77
- bug 'Capitalization bug fixed in upcoming release', %i[remote firefox] do
75
+ bug 'Capitalization issue', :safari do
78
76
  describe '#name' do
79
77
  it 'returns browser name' do
80
78
  expect(browser.name).to eq(WatirSpec.implementation.browser_args.first)
@@ -150,8 +148,9 @@ describe 'Browser' do
150
148
  end
151
149
  end
152
150
 
153
- describe '#new' do
154
- not_compliant_on :remote, :appveyor do
151
+ # TODO: Temporarily disabling this before moving it to unit tests
152
+ xdescribe '#new' do
153
+ not_compliant_on :remote do
155
154
  context 'with parameters' do
156
155
  let(:url) { 'http://localhost:4544/wd/hub/' }
157
156
 
@@ -159,8 +158,8 @@ describe 'Browser' do
159
158
  @original = WatirSpec.implementation.clone
160
159
 
161
160
  require 'watirspec/remote_server'
162
- args = ["-Dwebdriver.chrome.driver=#{Webdrivers::Chromedriver.binary}",
163
- "-Dwebdriver.gecko.driver=#{Webdrivers::Geckodriver.binary}"]
161
+ args = ["-Dwebdriver.chrome.driver=#{Webdrivers::Chromedriver.driver_path}",
162
+ "-Dwebdriver.gecko.driver=#{Webdrivers::Geckodriver.driver_path}"]
164
163
  WatirSpec::RemoteServer.new.start(4544, args: args)
165
164
  browser.close
166
165
  end
@@ -287,13 +286,15 @@ describe 'Browser' do
287
286
 
288
287
  compliant_on :chrome do
289
288
  not_compliant_on :watigiri do
290
- it 'takes port and driver_opt as arguments' do
289
+ it 'takes service as argument' do
291
290
  @original = WatirSpec.implementation.clone
292
291
  browser.close
293
292
  @opts = WatirSpec.implementation.browser_args.last
293
+ browser_name = WatirSpec.implementation.browser_args.first
294
+
295
+ service = Selenium::WebDriver::Service.send(browser_name, port: '2314', args: ['foo'])
294
296
 
295
- @opts.merge!(port: '2314',
296
- driver_opts: {args: ['foo']},
297
+ @opts.merge!(service: service,
297
298
  listener: LocalConfig::SelectorListener.new)
298
299
 
299
300
  @new_browser = WatirSpec.new_browser
@@ -373,16 +374,19 @@ describe 'Browser' do
373
374
  end
374
375
  end
375
376
 
376
- not_compliant_on :headless do
377
- describe '#refresh' do
378
- it 'refreshes the page' do
379
- browser.goto(WatirSpec.url_for('non_control_elements.html'))
380
- browser.span(class: 'footer').click
381
- expect(browser.span(class: 'footer').text).to include('Javascript')
382
- browser.refresh
383
- browser.span(class: 'footer').wait_until(&:present?)
384
- expect(browser.span(class: 'footer').text).to_not include('Javascript')
377
+ describe '#refresh' do
378
+ it 'refreshes the page' do
379
+ browser.goto(WatirSpec.url_for('non_control_elements.html'))
380
+
381
+ compliant_on :headless do
382
+ browser.div(id: 'best_language').scroll.to
385
383
  end
384
+
385
+ browser.div(id: 'best_language').click
386
+ expect(browser.div(id: 'best_language').text).to include('Ruby!')
387
+ browser.refresh
388
+ browser.div(id: 'best_language').wait_until(&:present?)
389
+ expect(browser.div(id: 'best_language').text).to_not include('Ruby!')
386
390
  end
387
391
  end
388
392
 
@@ -509,27 +513,26 @@ describe 'Browser' do
509
513
 
510
514
  describe '#wait' do
511
515
  # The only way to get engage this method is with page load strategy set to "none"
512
- # Chrome will be blocking on document ready state because it does not yet support page load strategy
513
516
  # This spec is both mocking out the response and demonstrating the necessary settings for it to be meaningful
514
- not_compliant_on :chrome do
515
- it 'waits for document ready state to be complete' do
516
- @original = WatirSpec.implementation.clone
517
- browser.close
518
- @opts = WatirSpec.implementation.browser_args.last
519
-
520
- @opts[:page_load_strategy] = 'none'
521
- browser = WatirSpec.new_browser
522
-
523
- start_time = Time.now
524
- allow(browser).to receive(:ready_state) { Time.now < start_time + 3 ? 'loading' : 'complete' }
525
- expect(browser.ready_state).to eq 'loading'
526
- browser.wait(20)
527
- expect(browser.ready_state).to eq 'complete'
528
-
529
- browser.close
530
- WatirSpec.implementation = @original.clone
531
- $browser = WatirSpec.new_browser
532
- end
517
+ it 'waits for document ready state to be complete' do
518
+ @original = WatirSpec.implementation.clone
519
+ browser.close
520
+ @opts = WatirSpec.implementation.browser_args.last
521
+
522
+ @opts[:page_load_strategy] = 'none'
523
+ browser = WatirSpec.new_browser
524
+
525
+ start_time = Time.now
526
+ allow(browser).to receive(:ready_state) { Time.now < start_time + 3 ? 'loading' : 'complete' }
527
+ expect(browser.ready_state).to eq 'loading'
528
+
529
+ browser.wait(20)
530
+ expect(Time.now - start_time).to be > 3
531
+ expect(browser.ready_state).to eq 'complete'
532
+
533
+ browser.close
534
+ WatirSpec.implementation = @original.clone
535
+ $browser = WatirSpec.new_browser
533
536
  end
534
537
  end
535
538
 
@@ -42,7 +42,7 @@ describe 'Browser#cookies' do
42
42
  end
43
43
 
44
44
  not_compliant_on :internet_explorer do
45
- it 'adds a cookie' do
45
+ it 'adds a cookie without options' do
46
46
  browser.goto set_cookie_url
47
47
  verify_cookies_count 1
48
48
 
@@ -63,29 +63,49 @@ describe 'Browser#cookies' do
63
63
  end
64
64
  end
65
65
 
66
- # TODO: - Split this up into multiple tests or figure out which parts are not compliant
67
- not_compliant_on :chrome, :internet_explorer, :safari, :firefox do
68
- it 'adds a cookie with options' do
66
+ it 'adds a cookie with path' do
67
+ browser.goto set_cookie_url
68
+
69
+ options = {path: '/set_cookie'}
70
+
71
+ browser.cookies.add 'path', 'b', options
72
+ cookie = browser.cookies.to_a.find { |e| e[:name] == 'path' }
73
+
74
+ expect(cookie).to_not be_nil
75
+ expect(cookie[:name]).to eq 'path'
76
+ expect(cookie[:value]).to eq 'b'
77
+ expect(cookie[:path]).to eq '/set_cookie'
78
+ end
79
+
80
+ it 'adds a cookie with expiration' do
81
+ browser.goto set_cookie_url
82
+
83
+ expires = Time.now + 10_000
84
+ options = {expires: expires}
85
+
86
+ browser.cookies.add 'expiration', 'b', options
87
+ cookie = browser.cookies.to_a.find { |e| e[:name] == 'expiration' }
88
+
89
+ expect(cookie).to_not be_nil
90
+ expect(cookie[:name]).to eq 'expiration'
91
+ expect(cookie[:value]).to eq 'b'
92
+ # a few ms slack
93
+ expect((cookie[:expires]).to_i).to be_within(2).of(expires.to_i)
94
+ end
95
+
96
+ bug 'https://bugs.chromium.org/p/chromedriver/issues/detail?id=2727', :chrome, :safari do
97
+ it 'adds a cookie with security' do
69
98
  browser.goto set_cookie_url
70
99
 
71
- expires = Time.now + 10_000
72
- options = {path: '/set_cookie',
73
- secure: true,
74
- expires: expires}
100
+ options = {secure: true}
75
101
 
76
- browser.cookies.add 'a', 'b', options
77
- cookie = browser.cookies.to_a.find { |e| e[:name] == 'a' }
102
+ browser.cookies.add 'secure', 'b', options
103
+ cookie = browser.cookies.to_a.find { |e| e[:name] == 'secure' }
78
104
  expect(cookie).to_not be_nil
79
105
 
80
- expect(cookie[:name]).to eq 'a'
106
+ expect(cookie[:name]).to eq 'secure'
81
107
  expect(cookie[:value]).to eq 'b'
82
-
83
- expect(cookie[:path]).to eq '/set_cookie'
84
108
  expect(cookie[:secure]).to be true
85
-
86
- expect(cookie[:expires]).to be_kind_of(Time)
87
- # a few ms slack
88
- expect((cookie[:expires]).to_i).to be_within(2).of(expires.to_i)
89
109
  end
90
110
  end
91
111
 
@@ -98,15 +118,13 @@ describe 'Browser#cookies' do
98
118
  verify_cookies_count 0
99
119
  end
100
120
 
101
- bug 'https://code.google.com/p/selenium/issues/detail?id=5487', :safari do
102
- it 'clears all cookies' do
103
- browser.goto set_cookie_url
104
- browser.cookies.add 'foo', 'bar'
105
- verify_cookies_count 2
121
+ it 'clears all cookies' do
122
+ browser.goto set_cookie_url
123
+ browser.cookies.add 'foo', 'bar'
124
+ verify_cookies_count 2
106
125
 
107
- browser.cookies.clear
108
- verify_cookies_count 0
109
- end
126
+ browser.cookies.clear
127
+ verify_cookies_count 0
110
128
  end
111
129
  end
112
130
 
@@ -124,20 +142,17 @@ describe 'Browser#cookies' do
124
142
  end
125
143
  end
126
144
 
127
- bug 'https://github.com/mozilla/geckodriver/issues/1000', :firefox do
128
- describe '#load' do
129
- it 'loads cookies from file' do
130
- browser.cookies.clear
131
- browser.cookies.load file
132
- expected = browser.cookies.to_a
133
- actual = YAML.safe_load(IO.read(file), [::Symbol])
145
+ describe '#load' do
146
+ it 'loads cookies from file' do
147
+ browser.cookies.clear
148
+ browser.cookies.load file
149
+ expected = browser.cookies.to_a
150
+ actual = YAML.safe_load(IO.read(file), [::Symbol])
134
151
 
135
- # https://code.google.com/p/selenium/issues/detail?id=6834
136
- expected.each { |cookie| cookie.delete(:expires) }
137
- actual.each { |cookie| cookie.delete(:expires) }
152
+ expected.each { |cookie| cookie.delete(:expires) }
153
+ actual.each { |cookie| cookie.delete(:expires) }
138
154
 
139
- expect(actual).to eq(expected)
140
- end
155
+ expect(actual).to eq(expected)
141
156
  end
142
157
  end
143
158
  end
@@ -1,47 +1,23 @@
1
1
  require 'watirspec_helper'
2
2
 
3
3
  describe 'Element' do
4
- not_compliant_on %i[remote firefox] do
5
- bug 'Safari does not strip text', :safari do
6
- context 'drag and drop' do
7
- before { browser.goto WatirSpec.url_for('drag_and_drop.html') }
4
+ context 'drag and drop' do
5
+ before { browser.goto WatirSpec.url_for('drag_and_drop.html') }
8
6
 
9
- let(:draggable) { browser.div id: 'draggable' }
10
- let(:droppable) { browser.div id: 'droppable' }
7
+ let(:draggable) { browser.div id: 'draggable' }
8
+ let(:droppable) { browser.div id: 'droppable' }
11
9
 
12
- it 'can drag and drop an element onto another' do
13
- expect(droppable.text).to eq 'Drop here'
14
- draggable.drag_and_drop_on droppable
15
- expect(droppable.text).to eq 'Dropped!'
16
- end
17
-
18
- not_compliant_on :headless, :firefox do
19
- it 'can drag and drop an element onto another when draggable is out of viewport' do
20
- reposition 'draggable'
21
- perform_drag_and_drop_on_droppable
22
- end
23
-
24
- it 'can drag and drop an element onto another when droppable is out of viewport' do
25
- reposition 'droppable'
26
- perform_drag_and_drop_on_droppable
27
- end
28
- end
29
-
30
- it 'can drag an element by the given offset' do
31
- expect(droppable.text).to eq 'Drop here'
32
- draggable.drag_and_drop_by 200, 50
33
- expect(droppable.text).to eq 'Dropped!'
34
- end
35
-
36
- def reposition(what)
37
- browser.button(id: "reposition#{what.capitalize}").click
38
- end
10
+ it 'can drag and drop an element onto another' do
11
+ expect(droppable.text).to include 'Drop here'
12
+ draggable.drag_and_drop_on droppable
13
+ expect(droppable.text).to include 'Dropped!'
14
+ end
39
15
 
40
- def perform_drag_and_drop_on_droppable
41
- expect(droppable.text).to eq 'Drop here'
42
- draggable.drag_and_drop_on droppable
43
- expect(droppable.text).to eq 'Dropped!'
44
- end
16
+ bug 'Element is getting moved to the wrong spot', :w3c do
17
+ it 'can drag an element by the given offset' do
18
+ expect(droppable.text).to include 'Drop here'
19
+ draggable.drag_and_drop_by 200, 50
20
+ expect(droppable.text).to include 'Dropped!'
45
21
  end
46
22
  end
47
23
  end
@@ -37,6 +37,8 @@ describe 'Button' do
37
37
  expect(browser.button(text: /Button 2/)).to exist
38
38
  expect(browser.button(value: 'Button 2')).to exist
39
39
  expect(browser.button(value: /Button 2/)).to exist
40
+ expect(browser.button(value: 'Button 4 With Child Text')).to exist
41
+ expect(browser.button(value: /Button 4 With Child Text/)).to exist
40
42
  end
41
43
 
42
44
  it 'returns true if the button exists (how = :caption)' do
@@ -13,7 +13,7 @@ describe 'Buttons' do
13
13
 
14
14
  describe '#length' do
15
15
  it 'returns the number of buttons' do
16
- expect(browser.buttons.length).to eq 10
16
+ expect(browser.buttons.length).to eq 11
17
17
  end
18
18
  end
19
19
 
@@ -39,12 +39,16 @@ describe 'CheckBox' do
39
39
  expect {
40
40
  expect(browser.checkbox(label: /this will not match/)).to exist
41
41
  }.to_not have_deprecated_text_regexp
42
+ end
42
43
 
43
- expect(browser.checkbox(label: /some visible some hidden/)).to_not exist
44
+ bug 'Safari is not filtering out hidden text', :safari do
45
+ it 'handles text_regexp deprecation in spite of hidden text' do
46
+ expect(browser.checkbox(label: /some visible some hidden/)).to_not exist
44
47
 
45
- expect {
46
- expect(browser.checkbox(label: /some visible$/)).to exist
47
- }.to have_deprecated_text_regexp
48
+ expect {
49
+ expect(browser.checkbox(label: /some visible$/)).to exist
50
+ }.to have_deprecated_text_regexp
51
+ end
48
52
  end
49
53
  end
50
54
 
@@ -15,17 +15,24 @@ describe 'DateField' do
15
15
  expect(browser.date_field(text: '')).to exist
16
16
  expect(browser.date_field(text: //)).to exist
17
17
  expect(browser.date_field(index: 0)).to exist
18
- expect(browser.date_field(xpath: "//input[@id='html5_date']")).to exist
19
18
  expect(browser.date_field(label: 'HTML5 Date')).to exist
20
19
  expect(browser.date_field(label: /Date$/)).to exist
21
20
  end
22
21
 
22
+ bug 'Safari does not recognize date type', :safari do
23
+ it 'returns true when using xpath' do
24
+ expect(browser.date_field(xpath: "//input[@id='html5_date']")).to exist
25
+ end
26
+ end
27
+
23
28
  it 'returns the date field if given no args' do
24
29
  expect(browser.date_field).to exist
25
30
  end
26
31
 
27
- it 'respects date fields types' do
28
- expect(browser.date_field.type).to eq('date')
32
+ bug 'Safari does not recognize date type', :safari do
33
+ it 'respects date fields types' do
34
+ expect(browser.date_field.type).to eq('date')
35
+ end
29
36
  end
30
37
 
31
38
  it 'returns false if the element does not exist' do
@@ -71,13 +78,15 @@ describe 'DateField' do
71
78
  end
72
79
  end
73
80
 
74
- describe '#type' do
75
- it 'returns the type attribute if the date field exists' do
76
- expect(browser.date_field(id: 'html5_date').type).to eq 'date'
77
- end
81
+ bug 'Safari does not recognize date type', :safari do
82
+ describe '#type' do
83
+ it 'returns the type attribute if the date field exists' do
84
+ expect(browser.date_field(id: 'html5_date').type).to eq 'date'
85
+ end
78
86
 
79
- it "raises UnknownObjectException if the date field doesn't exist" do
80
- expect { browser.date_field(index: 1337).type }.to raise_unknown_object_exception
87
+ it "raises UnknownObjectException if the date field doesn't exist" do
88
+ expect { browser.date_field(index: 1337).type }.to raise_unknown_object_exception
89
+ end
81
90
  end
82
91
  end
83
92
 
@@ -16,8 +16,7 @@ describe 'DateTimeField' do
16
16
  expect(browser.date_time_field(text: //)).to exist
17
17
  expect(browser.date_time_field(index: 0)).to exist
18
18
 
19
- # Firefox validates attribute "type" as "text" not "datetime-local"
20
- not_compliant_on :firefox do
19
+ bug 'https://github.com/mozilla/geckodriver/issues/1469', :firefox, :safari do
21
20
  expect(browser.date_time_field(xpath: "//input[@id='html5_datetime-local']")).to exist
22
21
  end
23
22
 
@@ -29,7 +28,7 @@ describe 'DateTimeField' do
29
28
  expect(browser.date_time_field).to exist
30
29
  end
31
30
 
32
- bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1424984', :firefox do
31
+ bug 'https://github.com/mozilla/geckodriver/issues/1469', :firefox, :safari do
33
32
  it 'respects date-time fields types' do
34
33
  expect(browser.date_time_field.type).to eq('datetime-local')
35
34
  end
@@ -79,7 +78,7 @@ describe 'DateTimeField' do
79
78
  end
80
79
 
81
80
  describe '#type' do
82
- bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1424984', :firefox do
81
+ bug 'https://github.com/mozilla/geckodriver/issues/1469', :firefox, :safari do
83
82
  it 'returns the type attribute if the date-time field exists' do
84
83
  expect(browser.date_time_field(id: 'html5_datetime-local').type).to eq 'datetime-local'
85
84
  end