watir 7.2.0 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -6,235 +6,239 @@ require 'watirspec_helper'
|
|
|
6
6
|
# TODO: fix duplication with frame_spec
|
|
7
7
|
#
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
it 'handles crossframe javascript' do
|
|
15
|
-
browser.goto WatirSpec.url_for('iframes.html')
|
|
16
|
-
|
|
17
|
-
expect(browser.iframe(id: 'iframe_1').text_field(name: 'senderElement').value).to eq 'send_this_value'
|
|
18
|
-
expect(browser.iframe(id: 'iframe_2').text_field(name: 'recieverElement').value).to eq 'old_value'
|
|
19
|
-
browser.iframe(id: 'iframe_1').button(id: 'send').click
|
|
20
|
-
expect(browser.iframe(id: 'iframe_2').text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'locates an element defined by Selenium Element' do
|
|
24
|
-
iframe = browser.iframe(id: 'iframe_1').locate
|
|
25
|
-
se_element = iframe.instance_variable_get(:@element)
|
|
26
|
-
iframe2 = browser.element(element: se_element).to_subtype
|
|
27
|
-
expect(iframe2).to eq iframe
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe '#wd' do
|
|
31
|
-
it 'returns a Watir::FramedDriver instance' do
|
|
32
|
-
iframe = browser.iframe(id: 'iframe_1')
|
|
33
|
-
expect(iframe.wd).to be_a(Watir::FramedDriver)
|
|
9
|
+
module Watir
|
|
10
|
+
describe IFrame do
|
|
11
|
+
before do
|
|
12
|
+
browser.goto(WatirSpec.url_for('iframes.html'))
|
|
34
13
|
end
|
|
35
14
|
|
|
36
|
-
it '
|
|
37
|
-
|
|
38
|
-
expect(iframe.wd.title).to eq 'Iframes'
|
|
39
|
-
end
|
|
15
|
+
it 'handles crossframe javascript' do
|
|
16
|
+
browser.goto WatirSpec.url_for('iframes.html')
|
|
40
17
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
18
|
+
expect(browser.iframe(id: 'iframe_1').text_field(name: 'senderElement').value).to eq 'send_this_value'
|
|
19
|
+
expect(browser.iframe(id: 'iframe_2').text_field(name: 'recieverElement').value).to eq 'old_value'
|
|
20
|
+
browser.iframe(id: 'iframe_1').button(id: 'send').click
|
|
21
|
+
expect(browser.iframe(id: 'iframe_2').text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'locates an element defined by Selenium Element' do
|
|
25
|
+
iframe = browser.iframe(id: 'iframe_1').locate
|
|
26
|
+
se_element = iframe.instance_variable_get(:@element)
|
|
27
|
+
iframe2 = browser.element(element: se_element).to_subtype
|
|
28
|
+
expect(iframe2).to eq iframe
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#wd' do
|
|
32
|
+
it 'returns a Watir::FramedDriver instance' do
|
|
33
|
+
iframe = browser.iframe(id: 'iframe_1')
|
|
34
|
+
expect(iframe.wd).to be_a(Watir::FramedDriver)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'properly delegates driver commands' do
|
|
38
|
+
iframe = browser.iframe(id: 'iframe_1')
|
|
39
|
+
expect(iframe.wd.title).to eq 'Iframes'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'properly delegates element commands' do
|
|
43
|
+
iframe = browser.iframe(id: 'iframe_1')
|
|
44
|
+
expect(iframe.wd.attribute('id')).to eq 'iframe_1'
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe '#exist?' do
|
|
49
|
+
it 'returns true if the iframe exists' do
|
|
50
|
+
expect(browser.iframe(id: 'iframe_1')).to exist
|
|
51
|
+
expect(browser.iframe(name: 'iframe1')).to exist
|
|
52
|
+
expect(browser.iframe(index: 0)).to exist
|
|
53
|
+
expect(browser.iframe(class: 'half')).to exist
|
|
54
|
+
expect(browser.iframe(xpath: "//iframe[@id='iframe_1']")).to exist
|
|
55
|
+
expect(browser.iframe(src: 'iframe_1.html')).to exist
|
|
56
|
+
expect(browser.iframe(id: /iframe/)).to exist
|
|
57
|
+
expect(browser.iframe(name: /iframe/)).to exist
|
|
58
|
+
expect(browser.iframe(src: /iframe_1/)).to exist
|
|
59
|
+
expect(browser.iframe(class: /half/)).to exist
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'returns the first iframe if given no args' do
|
|
63
|
+
expect(browser.iframe).to exist
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "returns false if the iframe doesn't exist" do
|
|
67
|
+
expect(browser.iframe(id: 'no_such_id')).not_to exist
|
|
68
|
+
expect(browser.iframe(name: 'no_such_text')).not_to exist
|
|
69
|
+
expect(browser.iframe(index: 1337)).not_to exist
|
|
70
|
+
expect(browser.iframe(src: 'no_such_src')).not_to exist
|
|
71
|
+
expect(browser.iframe(class: 'no_such_class')).not_to exist
|
|
72
|
+
expect(browser.iframe(id: /no_such_id/)).not_to exist
|
|
73
|
+
expect(browser.iframe(name: /no_such_text/)).not_to exist
|
|
74
|
+
expect(browser.iframe(src: /no_such_src/)).not_to exist
|
|
75
|
+
expect(browser.iframe(class: /no_such_class/)).not_to exist
|
|
76
|
+
expect(browser.iframe(xpath: "//iframe[@id='no_such_id']")).not_to exist
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'returns true if an element in an iframe does exist' do
|
|
80
|
+
expect(browser.iframe.element(css: '#senderElement')).to exist
|
|
81
|
+
expect(browser.iframe.element(id: 'senderElement')).to exist
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'returns true for multiple elements that exist in an iframe with a parent selector' do
|
|
85
|
+
expect(browser.div(class: 'wrapper').iframe.element(id: 'first_grandson')).to exist
|
|
86
|
+
expect(browser.div(class: 'wrapper').iframe.element(id: 'second_grandson')).to exist
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'returns false if an element in an iframe does not exist' do
|
|
90
|
+
expect(browser.iframe.element(css: '#no_such_id')).not_to exist
|
|
91
|
+
expect(browser.iframe.element(id: 'no_such_id')).not_to exist
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'returns true if an element outside an iframe exists after checking for one inside that does exist' do
|
|
95
|
+
existing_element = browser.element(css: '#iframe_1')
|
|
96
|
+
expect(existing_element).to exist
|
|
97
|
+
expect(browser.iframe.element(css: '#senderElement')).to exist
|
|
98
|
+
expect(existing_element).to exist
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it 'returns true if an element outside an iframe exists after checking for one inside that does not exist' do
|
|
102
|
+
existing_element = browser.element(css: '#iframe_1')
|
|
103
|
+
expect(existing_element).to exist
|
|
104
|
+
expect(browser.iframe.element(css: '#no_such_id')).not_to exist
|
|
105
|
+
expect(existing_element).to exist
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it 'returns true if an element exists in a frame generated in a collection' do
|
|
109
|
+
nested_element = browser.body.iframes.first.div
|
|
110
|
+
expect(nested_element).to exist
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'returns false for sub-element of a non-existing iframe' do
|
|
114
|
+
expect(browser.iframe(id: 'no_such_id').element).not_to exist
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'handles nested iframes' do
|
|
118
|
+
browser.goto(WatirSpec.url_for('nested_iframes.html'))
|
|
119
|
+
browser.iframe(id: 'two').iframe(id: 'three').link(id: 'four').click
|
|
120
|
+
|
|
121
|
+
expect {
|
|
122
|
+
browser.wait_until { |b| b.title == 'definition_lists' }
|
|
123
|
+
}.not_to raise_exception
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
127
|
+
expect { browser.iframe(id: 3.14).exists? }.to raise_error(TypeError)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it 'handles all locators for element which do not exist' do
|
|
132
|
+
expect(browser.iframe(index: 0).div(id: 'invalid')).not_to exist
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
describe '#present?' do
|
|
136
|
+
it 'returns true if the iframe present' do
|
|
137
|
+
expect(browser.iframe(id: 'iframe_1')).to be_present
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'returns false if the iframe is not present' do
|
|
141
|
+
expect(browser.iframe(id: 'no_such_id')).not_to be_present
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it 'switches between iframe and parent when needed' do
|
|
146
|
+
expect {
|
|
147
|
+
browser.iframe(id: 'iframe_1').elements.each do |element|
|
|
148
|
+
element.text
|
|
149
|
+
browser.h1.text
|
|
150
|
+
end
|
|
151
|
+
}.not_to raise_exception
|
|
44
152
|
end
|
|
45
|
-
end
|
|
46
153
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
expect
|
|
50
|
-
expect(browser.iframe(name: 'iframe1')).to exist
|
|
51
|
-
expect(browser.iframe(index: 0)).to exist
|
|
52
|
-
expect(browser.iframe(class: 'half')).to exist
|
|
53
|
-
expect(browser.iframe(xpath: "//iframe[@id='iframe_1']")).to exist
|
|
54
|
-
expect(browser.iframe(src: 'iframe_1.html')).to exist
|
|
55
|
-
expect(browser.iframe(id: /iframe/)).to exist
|
|
56
|
-
expect(browser.iframe(name: /iframe/)).to exist
|
|
57
|
-
expect(browser.iframe(src: /iframe_1/)).to exist
|
|
58
|
-
expect(browser.iframe(class: /half/)).to exist
|
|
154
|
+
it 'switches when the frame is created by subtype' do
|
|
155
|
+
subtype = browser.iframe.to_subtype
|
|
156
|
+
expect { subtype.element.locate }.not_to raise_exception
|
|
59
157
|
end
|
|
60
158
|
|
|
61
|
-
it '
|
|
62
|
-
|
|
63
|
-
|
|
159
|
+
it 'switches back to top level browsing context' do
|
|
160
|
+
# Point driver to browsing context of first iframe
|
|
161
|
+
browser.iframes.first.ps.locate
|
|
64
162
|
|
|
65
|
-
|
|
66
|
-
expect(browser.iframe(id: 'no_such_id')).to_not exist
|
|
67
|
-
expect(browser.iframe(name: 'no_such_text')).to_not exist
|
|
68
|
-
expect(browser.iframe(index: 1337)).to_not exist
|
|
69
|
-
expect(browser.iframe(src: 'no_such_src')).to_not exist
|
|
70
|
-
expect(browser.iframe(class: 'no_such_class')).to_not exist
|
|
71
|
-
expect(browser.iframe(id: /no_such_id/)).to_not exist
|
|
72
|
-
expect(browser.iframe(name: /no_such_text/)).to_not exist
|
|
73
|
-
expect(browser.iframe(src: /no_such_src/)).to_not exist
|
|
74
|
-
expect(browser.iframe(class: /no_such_class/)).to_not exist
|
|
75
|
-
expect(browser.iframe(xpath: "//iframe[@id='no_such_id']")).to_not exist
|
|
163
|
+
expect(browser.h1s.first.text).to be == 'Iframes'
|
|
76
164
|
end
|
|
77
165
|
|
|
78
|
-
it '
|
|
79
|
-
expect
|
|
80
|
-
expect(browser.iframe.element(id: 'senderElement')).to exist
|
|
166
|
+
it 'raises UnknownFrameException when accessing elements inside non-existing iframe' do
|
|
167
|
+
expect { browser.iframe(name: 'no_such_name').p(index: 0).id }.to raise_unknown_frame_exception
|
|
81
168
|
end
|
|
82
169
|
|
|
83
|
-
it '
|
|
84
|
-
expect
|
|
85
|
-
expect(browser.div(class: 'wrapper').iframe.element(id: 'second_grandson')).to exist
|
|
170
|
+
it 'raises UnknownFrameException when accessing a non-existing iframe' do
|
|
171
|
+
expect { browser.iframe(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
|
86
172
|
end
|
|
87
173
|
|
|
88
|
-
it '
|
|
89
|
-
expect
|
|
90
|
-
expect(browser.iframe.element(id: 'no_such_id')).to_not exist
|
|
174
|
+
it 'raises UnknownFrameException when accessing a non-existing subframe' do
|
|
175
|
+
expect { browser.iframe(name: 'iframe1').iframe(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
|
91
176
|
end
|
|
92
177
|
|
|
93
|
-
it '
|
|
94
|
-
|
|
95
|
-
expect(existing_element).to exist
|
|
96
|
-
expect(browser.iframe.element(css: '#senderElement')).to exist
|
|
97
|
-
expect(existing_element).to exist
|
|
178
|
+
it 'raises UnknownObjectException when accessing a non-existing element inside an existing iframe' do
|
|
179
|
+
expect { browser.iframe(index: 0).p(index: 1337).id }.to raise_unknown_object_exception
|
|
98
180
|
end
|
|
99
181
|
|
|
100
|
-
it
|
|
101
|
-
|
|
102
|
-
expect(existing_element).to exist
|
|
103
|
-
expect(browser.iframe.element(css: '#no_such_id')).to_not exist
|
|
104
|
-
expect(existing_element).to exist
|
|
182
|
+
it "raises NoMethodError when trying to access attributes it doesn't have" do
|
|
183
|
+
expect { browser.iframe(index: 0).foo }.to raise_error(NoMethodError)
|
|
105
184
|
end
|
|
106
185
|
|
|
107
|
-
it '
|
|
108
|
-
|
|
109
|
-
expect(
|
|
186
|
+
it 'is able to set a field' do
|
|
187
|
+
browser.iframe(index: 0).text_field(name: 'senderElement').set('new value')
|
|
188
|
+
expect(browser.iframe(index: 0).text_field(name: 'senderElement').value).to eq 'new value'
|
|
110
189
|
end
|
|
111
190
|
|
|
112
|
-
it '
|
|
113
|
-
|
|
191
|
+
it 'will suggest looking in an iframe when iframes exist' do
|
|
192
|
+
msg = 'Maybe look in an iframe?'
|
|
193
|
+
expect { browser.text_field(name: 'senderElement').set('no') }.to raise_unknown_object_exception(msg)
|
|
114
194
|
end
|
|
115
195
|
|
|
116
|
-
it '
|
|
196
|
+
it 'will suggest looking in a nested iframe when iframes exist' do
|
|
117
197
|
browser.goto(WatirSpec.url_for('nested_iframes.html'))
|
|
118
|
-
browser.iframe(id: 'two')
|
|
119
|
-
|
|
120
|
-
expect {
|
|
121
|
-
browser.wait_until { |b| b.title == 'definition_lists' }
|
|
122
|
-
}.not_to raise_exception
|
|
198
|
+
top = browser.iframe(id: 'two')
|
|
199
|
+
expect { top.link(id: 'four').click }.to raise_unknown_object_exception('Maybe look in an iframe?')
|
|
123
200
|
end
|
|
124
201
|
|
|
125
|
-
|
|
126
|
-
|
|
202
|
+
describe '#execute_script' do
|
|
203
|
+
it 'executes the given javascript in the specified frame',
|
|
204
|
+
except: {browser: :safari, reason: 'Safari does not strip text'} do
|
|
205
|
+
frame = browser.iframe(index: 0)
|
|
206
|
+
expect(frame.div(id: 'set_by_js').text).to eq ''
|
|
207
|
+
inner_html = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
|
208
|
+
script = "document.getElementById('set_by_js').innerHTML = '#{inner_html}'"
|
|
209
|
+
frame.execute_script script
|
|
210
|
+
text = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
|
211
|
+
expect(frame.div(id: 'set_by_js').text).to eq text
|
|
212
|
+
end
|
|
127
213
|
end
|
|
128
|
-
end
|
|
129
214
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
it 'returns true if the iframe present' do
|
|
136
|
-
expect(browser.iframe(id: 'iframe_1')).to be_present
|
|
215
|
+
describe '#html' do
|
|
216
|
+
it 'returns the full HTML source of the iframe' do
|
|
217
|
+
browser.goto WatirSpec.url_for('iframes.html')
|
|
218
|
+
expect(browser.iframe.html.downcase).to include('<title>iframe 1</title>')
|
|
219
|
+
end
|
|
137
220
|
end
|
|
138
221
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
it 'switches between iframe and parent when needed' do
|
|
145
|
-
browser.iframe(id: 'iframe_1').elements.each do |element|
|
|
146
|
-
element.text
|
|
147
|
-
browser.h1.text
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it 'switches when the frame is created by subtype' do
|
|
152
|
-
subtype = browser.iframe.to_subtype
|
|
153
|
-
expect { subtype.element.locate }.to_not raise_exception
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it 'switches back to top level browsing context' do
|
|
157
|
-
# Point driver to browsing context of first iframe
|
|
158
|
-
browser.iframes.first.ps.locate
|
|
159
|
-
|
|
160
|
-
expect(browser.h1s.first.text).to be == 'Iframes'
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it 'raises UnknownFrameException when accessing elements inside non-existing iframe' do
|
|
164
|
-
expect { browser.iframe(name: 'no_such_name').p(index: 0).id }.to raise_unknown_frame_exception
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
it 'raises UnknownFrameException when accessing a non-existing iframe' do
|
|
168
|
-
expect { browser.iframe(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
it 'raises UnknownFrameException when accessing a non-existing subframe' do
|
|
172
|
-
expect { browser.iframe(name: 'iframe1').iframe(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
it 'raises UnknownObjectException when accessing a non-existing element inside an existing iframe' do
|
|
176
|
-
expect { browser.iframe(index: 0).p(index: 1337).id }.to raise_unknown_object_exception
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it "raises NoMethodError when trying to access attributes it doesn't have" do
|
|
180
|
-
expect { browser.iframe(index: 0).foo }.to raise_error(NoMethodError)
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
it 'is able to set a field' do
|
|
184
|
-
browser.iframe(index: 0).text_field(name: 'senderElement').set('new value')
|
|
185
|
-
expect(browser.iframe(index: 0).text_field(name: 'senderElement').value).to eq 'new value'
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
it 'will suggest looking in an iframe when iframes exist' do
|
|
189
|
-
msg = 'Maybe look in an iframe?'
|
|
190
|
-
expect { browser.text_field(name: 'senderElement').set('no') }.to raise_unknown_object_exception(msg)
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
it 'will suggest looking in a nested iframe when iframes exist' do
|
|
194
|
-
browser.goto(WatirSpec.url_for('nested_iframes.html'))
|
|
195
|
-
top = browser.iframe(id: 'two')
|
|
196
|
-
expect { top.link(id: 'four').click }.to raise_unknown_object_exception('Maybe look in an iframe?')
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
describe '#execute_script' do
|
|
200
|
-
it 'executes the given javascript in the specified frame',
|
|
201
|
-
except: {browser: :safari, reason: 'Safari does not strip text'} do
|
|
202
|
-
frame = browser.iframe(index: 0)
|
|
203
|
-
expect(frame.div(id: 'set_by_js').text).to eq ''
|
|
204
|
-
inner_html = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
|
205
|
-
script = "document.getElementById('set_by_js').innerHTML = '#{inner_html}'"
|
|
206
|
-
frame.execute_script script
|
|
207
|
-
text = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
|
208
|
-
expect(frame.div(id: 'set_by_js').text).to eq text
|
|
222
|
+
describe '#text' do
|
|
223
|
+
it 'returns the text inside the iframe' do
|
|
224
|
+
browser.goto WatirSpec.url_for('iframes.html')
|
|
225
|
+
expect(browser.iframe.text).to include('Frame 1')
|
|
226
|
+
end
|
|
209
227
|
end
|
|
210
228
|
end
|
|
211
229
|
|
|
212
|
-
describe
|
|
213
|
-
it '
|
|
230
|
+
describe FramedDriver do
|
|
231
|
+
it 'raises name error if method is not defined on driver or element' do
|
|
214
232
|
browser.goto WatirSpec.url_for('iframes.html')
|
|
215
|
-
expect(browser.iframe.
|
|
233
|
+
expect(browser.iframe(id: 'iframe_1').wd).not_to respond_to :foo
|
|
234
|
+
expect { browser.iframe(id: 'iframe_1').wd.foo }.to raise_exception NoMethodError
|
|
216
235
|
end
|
|
217
|
-
end
|
|
218
236
|
|
|
219
|
-
|
|
220
|
-
it 'returns the text inside the iframe' do
|
|
237
|
+
it 'raises exception when attempting to switch to a non-frame element' do
|
|
221
238
|
browser.goto WatirSpec.url_for('iframes.html')
|
|
222
|
-
|
|
239
|
+
element = browser.h1.wd
|
|
240
|
+
fd = described_class.new(element, browser)
|
|
241
|
+
expect { fd.switch! }.to raise_exception Watir::Exception::UnknownFrameException
|
|
223
242
|
end
|
|
224
243
|
end
|
|
225
244
|
end
|
|
226
|
-
|
|
227
|
-
describe 'FramedDriver' do
|
|
228
|
-
it 'raises name error if method is not defined on driver or element' do
|
|
229
|
-
browser.goto WatirSpec.url_for('iframes.html')
|
|
230
|
-
expect(browser.iframe(id: 'iframe_1').wd).not_to respond_to :foo
|
|
231
|
-
expect { browser.iframe(id: 'iframe_1').wd.foo }.to raise_exception NoMethodError
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
it 'raises exception when attempting to switch to a non-frame element' do
|
|
235
|
-
browser.goto WatirSpec.url_for('iframes.html')
|
|
236
|
-
element = browser.h1.wd
|
|
237
|
-
fd = Watir::FramedDriver.new(element, browser)
|
|
238
|
-
expect { fd.switch! }.to raise_exception Watir::Exception::UnknownFrameException
|
|
239
|
-
end
|
|
240
|
-
end
|
|
@@ -2,46 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
require 'watirspec_helper'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
module Watir
|
|
6
|
+
describe IFrameCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('iframes.html'))
|
|
9
|
+
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.iframes(id: 'iframe_2').to_a).to eq [browser.iframe(id: 'iframe_2')]
|
|
14
|
+
end
|
|
13
15
|
end
|
|
14
|
-
end
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
describe 'eql?' do
|
|
18
|
+
it 'matches equality of iframe with that from a collection' do
|
|
19
|
+
expect(browser.iframes.last).to eq browser.iframe(id: 'iframe_3')
|
|
20
|
+
end
|
|
19
21
|
end
|
|
20
|
-
end
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
describe '#length' do
|
|
24
|
+
it 'returns the correct number of iframes' do
|
|
25
|
+
expect(browser.iframes.length).to eq 3
|
|
26
|
+
end
|
|
25
27
|
end
|
|
26
|
-
end
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
describe '#[]' do
|
|
30
|
+
it 'returns the iframe at the given index' do
|
|
31
|
+
expect(browser.iframes[0].id).to eq 'iframe_1'
|
|
32
|
+
end
|
|
31
33
|
end
|
|
32
|
-
end
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
describe '#each' do
|
|
36
|
+
it 'iterates through frames correctly' do
|
|
37
|
+
count = 0
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
browser.iframes.each_with_index do |f, index|
|
|
40
|
+
expect(f.name).to eq browser.iframe(index: index).name
|
|
41
|
+
expect(f.id).to eq browser.iframe(index: index).id
|
|
42
|
+
count += 1
|
|
43
|
+
end
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
expect(count).to be > 0
|
|
46
|
+
end
|
|
45
47
|
end
|
|
46
48
|
end
|
|
47
49
|
end
|