watir 6.16.5 → 6.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/actions/enable-safari/action.yml +11 -0
- data/.github/actions/install-chrome/action.yml +11 -0
- data/.github/workflows/linux.yml +61 -0
- data/.github/workflows/mac.yml +55 -0
- data/.github/workflows/unit.yml +37 -0
- data/.github/workflows/windows.yml +39 -0
- data/.rubocop.yml +32 -107
- data/.rubocop_todo.yml +36 -0
- data/CHANGES.md +52 -0
- data/Gemfile +3 -1
- data/LICENSE +2 -2
- data/README.md +9 -10
- data/Rakefile +4 -4
- data/lib/watir/adjacent.rb +8 -10
- data/lib/watir/after_hooks.rb +4 -4
- data/lib/watir/alert.rb +1 -0
- data/lib/watir/attribute_helper.rb +2 -0
- data/lib/watir/browser.rb +7 -3
- data/lib/watir/capabilities.rb +245 -97
- data/lib/watir/cookies.rb +3 -1
- data/lib/watir/element_collection.rb +21 -6
- data/lib/watir/elements/element.rb +66 -53
- data/lib/watir/elements/file_field.rb +1 -0
- data/lib/watir/elements/html_elements.rb +0 -1
- data/lib/watir/elements/iframe.rb +4 -3
- data/lib/watir/elements/link.rb +0 -9
- data/lib/watir/elements/radio.rb +1 -1
- data/lib/watir/elements/select.rb +22 -7
- data/lib/watir/generator/base/spec_extractor.rb +4 -4
- data/lib/watir/generator/html/generator.rb +1 -1
- data/lib/watir/has_window.rb +17 -15
- data/lib/watir/http_client.rb +17 -0
- data/lib/watir/js_execution.rb +3 -3
- data/lib/watir/js_snippets.rb +2 -2
- data/lib/watir/legacy_wait.rb +1 -1
- data/lib/watir/locators/element/selector_builder/xpath.rb +50 -15
- data/lib/watir/locators/element/selector_builder.rb +12 -13
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +3 -1
- data/lib/watir/locators.rb +1 -3
- data/lib/watir/logger.rb +7 -20
- data/lib/watir/radio_set.rb +2 -2
- data/lib/watir/user_editable.rb +6 -2
- data/lib/watir/version.rb +1 -1
- data/lib/watir/wait/timer.rb +1 -1
- data/lib/watir/wait.rb +2 -0
- data/lib/watir/window.rb +8 -4
- data/lib/watir/window_collection.rb +114 -0
- data/lib/watir-webdriver.rb +1 -1
- data/lib/watir.rb +3 -1
- data/lib/watirspec/guards.rb +1 -1
- data/lib/watirspec/implementation.rb +3 -5
- data/lib/watirspec/rake_tasks.rb +2 -0
- data/lib/watirspec/runner.rb +6 -2
- data/lib/watirspec/server.rb +1 -1
- data/lib/watirspec.rb +2 -1
- data/spec/spec_helper.rb +2 -7
- data/spec/unit/capabilities_spec.rb +1234 -18
- data/spec/unit/container_spec.rb +1 -1
- data/spec/unit/logger_spec.rb +5 -7
- data/spec/unit/match_elements/element_spec.rb +17 -15
- data/spec/unit/selector_builder/button_spec.rb +16 -15
- data/spec/unit/selector_builder/element_spec.rb +58 -9
- data/spec/unit/selector_builder/text_field_spec.rb +14 -14
- data/spec/unit/unit_helper.rb +2 -4
- data/spec/watirspec/after_hooks_spec.rb +58 -68
- data/spec/watirspec/alert_spec.rb +69 -79
- data/spec/watirspec/browser_spec.rb +51 -48
- data/spec/watirspec/cookies_spec.rb +52 -37
- data/spec/watirspec/drag_and_drop_spec.rb +14 -38
- data/spec/watirspec/elements/button_spec.rb +2 -0
- data/spec/watirspec/elements/buttons_spec.rb +1 -1
- data/spec/watirspec/elements/checkbox_spec.rb +8 -4
- data/spec/watirspec/elements/date_field_spec.rb +18 -9
- data/spec/watirspec/elements/date_time_field_spec.rb +3 -4
- data/spec/watirspec/elements/div_spec.rb +62 -54
- data/spec/watirspec/elements/element_spec.rb +73 -88
- data/spec/watirspec/elements/elements_spec.rb +12 -3
- data/spec/watirspec/elements/filefield_spec.rb +25 -50
- data/spec/watirspec/elements/form_spec.rb +6 -8
- data/spec/watirspec/elements/frame_spec.rb +10 -13
- data/spec/watirspec/elements/iframe_spec.rb +12 -9
- data/spec/watirspec/elements/iframes_spec.rb +2 -2
- data/spec/watirspec/elements/link_spec.rb +23 -12
- data/spec/watirspec/elements/links_spec.rb +11 -3
- data/spec/watirspec/elements/option_spec.rb +15 -17
- data/spec/watirspec/elements/select_list_spec.rb +222 -117
- data/spec/watirspec/elements/text_field_spec.rb +8 -4
- data/spec/watirspec/elements/tr_spec.rb +0 -9
- data/spec/watirspec/html/forms_with_input_elements.html +1 -0
- data/spec/watirspec/html/iframes.html +3 -0
- data/spec/watirspec/html/non_control_elements.html +4 -4
- data/spec/watirspec/html/right_click.html +12 -0
- data/spec/watirspec/html/special_chars.html +3 -0
- data/spec/watirspec/html/wait.html +6 -6
- data/spec/watirspec/html/window_switching.html +10 -0
- data/spec/watirspec/legacy_wait_spec.rb +216 -0
- data/spec/watirspec/special_chars_spec.rb +10 -0
- data/spec/watirspec/support/rspec_matchers.rb +33 -14
- data/spec/watirspec/user_editable_spec.rb +1 -1
- data/spec/watirspec/wait_spec.rb +257 -305
- data/spec/watirspec/window_switching_spec.rb +347 -211
- data/spec/watirspec_helper.rb +17 -20
- data/support/doctest_helper.rb +0 -2
- data/watir.gemspec +6 -7
- metadata +37 -26
- data/.travis.yml +0 -84
- data/appveyor.yml +0 -12
- data/lib/watir/elements/area.rb +0 -10
- data/spec/watirspec/relaxed_locate_spec.rb +0 -113
@@ -1,110 +1,100 @@
|
|
1
1
|
require 'watirspec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
3
|
+
describe 'Alert API' do
|
4
|
+
before do
|
5
|
+
browser.goto WatirSpec.url_for('alerts.html')
|
6
|
+
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
after do
|
9
|
+
browser.alert.ok if browser.alert.exists?
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
73
|
-
|
63
|
+
expect(browser.alert).to_not exist
|
64
|
+
end
|
74
65
|
|
75
|
-
|
76
|
-
|
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
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
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
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
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 '
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
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
|
-
|
154
|
-
|
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.
|
163
|
-
"-Dwebdriver.gecko.driver=#{Webdrivers::Geckodriver.
|
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
|
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!(
|
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
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
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
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
72
|
-
options = {path: '/set_cookie',
|
73
|
-
secure: true,
|
74
|
-
expires: expires}
|
100
|
+
options = {secure: true}
|
75
101
|
|
76
|
-
browser.cookies.add '
|
77
|
-
cookie = browser.cookies.to_a.find { |e| e[:name] == '
|
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 '
|
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
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
-
|
108
|
-
|
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
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
136
|
-
|
137
|
-
actual.each { |cookie| cookie.delete(:expires) }
|
152
|
+
expected.each { |cookie| cookie.delete(:expires) }
|
153
|
+
actual.each { |cookie| cookie.delete(:expires) }
|
138
154
|
|
139
|
-
|
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
|
-
|
5
|
-
|
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
|
-
|
10
|
-
|
7
|
+
let(:draggable) { browser.div id: 'draggable' }
|
8
|
+
let(:droppable) { browser.div id: 'droppable' }
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
@@ -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
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
28
|
-
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
80
|
-
|
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
|
-
|
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://
|
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://
|
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
|