watir 7.2.0 → 7.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/chrome.yml +1 -1
- data/.github/workflows/edge.yml +1 -1
- data/.github/workflows/firefox.yml +1 -1
- data/.github/workflows/ie.yml +1 -1
- data/.github/workflows/safari.yml +1 -1
- data/.github/workflows/unit.yml +1 -1
- data/.rubocop.yml +25 -12
- data/.rubocop_todo.yml +8 -1
- data/CHANGES.md +6 -1
- data/LICENSE +2 -2
- data/lib/watir/capabilities.rb +1 -1
- data/lib/watir/locators/anchor/selector_builder.rb +3 -0
- data/lib/watir/locators/element/matcher.rb +2 -1
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +2 -1
- data/lib/watir/locators/text_field/matcher.rb +0 -4
- data/lib/watir/version.rb +1 -1
- data/spec/locator_spec_helper.rb +0 -8
- data/spec/unit/capabilities_spec.rb +553 -561
- data/spec/unit/element_locator_spec.rb +89 -78
- data/spec/unit/match_elements/button_spec.rb +69 -62
- data/spec/unit/match_elements/element_spec.rb +303 -309
- data/spec/unit/match_elements/text_field_spec.rb +76 -73
- data/spec/unit/selector_builder/anchor_spec.rb +39 -33
- data/spec/unit/selector_builder/button_spec.rb +209 -202
- data/spec/unit/selector_builder/cell_spec.rb +48 -42
- data/spec/unit/selector_builder/element_spec.rb +634 -627
- data/spec/unit/selector_builder/row_spec.rb +119 -113
- data/spec/unit/selector_builder/text_field_spec.rb +195 -188
- data/spec/unit/selector_builder/textarea_spec.rb +22 -14
- data/spec/unit/wait_spec.rb +85 -81
- data/spec/watirspec/adjacent_spec.rb +249 -247
- data/spec/watirspec/after_hooks_spec.rb +161 -159
- data/spec/watirspec/alert_spec.rb +61 -58
- data/spec/watirspec/browser_spec.rb +409 -409
- data/spec/watirspec/capabilities_spec.rb +89 -99
- data/spec/watirspec/cookies_spec.rb +120 -118
- data/spec/watirspec/drag_and_drop_spec.rb +26 -24
- data/spec/watirspec/element_hidden_spec.rb +66 -60
- data/spec/watirspec/elements/area_spec.rb +49 -47
- data/spec/watirspec/elements/areas_spec.rb +27 -25
- data/spec/watirspec/elements/button_spec.rb +253 -251
- data/spec/watirspec/elements/buttons_spec.rb +36 -34
- data/spec/watirspec/elements/checkbox_spec.rb +48 -36
- data/spec/watirspec/elements/checkboxes_spec.rb +29 -27
- data/spec/watirspec/elements/collections_spec.rb +126 -119
- data/spec/watirspec/elements/date_field_spec.rb +185 -183
- data/spec/watirspec/elements/date_fields_spec.rb +29 -27
- data/spec/watirspec/elements/date_time_field_spec.rb +197 -195
- data/spec/watirspec/elements/date_time_fields_spec.rb +30 -28
- data/spec/watirspec/elements/dd_spec.rb +87 -85
- data/spec/watirspec/elements/dds_spec.rb +27 -25
- data/spec/watirspec/elements/del_spec.rb +106 -104
- data/spec/watirspec/elements/dels_spec.rb +26 -24
- data/spec/watirspec/elements/div_spec.rb +225 -221
- data/spec/watirspec/elements/divs_spec.rb +37 -35
- data/spec/watirspec/elements/dl_spec.rb +110 -108
- data/spec/watirspec/elements/dls_spec.rb +28 -26
- data/spec/watirspec/elements/dt_spec.rb +86 -84
- data/spec/watirspec/elements/dts_spec.rb +27 -25
- data/spec/watirspec/elements/element_spec.rb +794 -775
- data/spec/watirspec/elements/elements_spec.rb +40 -38
- data/spec/watirspec/elements/em_spec.rb +62 -60
- data/spec/watirspec/elements/ems_spec.rb +28 -26
- data/spec/watirspec/elements/filefield_spec.rb +116 -114
- data/spec/watirspec/elements/filefields_spec.rb +28 -26
- data/spec/watirspec/elements/font_spec.rb +20 -18
- data/spec/watirspec/elements/form_spec.rb +51 -49
- data/spec/watirspec/elements/forms_spec.rb +29 -27
- data/spec/watirspec/elements/frame_spec.rb +89 -87
- data/spec/watirspec/elements/frames_spec.rb +27 -25
- data/spec/watirspec/elements/hidden_spec.rb +81 -79
- data/spec/watirspec/elements/hiddens_spec.rb +28 -26
- data/spec/watirspec/elements/hn_spec.rb +59 -57
- data/spec/watirspec/elements/hns_spec.rb +26 -24
- data/spec/watirspec/elements/iframe_spec.rb +195 -191
- data/spec/watirspec/elements/iframes_spec.rb +31 -29
- data/spec/watirspec/elements/image_spec.rb +148 -146
- data/spec/watirspec/elements/images_spec.rb +26 -24
- data/spec/watirspec/elements/input_spec.rb +9 -7
- data/spec/watirspec/elements/ins_spec.rb +106 -104
- data/spec/watirspec/elements/inses_spec.rb +26 -24
- data/spec/watirspec/elements/label_spec.rb +56 -54
- data/spec/watirspec/elements/labels_spec.rb +26 -24
- data/spec/watirspec/elements/li_spec.rb +76 -74
- data/spec/watirspec/elements/link_spec.rb +173 -177
- data/spec/watirspec/elements/links_spec.rb +45 -43
- data/spec/watirspec/elements/lis_spec.rb +27 -25
- data/spec/watirspec/elements/list_spec.rb +44 -42
- data/spec/watirspec/elements/map_spec.rb +57 -55
- data/spec/watirspec/elements/maps_spec.rb +27 -25
- data/spec/watirspec/elements/meta_spec.rb +16 -14
- data/spec/watirspec/elements/metas_spec.rb +26 -24
- data/spec/watirspec/elements/ol_spec.rb +56 -65
- data/spec/watirspec/elements/ols_spec.rb +26 -24
- data/spec/watirspec/elements/option_spec.rb +91 -89
- data/spec/watirspec/elements/p_spec.rb +81 -79
- data/spec/watirspec/elements/pre_spec.rb +77 -75
- data/spec/watirspec/elements/pres_spec.rb +26 -24
- data/spec/watirspec/elements/ps_spec.rb +26 -24
- data/spec/watirspec/elements/radio_spec.rb +251 -249
- data/spec/watirspec/elements/radios_spec.rb +28 -26
- data/spec/watirspec/elements/select_list_spec.rb +537 -526
- data/spec/watirspec/elements/select_lists_spec.rb +32 -30
- data/spec/watirspec/elements/span_spec.rb +112 -110
- data/spec/watirspec/elements/spans_spec.rb +26 -24
- data/spec/watirspec/elements/strong_spec.rb +58 -58
- data/spec/watirspec/elements/strongs_spec.rb +28 -26
- data/spec/watirspec/elements/table_spec.rb +192 -139
- data/spec/watirspec/elements/tables_spec.rb +28 -26
- data/spec/watirspec/elements/tbody_spec.rb +74 -72
- data/spec/watirspec/elements/tbodys_spec.rb +40 -38
- data/spec/watirspec/elements/td_spec.rb +66 -64
- data/spec/watirspec/elements/tds_spec.rb +41 -39
- data/spec/watirspec/elements/text_field_spec.rb +206 -204
- data/spec/watirspec/elements/text_fields_spec.rb +30 -28
- data/spec/watirspec/elements/textarea_spec.rb +20 -18
- data/spec/watirspec/elements/textareas_spec.rb +18 -16
- data/spec/watirspec/elements/tfoot_spec.rb +65 -63
- data/spec/watirspec/elements/tfoots_spec.rb +42 -40
- data/spec/watirspec/elements/thead_spec.rb +65 -63
- data/spec/watirspec/elements/theads_spec.rb +42 -40
- data/spec/watirspec/elements/tr_spec.rb +48 -46
- data/spec/watirspec/elements/trs_spec.rb +42 -40
- data/spec/watirspec/elements/ul_spec.rb +56 -54
- data/spec/watirspec/elements/uls_spec.rb +26 -24
- data/spec/watirspec/radio_set_spec.rb +269 -267
- data/spec/watirspec/screenshot_spec.rb +20 -18
- data/spec/watirspec/scroll_spec.rb +152 -148
- data/spec/watirspec/shadow_root_spec.rb +86 -83
- data/spec/watirspec/user_editable_spec.rb +200 -198
- data/spec/watirspec/wait_spec.rb +289 -295
- data/spec/watirspec/window_switching_spec.rb +422 -434
- data/spec/watirspec_helper.rb +1 -23
- data/watir.gemspec +5 -4
- metadata +44 -33
- data/spec/watirspec/attributes_spec.rb +0 -18
- data/spec/watirspec/elements/table_nesting_spec.rb +0 -51
- data/spec/watirspec/special_chars_spec.rb +0 -23
@@ -2,343 +2,345 @@
|
|
2
2
|
|
3
3
|
require 'watirspec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
it 'returns false if no radio button exists' do
|
26
|
-
expect(browser.radio_set(id: 'no_such_id')).to_not exist
|
27
|
-
expect(browser.radio_set(id: /no_such_id/)).to_not exist
|
28
|
-
expect(browser.radio_set(name: 'no_such_name')).to_not exist
|
29
|
-
expect(browser.radio_set(name: /no_such_name/)).to_not exist
|
30
|
-
expect(browser.radio_set(value: 'no_such_value')).to_not exist
|
31
|
-
expect(browser.radio_set(value: /no_such_value/)).to_not exist
|
32
|
-
expect(browser.radio_set(text: 'no_such_text')).to_not exist
|
33
|
-
expect(browser.radio_set(text: /no_such_text/)).to_not exist
|
34
|
-
expect(browser.radio_set(class: 'no_such_class')).to_not exist
|
35
|
-
expect(browser.radio_set(class: /no_such_class/)).to_not exist
|
36
|
-
expect(browser.radio_set(index: 1337)).to_not exist
|
37
|
-
expect(browser.radio_set(xpath: "input[@id='no_such_id']")).to_not exist
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'returns the first radio set if given no args' do
|
41
|
-
expect(browser.radio_set).to exist
|
42
|
-
end
|
43
|
-
|
44
|
-
it "raises TypeError when 'what' argument is invalid" do
|
45
|
-
expect { browser.radio_set(id: 3.14).exists? }.to raise_error(TypeError)
|
46
|
-
end
|
47
|
-
end
|
5
|
+
module Watir
|
6
|
+
describe RadioSet do
|
7
|
+
before do
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
9
|
+
end
|
10
|
+
|
11
|
+
# Exists method
|
12
|
+
describe '#exists?' do
|
13
|
+
it 'returns true if matches any radio_set button' do
|
14
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes')).to exist
|
15
|
+
expect(browser.radio_set(id: /new_user_newsletter_yes/)).to exist
|
16
|
+
expect(browser.radio_set(name: 'new_user_newsletter')).to exist
|
17
|
+
expect(browser.radio_set(name: /new_user_newsletter/)).to exist
|
18
|
+
expect(browser.radio_set(value: 'yes')).to exist
|
19
|
+
expect(browser.radio_set(value: /yes/)).to exist
|
20
|
+
expect(browser.radio_set(class: 'huge')).to exist
|
21
|
+
expect(browser.radio_set(class: /huge/)).to exist
|
22
|
+
expect(browser.radio_set(index: 0)).to exist
|
23
|
+
expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_yes']")).to exist
|
24
|
+
end
|
48
25
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
26
|
+
it 'returns false if no radio button exists' do
|
27
|
+
expect(browser.radio_set(id: 'no_such_id')).not_to exist
|
28
|
+
expect(browser.radio_set(id: /no_such_id/)).not_to exist
|
29
|
+
expect(browser.radio_set(name: 'no_such_name')).not_to exist
|
30
|
+
expect(browser.radio_set(name: /no_such_name/)).not_to exist
|
31
|
+
expect(browser.radio_set(value: 'no_such_value')).not_to exist
|
32
|
+
expect(browser.radio_set(value: /no_such_value/)).not_to exist
|
33
|
+
expect(browser.radio_set(text: 'no_such_text')).not_to exist
|
34
|
+
expect(browser.radio_set(text: /no_such_text/)).not_to exist
|
35
|
+
expect(browser.radio_set(class: 'no_such_class')).not_to exist
|
36
|
+
expect(browser.radio_set(class: /no_such_class/)).not_to exist
|
37
|
+
expect(browser.radio_set(index: 1337)).not_to exist
|
38
|
+
expect(browser.radio_set(xpath: "input[@id='no_such_id']")).not_to exist
|
39
|
+
end
|
54
40
|
|
55
|
-
|
56
|
-
|
57
|
-
|
41
|
+
it 'returns the first radio set if given no args' do
|
42
|
+
expect(browser.radio_set).to exist
|
43
|
+
end
|
58
44
|
|
59
|
-
|
60
|
-
|
45
|
+
it "raises TypeError when 'what' argument is invalid" do
|
46
|
+
expect { browser.radio_set(id: 3.14).exists? }.to raise_error(TypeError)
|
47
|
+
end
|
61
48
|
end
|
62
|
-
end
|
63
49
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
50
|
+
# Attribute methods
|
51
|
+
describe '#name' do
|
52
|
+
it 'returns the name attribute if the radio exists' do
|
53
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes').name).to eq 'new_user_newsletter'
|
54
|
+
end
|
71
55
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
56
|
+
it 'returns an empty string if the radio exists and there is not name' do
|
57
|
+
expect(browser.radio_set(id: 'new_user_newsletter_absolutely').name).to eq ''
|
58
|
+
end
|
76
59
|
|
77
|
-
|
78
|
-
|
60
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
61
|
+
expect { browser.radio_set(index: 1337).name }.to raise_unknown_object_exception
|
62
|
+
end
|
79
63
|
end
|
80
|
-
end
|
81
64
|
|
82
|
-
|
83
|
-
|
84
|
-
|
65
|
+
context 'without name specified' do
|
66
|
+
it 'Finds specified radio' do
|
67
|
+
expect(browser.radio_set(id: 'new_user_newsletter_absolutely').count).to eq 1
|
68
|
+
expect(browser.radio_set(id: 'new_user_newsletter_absolutely').radios.size).to eq 1
|
69
|
+
expect(browser.radio_set(id: 'new_user_newsletter_absolutely').radio(value: 'absolutely').exist?).to be true
|
70
|
+
end
|
85
71
|
end
|
86
72
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
73
|
+
describe '#type' do
|
74
|
+
it 'returns the type attribute if the radio set exists' do
|
75
|
+
expect(browser.radio_set.type).to eq 'radio'
|
76
|
+
end
|
91
77
|
|
92
|
-
|
93
|
-
|
94
|
-
|
78
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
79
|
+
expect { browser.radio_set(index: 1337).type }.to raise_unknown_object_exception
|
80
|
+
end
|
95
81
|
end
|
96
82
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
83
|
+
describe '#value' do
|
84
|
+
it 'returns the value attributes of the selected radio button' do
|
85
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes').value).to eq 'yes'
|
86
|
+
end
|
101
87
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
expect(browser.radio_set(index: 0)).to_not respond_to(:id)
|
106
|
-
expect(browser.radio_set(index: 0)).to respond_to(:name)
|
107
|
-
expect(browser.radio_set(index: 0)).to_not respond_to(:title)
|
108
|
-
expect(browser.radio_set(index: 0)).to respond_to(:type)
|
109
|
-
expect(browser.radio_set(index: 0)).to respond_to(:value)
|
110
|
-
expect(browser.radio_set(index: 0)).to respond_to(:text)
|
111
|
-
expect(browser.radio_set(index: 0)).to_not respond_to(:clear)
|
88
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
89
|
+
expect { browser.radio_set(index: 1337).value }.to raise_unknown_object_exception
|
90
|
+
end
|
112
91
|
end
|
113
|
-
end
|
114
92
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_nah']")).to be_enabled
|
120
|
-
end
|
93
|
+
describe '#text' do
|
94
|
+
it 'returns the text of the selected radio button' do
|
95
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes').text).to eq 'Yes'
|
96
|
+
end
|
121
97
|
|
122
|
-
|
123
|
-
|
124
|
-
|
98
|
+
it "raises UnknownObjectException if the radio set doesn't exist" do
|
99
|
+
expect { browser.radio_set(index: 1337).text }.to raise_unknown_object_exception
|
100
|
+
end
|
125
101
|
end
|
126
102
|
|
127
|
-
|
128
|
-
|
129
|
-
|
103
|
+
describe '#respond_to?' do
|
104
|
+
it 'returns true for all attribute methods' do
|
105
|
+
expect(browser.radio_set(index: 0)).not_to respond_to(:class_name)
|
106
|
+
expect(browser.radio_set(index: 0)).not_to respond_to(:id)
|
107
|
+
expect(browser.radio_set(index: 0)).to respond_to(:name)
|
108
|
+
expect(browser.radio_set(index: 0)).not_to respond_to(:title)
|
109
|
+
expect(browser.radio_set(index: 0)).to respond_to(:type)
|
110
|
+
expect(browser.radio_set(index: 0)).to respond_to(:value)
|
111
|
+
expect(browser.radio_set(index: 0)).to respond_to(:text)
|
112
|
+
expect(browser.radio_set(index: 0)).not_to respond_to(:clear)
|
113
|
+
end
|
130
114
|
end
|
131
|
-
end
|
132
115
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
116
|
+
# Access methods
|
117
|
+
describe '#enabled?' do
|
118
|
+
it 'returns true if any radio button in the set is enabled' do
|
119
|
+
expect(browser.radio_set(id: 'new_user_newsletter_nah')).to be_enabled
|
120
|
+
expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_nah']")).to be_enabled
|
121
|
+
end
|
138
122
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
123
|
+
it 'returns false if all radio buttons are disabled' do
|
124
|
+
expect(browser.radio_set(id: 'new_user_newsletter_none')).not_to be_enabled
|
125
|
+
expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_none']")).not_to be_enabled
|
126
|
+
end
|
143
127
|
|
144
|
-
|
145
|
-
|
128
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
129
|
+
expect { browser.radio_set(id: 'no_such_id').enabled? }.to raise_unknown_object_exception
|
130
|
+
expect { browser.radio_set(xpath: "//input[@id='no_such_id']").enabled? }.to raise_unknown_object_exception
|
131
|
+
end
|
146
132
|
end
|
147
|
-
end
|
148
133
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
expect(radio.value).to eq 'yes'
|
155
|
-
end
|
134
|
+
describe '#disabled?' do
|
135
|
+
it 'returns false if the any radio button in the set is enabled' do
|
136
|
+
expect(browser.radio_set(id: 'new_user_newsletter_nah')).not_to be_disabled
|
137
|
+
expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_nah']")).not_to be_disabled
|
138
|
+
end
|
156
139
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
end
|
140
|
+
it 'returns true if all radio buttons are disabled' do
|
141
|
+
expect(browser.radio_set(id: 'new_user_newsletter_none')).to be_disabled
|
142
|
+
expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_none']")).to be_disabled
|
143
|
+
end
|
162
144
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
expect(radio.value).to eq 'no'
|
145
|
+
it 'raises UnknownObjectException when the radio set does not exist' do
|
146
|
+
expect { browser.radio_set(index: 1337).disabled? }.to raise_unknown_object_exception
|
147
|
+
end
|
167
148
|
end
|
168
149
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
150
|
+
# Other
|
151
|
+
describe '#radio' do
|
152
|
+
it 'returns first instance of Radio if no arguments specified' do
|
153
|
+
radio = browser.radio_set(id: 'new_user_newsletter_yes').radio
|
154
|
+
expect(radio).to be_instance_of(Watir::Radio)
|
155
|
+
expect(radio.value).to eq 'yes'
|
156
|
+
end
|
173
157
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
end
|
158
|
+
it 'returns provided instance of Radio if element has no name' do
|
159
|
+
radio = browser.radio_set(id: 'new_user_newsletter_absolutely').radio
|
160
|
+
expect(radio).to be_instance_of(Watir::Radio)
|
161
|
+
expect(radio.value).to eq 'absolutely'
|
162
|
+
end
|
180
163
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
expect(radios.map(&:value)).to match_array values
|
187
|
-
end
|
164
|
+
it 'returns an instance of Radio matching the provided value' do
|
165
|
+
radio = browser.radio_set(id: 'new_user_newsletter_yes').radio(id: 'new_user_newsletter_no')
|
166
|
+
expect(radio).to be_instance_of(Watir::Radio)
|
167
|
+
expect(radio.value).to eq 'no'
|
168
|
+
end
|
188
169
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
end
|
170
|
+
it 'does not exist when using bad locator' do
|
171
|
+
radio = browser.radio_set(id: 'new_user_newsletter_yes').radio(id: 'new_user_newsletter_not_there')
|
172
|
+
expect(radio).not_to exist
|
173
|
+
end
|
194
174
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
175
|
+
it 'raises Unknown Object Exception if it specifies the wrong name' do
|
176
|
+
radio_set = browser.radio_set(id: 'new_user_newsletter_yes')
|
177
|
+
expect { radio_set.radio(name: '') }.to raise_unknown_object_exception
|
178
|
+
expect { radio_set.radio(name: 'foo') }.to raise_unknown_object_exception
|
179
|
+
end
|
200
180
|
end
|
201
181
|
|
202
|
-
|
203
|
-
radios
|
204
|
-
|
205
|
-
|
182
|
+
describe '#radios' do
|
183
|
+
it 'returns array of all radios in the set if no arguments specified' do
|
184
|
+
radios = browser.radio_set(id: 'new_user_newsletter_yes').radios
|
185
|
+
expect(radios).to be_instance_of(Watir::RadioCollection)
|
186
|
+
values = %w[yes no certainly nah nah]
|
187
|
+
expect(radios.map(&:value)).to match_array values
|
188
|
+
end
|
206
189
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
190
|
+
it 'returns RadioCollection matching the provided value' do
|
191
|
+
radios = browser.radio_set(id: 'new_user_newsletter_yes').radios(id: /new_user_newsletter_n/)
|
192
|
+
expect(radios).to be_instance_of(Watir::RadioCollection)
|
193
|
+
expect(radios.map(&:value)).to eq %w[no nah]
|
194
|
+
end
|
211
195
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
196
|
+
it 'returns provided instance of Radio if element has no name' do
|
197
|
+
radios = browser.radio_set(id: 'new_user_newsletter_absolutely').radios
|
198
|
+
expect(radios).to be_instance_of(Watir::RadioCollection)
|
199
|
+
expect(radios.size).to eq 1
|
200
|
+
expect(radios.first.value).to eq 'absolutely'
|
201
|
+
end
|
217
202
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
203
|
+
it 'returns empty collection if specified radio does not exist' do
|
204
|
+
radios = browser.radio_set(id: 'new_user_newsletter_yes').radios(id: 'new_user_newsletter_not_there')
|
205
|
+
expect(radios).to be_empty
|
206
|
+
end
|
222
207
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
end
|
208
|
+
it 'raises empty collection if it specifies the wrong name' do
|
209
|
+
radio_set = browser.radio_set(id: 'new_user_newsletter_yes')
|
210
|
+
expect { radio_set.radios(name: '') }.to raise_unknown_object_exception
|
211
|
+
end
|
228
212
|
|
229
|
-
|
230
|
-
|
231
|
-
|
213
|
+
it 'returns the radio button at the specified index' do
|
214
|
+
radio_set = browser.radio_set(id: 'new_user_newsletter_yes')
|
215
|
+
expect(radio_set[1]).to be_a Watir::Radio
|
216
|
+
end
|
232
217
|
end
|
233
218
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
219
|
+
describe '#selected' do
|
220
|
+
it "raises UnknownObjectException if the radio set doesn't exist" do
|
221
|
+
expect { browser.radio_set(name: 'no_such_name').selected }.to raise_unknown_object_exception
|
222
|
+
end
|
238
223
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
224
|
+
it 'gets the currently selected radio' do
|
225
|
+
expect(browser.radio_set(id: 'new_user_newsletter_no').selected.text).to eq 'Yes'
|
226
|
+
expect(browser.radio_set(id: 'new_user_newsletter_no').selected.value).to eq 'yes'
|
227
|
+
end
|
243
228
|
end
|
244
229
|
|
245
|
-
|
246
|
-
|
247
|
-
|
230
|
+
describe '#include?' do
|
231
|
+
it 'returns true if the given radio exists by text' do
|
232
|
+
expect(browser.radio_set(id: 'new_user_newsletter_no')).to include('Yes')
|
233
|
+
end
|
248
234
|
|
249
|
-
|
250
|
-
|
251
|
-
|
235
|
+
it "returns false if the given option doesn't exist" do
|
236
|
+
expect(browser.radio_set(id: 'new_user_newsletter_no')).not_to include('Mother')
|
237
|
+
end
|
252
238
|
end
|
253
|
-
end
|
254
239
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
browser.radio_set(id: 'new_user_newsletter_yes').
|
259
|
-
expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'Probably'
|
240
|
+
describe '#selected?' do
|
241
|
+
it 'returns true if the given option is selected by text' do
|
242
|
+
browser.radio_set(id: 'new_user_newsletter_yes').select('No')
|
243
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes')).to be_selected('No')
|
260
244
|
end
|
261
245
|
|
262
|
-
it '
|
263
|
-
browser.radio_set(id: 'new_user_newsletter_yes').
|
264
|
-
expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'Probably'
|
246
|
+
it 'returns false if the given option is not selected by text' do
|
247
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes')).not_to be_selected('Probably')
|
265
248
|
end
|
266
249
|
|
267
|
-
it
|
268
|
-
browser.radio_set(
|
269
|
-
|
250
|
+
it "raises UnknownObjectException if the radio button doesn't exist" do
|
251
|
+
expect { browser.radio_set(id: 'new_user_newsletter_yes').selected?('missing_option') }
|
252
|
+
.to raise_unknown_object_exception
|
270
253
|
end
|
254
|
+
end
|
271
255
|
|
272
|
-
|
273
|
-
|
274
|
-
|
256
|
+
describe '#select' do
|
257
|
+
context 'when interacting with radios' do
|
258
|
+
it 'selects radio text by String' do
|
259
|
+
browser.radio_set(id: 'new_user_newsletter_yes').select('Probably')
|
260
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'Probably'
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'selects radio text by Regexp' do
|
264
|
+
browser.radio_set(id: 'new_user_newsletter_yes').select(/Prob/)
|
265
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'Probably'
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'selects the radio text when given an Xpath' do
|
269
|
+
browser.radio_set(xpath: "//input[@id='new_user_newsletter_no']").select('Probably')
|
270
|
+
expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_no']").selected.text).to eq 'Probably'
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'selects radio value by string' do
|
274
|
+
browser.radio_set(id: 'new_user_newsletter_yes').select('no')
|
275
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'No'
|
276
|
+
end
|
277
|
+
|
278
|
+
it 'selects radio value by regexp' do
|
279
|
+
browser.radio_set(id: 'new_user_newsletter_yes').select(/nah/)
|
280
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'Probably'
|
281
|
+
end
|
275
282
|
end
|
276
283
|
|
277
|
-
it '
|
278
|
-
browser.radio_set(id: 'new_user_newsletter_yes').select(
|
279
|
-
expect(browser.radio_set(id: 'new_user_newsletter_yes').selected.text).to eq 'Probably'
|
284
|
+
it 'returns the value selected' do
|
285
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes').select('no')).to eq 'no'
|
280
286
|
end
|
281
|
-
end
|
282
|
-
|
283
|
-
it 'returns the value selected' do
|
284
|
-
expect(browser.radio_set(id: 'new_user_newsletter_yes').select('no')).to eq 'no'
|
285
|
-
end
|
286
287
|
|
287
|
-
|
288
|
-
|
289
|
-
|
288
|
+
it 'fires onchange event when selecting a radio' do
|
289
|
+
browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'certainly').set
|
290
|
+
expect(messages).to eq ['changed: new_user_newsletter']
|
290
291
|
|
291
|
-
|
292
|
-
|
292
|
+
browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'certainly').set
|
293
|
+
expect(messages).to eq ['changed: new_user_newsletter'] # no event fired here - didn't change
|
293
294
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
295
|
+
browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'yes').set
|
296
|
+
browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'certainly').set
|
297
|
+
list = ['changed: new_user_newsletter', 'clicked: new_user_newsletter_yes', 'changed: new_user_newsletter']
|
298
|
+
expect(messages).to eq list
|
299
|
+
end
|
299
300
|
|
300
|
-
|
301
|
-
|
301
|
+
it "doesn't fire onchange event when selecting an already selected radio" do
|
302
|
+
browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'no').set
|
302
303
|
|
303
|
-
|
304
|
-
|
304
|
+
browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'no').set
|
305
|
+
expect(messages.size).to eq 1
|
305
306
|
|
306
|
-
|
307
|
-
|
307
|
+
browser.radio_set(id: 'new_user_newsletter_yes').radio(value: 'no').set
|
308
|
+
expect(messages.size).to eq 1
|
309
|
+
end
|
308
310
|
end
|
309
|
-
end
|
310
311
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
312
|
+
describe '#eql?' do
|
313
|
+
it 'returns true when located by any radio button' do
|
314
|
+
rs = browser.radio_set(id: 'new_user_newsletter_yes')
|
315
|
+
expect(browser.radio_set(id: /new_user_newsletter_no/)).to eql rs
|
316
|
+
expect(browser.radio_set(name: 'new_user_newsletter', index: 2)).to eql rs
|
317
|
+
expect(browser.radio_set(name: /new_user_newsletter/)).to eql rs
|
318
|
+
expect(browser.radio_set(value: 'yes')).to eql rs
|
319
|
+
expect(browser.radio_set(value: /yes/)).to eql rs
|
320
|
+
expect(browser.radio_set(class: 'huge')).to eql rs
|
321
|
+
expect(browser.radio_set(class: /huge/)).to eql rs
|
322
|
+
expect(browser.radio_set(index: 0)).to eql rs
|
323
|
+
expect(browser.radio_set(xpath: "//input[@id='new_user_newsletter_probably']")).to eql rs
|
324
|
+
end
|
323
325
|
end
|
324
|
-
end
|
325
326
|
|
326
|
-
|
327
|
-
|
328
|
-
|
327
|
+
it 'returns the text of the selected radio' do
|
328
|
+
expect(browser.radio_set(id: 'new_user_newsletter_yes').select('No')).to eq 'No'
|
329
|
+
end
|
329
330
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
331
|
+
it "raises UnknownObjectException if the radio doesn't exist" do
|
332
|
+
expect { browser.radio_set(id: 'new_user_newsletter_yes').select('missing_option') }
|
333
|
+
.to raise_unknown_object_exception
|
334
|
+
expect { browser.radio_set(id: 'new_user_newsletter_yes').select(/missing_option/) }
|
335
|
+
.to raise_unknown_object_exception
|
336
|
+
end
|
336
337
|
|
337
|
-
|
338
|
-
|
339
|
-
|
338
|
+
it 'raises ObjectDisabledException if the option is disabled' do
|
339
|
+
expect { browser.radio_set(id: 'new_user_newsletter_none').select('None') }.to raise_object_disabled_exception
|
340
|
+
end
|
340
341
|
|
341
|
-
|
342
|
-
|
342
|
+
it 'raises a TypeError if argument is not a String, Regexp or Numeric' do
|
343
|
+
expect { browser.radio_set(id: 'new_user_newsletter_yes').select([]) }.to raise_error(TypeError)
|
344
|
+
end
|
343
345
|
end
|
344
346
|
end
|