watir 6.17.0 → 7.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/actions/enable-safari/action.yml +11 -0
- data/.github/actions/install-chrome/action.yml +12 -0
- data/.github/actions/setup-linux/action.yml +8 -0
- data/.github/workflows/tests.yml +104 -0
- data/.rubocop.yml +2 -7
- data/.rubocop_todo.yml +36 -0
- data/CHANGES.md +59 -0
- data/LICENSE +2 -2
- data/README.md +6 -10
- data/Rakefile +2 -2
- data/lib/watir.rb +4 -45
- data/lib/watir/adjacent.rb +1 -1
- data/lib/watir/alert.rb +4 -8
- data/lib/watir/attribute_helper.rb +2 -0
- data/lib/watir/browser.rb +20 -6
- data/lib/watir/capabilities.rb +79 -110
- data/lib/watir/cell_container.rb +4 -4
- data/lib/watir/container.rb +4 -26
- data/lib/watir/cookies.rb +2 -0
- data/lib/watir/element_collection.rb +21 -6
- data/lib/watir/elements/checkbox.rb +4 -4
- data/lib/watir/elements/date_field.rb +4 -4
- data/lib/watir/elements/date_time_field.rb +4 -4
- data/lib/watir/elements/element.rb +51 -59
- data/lib/watir/elements/file_field.rb +4 -4
- data/lib/watir/elements/font.rb +5 -4
- data/lib/watir/elements/hidden.rb +4 -4
- data/lib/watir/elements/html_elements.rb +444 -446
- data/lib/watir/elements/iframe.rb +6 -6
- data/lib/watir/elements/radio.rb +6 -6
- data/lib/watir/elements/select.rb +62 -90
- data/lib/watir/elements/svg_elements.rb +96 -96
- data/lib/watir/elements/text_field.rb +4 -4
- data/lib/watir/generator/base/generator.rb +4 -4
- data/lib/watir/generator/base/visitor.rb +0 -29
- data/lib/watir/generator/html/generator.rb +2 -1
- data/lib/watir/has_window.rb +22 -18
- data/lib/watir/http_client.rb +9 -0
- data/lib/watir/js_execution.rb +2 -2
- data/lib/watir/js_snippets.rb +2 -2
- data/lib/watir/locators.rb +6 -8
- data/lib/watir/locators/button/matcher.rb +0 -23
- data/lib/watir/locators/button/selector_builder/xpath.rb +4 -15
- data/lib/watir/locators/element/matcher.rb +4 -19
- data/lib/watir/locators/element/selector_builder.rb +3 -41
- data/lib/watir/locators/element/selector_builder/xpath.rb +34 -41
- data/lib/watir/locators/option/matcher.rb +24 -0
- data/lib/watir/locators/option/selector_builder.rb +8 -0
- data/lib/watir/locators/option/selector_builder/xpath.rb +37 -0
- data/lib/watir/logger.rb +4 -91
- data/lib/watir/radio_set.rb +5 -4
- data/lib/watir/row_container.rb +4 -4
- data/lib/watir/screenshot.rb +2 -8
- data/lib/watir/user_editable.rb +13 -2
- data/lib/watir/version.rb +1 -1
- data/lib/watir/wait.rb +6 -74
- data/lib/watir/wait/timer.rb +1 -1
- data/lib/watir/window.rb +24 -25
- data/lib/watir/window_collection.rb +79 -0
- data/lib/watirspec.rb +5 -2
- data/lib/watirspec/guards.rb +1 -1
- data/lib/watirspec/implementation.rb +7 -5
- data/lib/watirspec/runner.rb +2 -2
- data/lib/watirspec/server.rb +2 -2
- data/spec/spec_helper.rb +1 -21
- data/spec/unit/capabilities_spec.rb +504 -21
- data/spec/unit/match_elements/button_spec.rb +0 -13
- data/spec/unit/match_elements/element_spec.rb +55 -51
- data/spec/unit/match_elements/text_field_spec.rb +6 -6
- data/spec/unit/selector_builder/element_spec.rb +6 -23
- data/spec/unit/selector_builder/text_field_spec.rb +6 -7
- data/spec/unit/unit_helper.rb +2 -4
- data/spec/watirspec/after_hooks_spec.rb +23 -42
- data/spec/watirspec/alert_spec.rb +4 -21
- data/spec/watirspec/browser_spec.rb +186 -206
- data/spec/watirspec/cookies_spec.rb +47 -52
- data/spec/watirspec/drag_and_drop_spec.rb +5 -7
- data/spec/watirspec/elements/area_spec.rb +1 -5
- data/spec/watirspec/elements/button_spec.rb +4 -18
- data/spec/watirspec/elements/checkbox_spec.rb +10 -24
- data/spec/watirspec/elements/date_field_spec.rb +13 -16
- data/spec/watirspec/elements/date_time_field_spec.rb +14 -13
- data/spec/watirspec/elements/dd_spec.rb +3 -4
- data/spec/watirspec/elements/del_spec.rb +10 -12
- data/spec/watirspec/elements/div_spec.rb +45 -84
- data/spec/watirspec/elements/divs_spec.rb +2 -2
- data/spec/watirspec/elements/dl_spec.rb +4 -12
- data/spec/watirspec/elements/element_spec.rb +204 -181
- data/spec/watirspec/elements/elements_spec.rb +8 -9
- data/spec/watirspec/elements/filefield_spec.rb +5 -7
- data/spec/watirspec/elements/form_spec.rb +3 -5
- data/spec/watirspec/elements/forms_spec.rb +3 -5
- data/spec/watirspec/elements/frame_spec.rb +17 -22
- data/spec/watirspec/elements/iframe_spec.rb +25 -33
- data/spec/watirspec/elements/ins_spec.rb +10 -12
- data/spec/watirspec/elements/link_spec.rb +23 -23
- data/spec/watirspec/elements/links_spec.rb +8 -9
- data/spec/watirspec/elements/radio_spec.rb +11 -14
- data/spec/watirspec/elements/select_list_spec.rb +358 -209
- data/spec/watirspec/elements/span_spec.rb +12 -14
- data/spec/watirspec/elements/spans_spec.rb +1 -1
- data/spec/watirspec/elements/strong_spec.rb +1 -1
- data/spec/watirspec/elements/table_nesting_spec.rb +31 -34
- data/spec/watirspec/elements/table_spec.rb +11 -13
- data/spec/watirspec/elements/tbody_spec.rb +10 -12
- data/spec/watirspec/elements/td_spec.rb +4 -6
- data/spec/watirspec/elements/text_field_spec.rb +10 -12
- data/spec/watirspec/elements/tr_spec.rb +5 -7
- data/spec/watirspec/html/non_control_elements.html +8 -3
- data/spec/watirspec/html/special_chars.html +3 -0
- data/spec/watirspec/html/wait.html +5 -5
- data/spec/watirspec/html/window_switching.html +10 -0
- data/spec/watirspec/special_chars_spec.rb +10 -0
- data/spec/watirspec/support/rspec_matchers.rb +11 -24
- data/spec/watirspec/user_editable_spec.rb +26 -28
- data/spec/watirspec/wait_spec.rb +154 -201
- data/spec/watirspec/window_switching_spec.rb +359 -270
- data/spec/watirspec_helper.rb +52 -49
- data/support/doctest_helper.rb +0 -2
- data/watir.gemspec +4 -5
- metadata +30 -39
- data/.travis.yml +0 -87
- data/appveyor.yml +0 -13
- data/lib/watir/legacy_wait.rb +0 -123
- data/spec/implementation_spec.rb +0 -24
- data/spec/unit/container_spec.rb +0 -35
- data/spec/unit/logger_spec.rb +0 -81
- data/spec/watirspec/relaxed_locate_spec.rb +0 -109
@@ -4,7 +4,7 @@ describe 'Browser#cookies' do
|
|
4
4
|
after { browser.cookies.clear }
|
5
5
|
|
6
6
|
it 'gets an empty list of cookies' do
|
7
|
-
browser.goto WatirSpec.url_for '
|
7
|
+
browser.goto WatirSpec.url_for 'index.html'
|
8
8
|
expect(browser.cookies.to_a).to eq []
|
9
9
|
end
|
10
10
|
|
@@ -41,94 +41,89 @@ describe 'Browser#cookies' do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
verify_cookies_count 1
|
44
|
+
it 'adds a cookie without options' do
|
45
|
+
browser.goto WatirSpec.url_for 'index.html'
|
46
|
+
verify_cookies_count 0
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
browser.cookies.add 'foo', 'bar'
|
49
|
+
verify_cookies_count 1
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
verify_cookies_count 1
|
52
|
+
it 'adds a cookie with a string expires value' do
|
53
|
+
browser.goto WatirSpec.url_for 'index.html'
|
56
54
|
|
57
|
-
|
55
|
+
expire_time = Time.now + 10_000
|
58
56
|
|
59
|
-
|
57
|
+
browser.cookies.add 'foo', 'bar', expires: expire_time.to_s
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
end
|
59
|
+
cookie = browser.cookies[:foo]
|
60
|
+
expect(cookie[:expires]).to be_kind_of(Time)
|
64
61
|
end
|
65
62
|
|
66
|
-
it 'adds a cookie with path'
|
67
|
-
|
63
|
+
it 'adds a cookie with path',
|
64
|
+
except: {browser: :ie, reason: 'path contains two slashes'} do
|
65
|
+
browser.goto WatirSpec.url_for 'index.html'
|
68
66
|
|
69
67
|
options = {path: '/set_cookie'}
|
70
|
-
|
71
68
|
browser.cookies.add 'path', 'b', options
|
69
|
+
|
70
|
+
expect(browser.cookies.to_a).to be_empty
|
71
|
+
|
72
|
+
browser.goto set_cookie_url
|
72
73
|
cookie = browser.cookies.to_a.find { |e| e[:name] == 'path' }
|
73
74
|
|
74
|
-
expect(cookie).to_not be_nil
|
75
75
|
expect(cookie[:name]).to eq 'path'
|
76
76
|
expect(cookie[:value]).to eq 'b'
|
77
77
|
expect(cookie[:path]).to eq '/set_cookie'
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'adds a cookie with expiration' do
|
81
|
-
browser.goto
|
81
|
+
browser.goto WatirSpec.url_for 'index.html'
|
82
82
|
|
83
83
|
expires = Time.now + 10_000
|
84
84
|
options = {expires: expires}
|
85
85
|
|
86
86
|
browser.cookies.add 'expiration', 'b', options
|
87
|
-
cookie = browser.cookies.to_a.
|
87
|
+
cookie = browser.cookies.to_a.first
|
88
88
|
|
89
|
-
expect(cookie).to_not be_nil
|
90
89
|
expect(cookie[:name]).to eq 'expiration'
|
91
90
|
expect(cookie[:value]).to eq 'b'
|
92
|
-
|
91
|
+
|
93
92
|
expect((cookie[:expires]).to_i).to be_within(2).of(expires.to_i)
|
94
93
|
end
|
95
94
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
# Pending resolution of https://github.com/w3c/webdriver/issues/1571
|
96
|
+
it 'adding cookie with security does not raise exception but can not be retrieved',
|
97
|
+
except: [{browser: :firefox,
|
98
|
+
reason: 'https://github.com/mozilla/geckodriver/issues/1840'},
|
99
|
+
{browser: %i[chrome edge], platform: :windows}] do
|
100
|
+
browser.goto WatirSpec.url_for 'index.html'
|
101
101
|
|
102
|
-
|
103
|
-
cookie = browser.cookies.to_a.find { |e| e[:name] == 'secure' }
|
104
|
-
expect(cookie).to_not be_nil
|
102
|
+
options = {secure: true}
|
105
103
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
104
|
+
browser.cookies.add 'secure', 'b', options
|
105
|
+
cookie = browser.cookies.to_a.find { |e| e[:name] == 'secure' }
|
106
|
+
expect(cookie).to be_nil
|
110
107
|
end
|
111
108
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
verify_cookies_count 1
|
109
|
+
it 'removes a cookie' do
|
110
|
+
browser.goto set_cookie_url
|
111
|
+
verify_cookies_count 1
|
116
112
|
|
117
|
-
|
118
|
-
|
119
|
-
|
113
|
+
browser.cookies.delete 'monster'
|
114
|
+
verify_cookies_count 0
|
115
|
+
end
|
120
116
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
117
|
+
it 'clears all cookies' do
|
118
|
+
browser.goto set_cookie_url
|
119
|
+
browser.cookies.add 'foo', 'bar'
|
120
|
+
verify_cookies_count 2
|
125
121
|
|
126
|
-
|
127
|
-
|
128
|
-
end
|
122
|
+
browser.cookies.clear
|
123
|
+
verify_cookies_count 0
|
129
124
|
end
|
130
125
|
|
131
|
-
|
126
|
+
context 'cookie file' do
|
132
127
|
let(:file) { "#{Dir.tmpdir}/cookies" }
|
133
128
|
|
134
129
|
before do
|
@@ -142,7 +137,7 @@ describe 'Browser#cookies' do
|
|
142
137
|
end
|
143
138
|
end
|
144
139
|
|
145
|
-
describe '#load' do
|
140
|
+
describe '#load', except: {browser: :ie} do
|
146
141
|
it 'loads cookies from file' do
|
147
142
|
browser.cookies.clear
|
148
143
|
browser.cookies.load file
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'watirspec_helper'
|
2
2
|
|
3
3
|
describe 'Element' do
|
4
|
-
context 'drag and drop' do
|
4
|
+
context 'drag and drop', except: {browser: :ie} do
|
5
5
|
before { browser.goto WatirSpec.url_for('drag_and_drop.html') }
|
6
6
|
|
7
7
|
let(:draggable) { browser.div id: 'draggable' }
|
@@ -13,12 +13,10 @@ describe 'Element' do
|
|
13
13
|
expect(droppable.text).to include 'Dropped!'
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
expect(droppable.text).to include 'Dropped!'
|
21
|
-
end
|
16
|
+
it 'can drag an element by the given offset' do
|
17
|
+
expect(droppable.text).to include 'Drop here'
|
18
|
+
draggable.drag_and_drop_by 200, 50
|
19
|
+
expect(droppable.text).to include 'Dropped!'
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -12,11 +12,7 @@ describe 'Area' do
|
|
12
12
|
expect(browser.area(id: /NCE/)).to exist
|
13
13
|
expect(browser.area(title: 'Tables')).to exist
|
14
14
|
expect(browser.area(title: /Tables/)).to exist
|
15
|
-
|
16
|
-
not_compliant_on :internet_explorer do
|
17
|
-
expect(browser.area(href: 'tables.html')).to exist
|
18
|
-
end
|
19
|
-
|
15
|
+
expect(browser.area(href: 'tables.html')).to exist
|
20
16
|
expect(browser.area(href: /tables/)).to exist
|
21
17
|
|
22
18
|
expect(browser.area(index: 0)).to exist
|
@@ -14,9 +14,7 @@ describe 'Button' do
|
|
14
14
|
expect(browser.button(name: /new_user_reset/)).to exist
|
15
15
|
expect(browser.button(value: 'Button')).to exist
|
16
16
|
expect(browser.button(value: /Button/)).to exist
|
17
|
-
|
18
|
-
expect(browser.button(src: 'images/button.png')).to exist
|
19
|
-
end
|
17
|
+
expect(browser.button(src: 'images/button.png')).to exist
|
20
18
|
expect(browser.button(src: /button\.png/)).to exist
|
21
19
|
expect(browser.button(text: 'Button 2')).to exist
|
22
20
|
expect(browser.button(text: /Button 2/)).to exist
|
@@ -41,16 +39,6 @@ describe 'Button' do
|
|
41
39
|
expect(browser.button(value: /Button 4 With Child Text/)).to exist
|
42
40
|
end
|
43
41
|
|
44
|
-
it 'returns true if the button exists (how = :caption)' do
|
45
|
-
expect {
|
46
|
-
expect(browser.button(caption: 'Button 2')).to exist
|
47
|
-
}.to have_deprecated_caption
|
48
|
-
|
49
|
-
expect {
|
50
|
-
expect(browser.button(caption: /Button 2/)).to exist
|
51
|
-
}.to have_deprecated_caption
|
52
|
-
end
|
53
|
-
|
54
42
|
it 'returns the first button if given no args' do
|
55
43
|
expect(browser.button).to exist
|
56
44
|
end
|
@@ -137,10 +125,8 @@ describe 'Button' do
|
|
137
125
|
end
|
138
126
|
|
139
127
|
describe '#style' do
|
140
|
-
|
141
|
-
|
142
|
-
expect(browser.button(id: 'delete_user_submit').style).to eq 'border: 4px solid red;'
|
143
|
-
end
|
128
|
+
it 'returns the style attribute if the button exists' do
|
129
|
+
expect(browser.button(id: 'delete_user_submit').style).to include 'border: 4px solid red;'
|
144
130
|
end
|
145
131
|
|
146
132
|
it "returns an empty string if the element exists and the attribute doesn't exist" do
|
@@ -254,7 +240,7 @@ describe 'Button' do
|
|
254
240
|
it 'clicks the button if it exists' do
|
255
241
|
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
256
242
|
browser.button(id: 'delete_user_submit').click
|
257
|
-
|
243
|
+
browser.wait_while(url: /forms_with_input_elements\.html$/)
|
258
244
|
expect(browser.text).to include('Semantic table')
|
259
245
|
end
|
260
246
|
|
@@ -26,30 +26,16 @@ describe 'CheckBox' do
|
|
26
26
|
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_books']")).to exist
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
expect {
|
40
|
-
expect(browser.checkbox(label: /this will not match/)).to exist
|
41
|
-
}.to_not have_deprecated_text_regexp
|
42
|
-
end
|
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
|
47
|
-
|
48
|
-
expect {
|
49
|
-
expect(browser.checkbox(label: /some visible$/)).to exist
|
50
|
-
}.to have_deprecated_text_regexp
|
51
|
-
end
|
52
|
-
end
|
29
|
+
# TODO: More of this for text & labels somewhere central
|
30
|
+
it 'handles text_regexp deprecations for label locators' do
|
31
|
+
expect(browser.checkbox(label: /some visible/)).to exist
|
32
|
+
expect(browser.checkbox(label: /some (visible|Jeff)/)).to exist
|
33
|
+
expect(browser.checkbox(label: /none visible/)).to exist
|
34
|
+
expect(browser.checkbox(label: /this will not match/)).to_not exist
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'handles text_regexp deprecation in spite of hidden text' do
|
38
|
+
expect(browser.checkbox(label: /some visible some hidden/)).to exist
|
53
39
|
end
|
54
40
|
|
55
41
|
it 'returns true if the checkbox button exists (search by name and value)' do
|
@@ -19,20 +19,18 @@ describe 'DateField' do
|
|
19
19
|
expect(browser.date_field(label: /Date$/)).to exist
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
22
|
+
it 'returns true when using xpath',
|
23
|
+
except: {browser: %i[ie safari], reason: 'Date type not recognized'} do
|
24
|
+
expect(browser.date_field(xpath: "//input[@id='html5_date']")).to exist
|
26
25
|
end
|
27
26
|
|
28
27
|
it 'returns the date field if given no args' do
|
29
28
|
expect(browser.date_field).to exist
|
30
29
|
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
31
|
+
it 'respects date fields types',
|
32
|
+
except: {browser: %i[ie safari], reason: 'Date type not recognized'} do
|
33
|
+
expect(browser.date_field.type).to eq('date')
|
36
34
|
end
|
37
35
|
|
38
36
|
it 'returns false if the element does not exist' do
|
@@ -78,15 +76,14 @@ describe 'DateField' do
|
|
78
76
|
end
|
79
77
|
end
|
80
78
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
describe '#type' do
|
80
|
+
it 'returns the type attribute if the date field exists',
|
81
|
+
except: {browser: %i[ie safari], reason: 'Date type not recognized'} do
|
82
|
+
expect(browser.date_field(id: 'html5_date').type).to eq 'date'
|
83
|
+
end
|
86
84
|
|
87
|
-
|
88
|
-
|
89
|
-
end
|
85
|
+
it "raises UnknownObjectException if the date field doesn't exist" do
|
86
|
+
expect { browser.date_field(index: 1337).type }.to raise_unknown_object_exception
|
90
87
|
end
|
91
88
|
end
|
92
89
|
|
@@ -15,23 +15,24 @@ describe 'DateTimeField' do
|
|
15
15
|
expect(browser.date_time_field(text: '')).to exist
|
16
16
|
expect(browser.date_time_field(text: //)).to exist
|
17
17
|
expect(browser.date_time_field(index: 0)).to exist
|
18
|
-
|
19
|
-
bug 'https://github.com/mozilla/geckodriver/issues/1469', :firefox, :safari do
|
20
|
-
expect(browser.date_time_field(xpath: "//input[@id='html5_datetime-local']")).to exist
|
21
|
-
end
|
22
|
-
|
23
18
|
expect(browser.date_time_field(label: 'HTML5 Datetime Local')).to exist
|
24
19
|
expect(browser.date_time_field(label: /Local$/)).to exist
|
25
20
|
end
|
26
21
|
|
22
|
+
it 'returns true if the datetime-local element exists',
|
23
|
+
except: [{browser: :firefox, reason: 'https://github.com/mozilla/geckodriver/issues/1469'},
|
24
|
+
{browser: %i[ie safari], reason: 'Date type not recognized'}] do
|
25
|
+
expect(browser.date_time_field(xpath: "//input[@id='html5_datetime-local']")).to exist
|
26
|
+
end
|
27
|
+
|
27
28
|
it 'returns the date-time field if given no args' do
|
28
29
|
expect(browser.date_time_field).to exist
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
it 'respects date-time fields types',
|
33
|
+
except: [{browser: :firefox, reason: 'https://github.com/mozilla/geckodriver/issues/1469'},
|
34
|
+
{browser: %i[ie safari], reason: 'Date type not recognized'}] do
|
35
|
+
expect(browser.date_time_field.type).to eq('datetime-local')
|
35
36
|
end
|
36
37
|
|
37
38
|
it 'returns false if the element does not exist' do
|
@@ -78,10 +79,10 @@ describe 'DateTimeField' do
|
|
78
79
|
end
|
79
80
|
|
80
81
|
describe '#type' do
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
it 'returns the type attribute if the date-time field exists',
|
83
|
+
except: [{browser: :firefox, reason: 'https://github.com/mozilla/geckodriver/issues/1469'},
|
84
|
+
{browser: %i[ie safari], reason: 'Date type not recognized'}] do
|
85
|
+
expect(browser.date_time_field(id: 'html5_datetime-local').type).to eq 'datetime-local'
|
85
86
|
end
|
86
87
|
|
87
88
|
it "raises UnknownObjectException if the date-time field doesn't exist" do
|
@@ -55,10 +55,9 @@ describe 'Dd' do
|
|
55
55
|
expect(browser.dd(id: 'someone').text).to eq 'John Doe'
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
58
|
+
it 'returns an empty string if the element exists but contains no text',
|
59
|
+
except: {browser: :safari, reason: 'Safari does not strip text'} do
|
60
|
+
expect(browser.dd(class: 'noop').text).to eq ''
|
62
61
|
end
|
63
62
|
|
64
63
|
it 'raises UnknownObjectException if the element does not exist' do
|
@@ -94,18 +94,16 @@ describe 'Del' do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
# Other
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
expect { browser.del(title: 'no_such_title').click }.to raise_unknown_object_exception
|
108
|
-
end
|
97
|
+
describe '#click', except: {headless: true} do
|
98
|
+
it 'fires events' do
|
99
|
+
expect(browser.del(class: 'footer').text).to_not include('Javascript')
|
100
|
+
browser.del(class: 'footer').click
|
101
|
+
expect(browser.del(class: 'footer').text).to include('Javascript')
|
102
|
+
end
|
103
|
+
|
104
|
+
it "raises UnknownObjectException if the del doesn't exist" do
|
105
|
+
expect { browser.del(id: 'no_such_id').click }.to raise_unknown_object_exception
|
106
|
+
expect { browser.del(title: 'no_such_title').click }.to raise_unknown_object_exception
|
109
107
|
end
|
110
108
|
end
|
111
109
|
end
|
@@ -19,6 +19,9 @@ describe 'Div' do
|
|
19
19
|
expect(browser.div(xpath: "//div[@id='header']")).to exist
|
20
20
|
expect(browser.div(custom_attribute: 'custom')).to exist
|
21
21
|
expect(browser.div(custom_attribute: /custom/)).to exist
|
22
|
+
expect(browser.div(text: /some visible/)).to exist
|
23
|
+
expect(browser.div(text: /some (visible|Jeff)/)).to exist
|
24
|
+
expect(browser.div(text: /none visible/)).to exist
|
22
25
|
end
|
23
26
|
|
24
27
|
it 'returns the first div if given no args' do
|
@@ -34,6 +37,7 @@ describe 'Div' do
|
|
34
37
|
expect(browser.div(text: /no_such_text/)).to_not exist
|
35
38
|
expect(browser.div(class: 'no_such_class')).to_not exist
|
36
39
|
expect(browser.div(class: /no_such_class/)).to_not exist
|
40
|
+
expect(browser.div(text: /some visible some hidden/)).to exist
|
37
41
|
expect(browser.div(index: 1337)).to_not exist
|
38
42
|
expect(browser.div(xpath: "//div[@id='no_such_id']")).to_not exist
|
39
43
|
end
|
@@ -71,10 +75,8 @@ describe 'Div' do
|
|
71
75
|
end
|
72
76
|
|
73
77
|
describe '#style' do
|
74
|
-
|
75
|
-
|
76
|
-
expect(browser.div(id: 'best_language').style).to eq 'color: red; text-decoration: underline; cursor: pointer;'
|
77
|
-
end
|
78
|
+
it 'returns the style attribute if the element exists' do
|
79
|
+
expect(browser.div(id: 'best_language').style).to eq 'color: red; text-decoration: underline; cursor: pointer;'
|
78
80
|
end
|
79
81
|
|
80
82
|
it "returns an empty string if the element exists but the attribute doesn't" do
|
@@ -97,10 +99,9 @@ describe 'Div' do
|
|
97
99
|
expect(browser.div(index: 0).text.strip).to eq ''
|
98
100
|
end
|
99
101
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
102
|
+
it 'returns an empty string if the div is hidden',
|
103
|
+
except: {browser: :safari, reason: 'Safari is not filtering out hidden text'} do
|
104
|
+
expect(browser.div(id: 'hidden').text).to eq ''
|
104
105
|
end
|
105
106
|
|
106
107
|
it 'raises UnknownObjectException if the element does not exist' do
|
@@ -126,40 +127,6 @@ describe 'Div' do
|
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
129
|
-
describe 'Deprecation Warnings' do
|
130
|
-
describe 'text locator with RegExp values' do
|
131
|
-
it 'does not throw deprecation when still matched by text content' do
|
132
|
-
expect { browser.div(text: /some visible/).locate }.not_to have_deprecated_text_regexp
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'does not throw deprecation with complex regexp matched by text content' do
|
136
|
-
expect { browser.div(text: /some (in|)visible/).locate }.not_to have_deprecated_text_regexp
|
137
|
-
end
|
138
|
-
|
139
|
-
not_compliant_on :watigiri do
|
140
|
-
bug 'Safari is not filtering out hidden text', :safari do
|
141
|
-
it 'throws deprecation when no longer matched by text content' do
|
142
|
-
expect { browser.div(text: /some visible$/).locate }.to have_deprecated_text_regexp
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
not_compliant_on :watigiri do
|
148
|
-
it 'does not throw deprecation when element does not exist' do
|
149
|
-
expect { browser.div(text: /definitely not there/).locate }.not_to have_deprecated_text_regexp
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
not_compliant_on :watigiri do
|
154
|
-
bug 'Safari is not filtering out hidden text', :safari do
|
155
|
-
it 'does not locate entire content with regular expressions' do
|
156
|
-
expect(browser.div(text: /some visible some hidden/)).to_not exist
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
130
|
# Manipulation methods
|
164
131
|
describe '#click' do
|
165
132
|
it 'fires events when clicked' do
|
@@ -199,57 +166,51 @@ describe 'Div' do
|
|
199
166
|
end
|
200
167
|
end
|
201
168
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
end
|
169
|
+
describe '#double_click',
|
170
|
+
except: {browser: :safari, reason: 'command correctly received, but action not taken'} do
|
171
|
+
it 'fires the ondblclick event' do
|
172
|
+
div = browser.div(id: 'html_test')
|
173
|
+
div.scroll.to
|
174
|
+
div.double_click
|
175
|
+
expect(messages).to include('double clicked')
|
210
176
|
end
|
177
|
+
end
|
211
178
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
179
|
+
describe '#double_click!' do
|
180
|
+
it 'fires the ondblclick event' do
|
181
|
+
browser.div(id: 'html_test').double_click!
|
182
|
+
expect(messages).to include('double clicked')
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#right_click' do
|
187
|
+
it 'fires the oncontextmenu event' do
|
188
|
+
browser.goto(WatirSpec.url_for('right_click.html'))
|
189
|
+
browser.div(id: 'click').right_click
|
190
|
+
expect(messages.first).to eq 'right-clicked'
|
217
191
|
end
|
218
192
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
end
|
193
|
+
it 'accepts modifiers', except: {browser: :ie} do
|
194
|
+
browser.goto(WatirSpec.url_for('right_click.html'))
|
195
|
+
browser.div(id: 'click-logger').right_click(:control, :alt)
|
196
|
+
expect(event_log.first).to eq('control=true alt=true')
|
197
|
+
end
|
225
198
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
expect(event_log.first).to eq('control=true alt=true')
|
230
|
-
end
|
199
|
+
it 'scrolls' do
|
200
|
+
browser.del(class: 'footer').double_click
|
201
|
+
puts 'yes?'
|
231
202
|
end
|
232
203
|
end
|
233
204
|
|
234
205
|
describe '#html' do
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
expect(html).to_not include('</body>')
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
deviates_on :internet_explorer do
|
248
|
-
it 'returns the HTML of the element' do
|
249
|
-
html = browser.div(id: 'footer').html.downcase
|
250
|
-
expect(html).to include('title="closing remarks"')
|
251
|
-
expect(html).to_not include('</body>')
|
252
|
-
end
|
206
|
+
it 'returns the HTML of the element' do
|
207
|
+
html = browser.div(id: 'footer').html.downcase
|
208
|
+
expect(html).to include('id="footer"')
|
209
|
+
expect(html).to include('title="closing remarks"')
|
210
|
+
expect(html).to include('class="profile"')
|
211
|
+
|
212
|
+
expect(html).to_not include('<div id="content">')
|
213
|
+
expect(html).to_not include('</body>')
|
253
214
|
end
|
254
215
|
end
|
255
216
|
end
|