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
|
@@ -2,28 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
require 'watirspec_helper'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
module Watir
|
|
6
|
+
describe Font do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('font.html'))
|
|
9
|
+
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
it 'finds the font element' do
|
|
12
|
+
expect(browser.font(index: 0)).to exist
|
|
13
|
+
end
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
it 'knows about the color attribute' do
|
|
16
|
+
expect(browser.font(index: 0).color).to eq '#ff00ff'
|
|
17
|
+
end
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
it 'knows about the face attribute' do
|
|
20
|
+
expect(browser.font(index: 0).face).to eq 'Helvetica'
|
|
21
|
+
end
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
it 'knows about the size attribute' do
|
|
24
|
+
expect(browser.font(index: 0).size).to eq '12'
|
|
25
|
+
end
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
it 'finds all font elements' do
|
|
28
|
+
expect(browser.fonts.size).to eq 1
|
|
29
|
+
end
|
|
28
30
|
end
|
|
29
31
|
end
|
|
@@ -2,67 +2,69 @@
|
|
|
2
2
|
|
|
3
3
|
require 'watirspec_helper'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
module Watir
|
|
6
|
+
describe Form do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
describe '#exists?' do
|
|
12
|
+
it 'returns true if the form exists' do
|
|
13
|
+
expect(browser.form(id: 'new_user')).to exist
|
|
14
|
+
expect(browser.form(id: /new_user/)).to exist
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
expect(browser.form(class: 'user')).to exist
|
|
17
|
+
expect(browser.form(class: /user/)).to exist
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
expect(browser.form(method: 'post')).to exist
|
|
20
|
+
expect(browser.form(method: /post/)).to exist
|
|
21
|
+
expect(browser.form(action: /to_me/)).to exist
|
|
22
|
+
expect(browser.form(index: 0)).to exist
|
|
23
|
+
expect(browser.form(xpath: "//form[@id='new_user']")).to exist
|
|
24
|
+
end
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
it 'returns the first form if given no args' do
|
|
27
|
+
expect(browser.form).to exist
|
|
28
|
+
end
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
it "returns false if the form doesn't exist" do
|
|
31
|
+
expect(browser.form(id: 'no_such_id')).not_to exist
|
|
32
|
+
expect(browser.form(id: /no_such_id/)).not_to exist
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
expect(browser.form(class: 'no_such_class')).not_to exist
|
|
35
|
+
expect(browser.form(class: /no_such_class/)).not_to exist
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
expect(browser.form(method: 'no_such_method')).not_to exist
|
|
38
|
+
expect(browser.form(method: /no_such_method/)).not_to exist
|
|
39
|
+
expect(browser.form(action: 'no_such_action')).not_to exist
|
|
40
|
+
expect(browser.form(action: /no_such_action/)).not_to exist
|
|
41
|
+
expect(browser.form(index: 1337)).not_to exist
|
|
42
|
+
expect(browser.form(xpath: "//form[@id='no_such_id']")).not_to exist
|
|
43
|
+
end
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
46
|
+
expect { browser.form(id: 3.14).exists? }.to raise_error(TypeError)
|
|
47
|
+
end
|
|
46
48
|
end
|
|
47
|
-
end
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
describe '#submit' do
|
|
51
|
+
it 'submits the form' do
|
|
52
|
+
browser.form(id: 'delete_user').submit
|
|
53
|
+
browser.wait_while(url: /forms_with_input_elements\.html$/)
|
|
54
|
+
expect(browser.text).to include('Semantic table')
|
|
55
|
+
end
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
it 'triggers onsubmit event and takes its result into account' do
|
|
58
|
+
form = browser.form(name: 'user_new')
|
|
59
|
+
form.submit
|
|
60
|
+
expect(form).to exist
|
|
61
|
+
expect(messages.size).to eq 1
|
|
62
|
+
expect(messages[0]).to eq 'submit'
|
|
63
|
+
end
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
it 'times out when submitting an element that is not displayed' do
|
|
66
|
+
expect { browser.form(name: 'no').submit }.to raise_unknown_object_exception
|
|
67
|
+
end
|
|
66
68
|
end
|
|
67
69
|
end
|
|
68
70
|
end
|
|
@@ -2,43 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
require 'watirspec_helper'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
module Watir
|
|
6
|
+
describe FormCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.forms(method: 'post').to_a).to eq [browser.form(method: 'post')]
|
|
14
|
+
end
|
|
13
15
|
end
|
|
14
|
-
end
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the number of forms in the container' do
|
|
19
|
+
expect(browser.forms.length).to eq 2
|
|
20
|
+
end
|
|
19
21
|
end
|
|
20
|
-
end
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
describe '#[]n' do
|
|
24
|
+
it 'provides access to the nth form' do
|
|
25
|
+
expect(browser.forms[0].action).to match(/post_to_me$/) # varies between browsers
|
|
26
|
+
expect(browser.forms[0].attribute_value('method')).to eq 'post'
|
|
27
|
+
end
|
|
26
28
|
end
|
|
27
|
-
end
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
describe '#each' do
|
|
31
|
+
it 'iterates through forms correctly' do
|
|
32
|
+
count = 0
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
browser.forms.each_with_index do |f, index|
|
|
35
|
+
expect(f.name).to eq browser.form(index: index).name
|
|
36
|
+
expect(f.id).to eq browser.form(index: index).id
|
|
37
|
+
expect(f.class_name).to eq browser.form(index: index).class_name
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
count += 1
|
|
40
|
+
end
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
expect(count).to be > 0
|
|
43
|
+
end
|
|
42
44
|
end
|
|
43
45
|
end
|
|
44
46
|
end
|
|
@@ -6,110 +6,112 @@ require 'watirspec_helper'
|
|
|
6
6
|
# TODO: fix duplication with iframe_spec
|
|
7
7
|
#
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
it 'handles crossframe javascript' do
|
|
15
|
-
expect(browser.frame(id: 'frame_1').text_field(name: 'senderElement').value).to eq 'send_this_value'
|
|
16
|
-
expect(browser.frame(id: 'frame_2').text_field(name: 'recieverElement').value).to eq 'old_value'
|
|
17
|
-
browser.frame(id: 'frame_1').button(id: 'send').click
|
|
18
|
-
expect(browser.frame(id: 'frame_2').text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe '#exist?' do
|
|
22
|
-
it 'returns true if the frame exists' do
|
|
23
|
-
expect(browser.frame(id: 'frame_1')).to exist
|
|
24
|
-
expect(browser.frame(name: 'frame1')).to exist
|
|
25
|
-
expect(browser.frame(index: 0)).to exist
|
|
26
|
-
expect(browser.frame(class: 'half')).to exist
|
|
27
|
-
expect(browser.frame(xpath: "//frame[@id='frame_1']")).to exist
|
|
28
|
-
expect(browser.frame(src: 'frame_1.html')).to exist
|
|
29
|
-
expect(browser.frame(id: /frame/)).to exist
|
|
30
|
-
expect(browser.frame(name: /frame/)).to exist
|
|
31
|
-
expect(browser.frame(src: /frame_1/)).to exist
|
|
32
|
-
expect(browser.frame(class: /half/)).to exist
|
|
9
|
+
module Watir
|
|
10
|
+
describe Frame do
|
|
11
|
+
before do
|
|
12
|
+
browser.goto(WatirSpec.url_for('frames.html'))
|
|
33
13
|
end
|
|
34
14
|
|
|
35
|
-
it '
|
|
36
|
-
expect(browser.frame).to
|
|
15
|
+
it 'handles crossframe javascript' do
|
|
16
|
+
expect(browser.frame(id: 'frame_1').text_field(name: 'senderElement').value).to eq 'send_this_value'
|
|
17
|
+
expect(browser.frame(id: 'frame_2').text_field(name: 'recieverElement').value).to eq 'old_value'
|
|
18
|
+
browser.frame(id: 'frame_1').button(id: 'send').click
|
|
19
|
+
expect(browser.frame(id: 'frame_2').text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
|
37
20
|
end
|
|
38
21
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
describe '#exist?' do
|
|
23
|
+
it 'returns true if the frame exists' do
|
|
24
|
+
expect(browser.frame(id: 'frame_1')).to exist
|
|
25
|
+
expect(browser.frame(name: 'frame1')).to exist
|
|
26
|
+
expect(browser.frame(index: 0)).to exist
|
|
27
|
+
expect(browser.frame(class: 'half')).to exist
|
|
28
|
+
expect(browser.frame(xpath: "//frame[@id='frame_1']")).to exist
|
|
29
|
+
expect(browser.frame(src: 'frame_1.html')).to exist
|
|
30
|
+
expect(browser.frame(id: /frame/)).to exist
|
|
31
|
+
expect(browser.frame(name: /frame/)).to exist
|
|
32
|
+
expect(browser.frame(src: /frame_1/)).to exist
|
|
33
|
+
expect(browser.frame(class: /half/)).to exist
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'returns the first frame if given no args' do
|
|
37
|
+
expect(browser.frame).to exist
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "returns false if the frame doesn't exist" do
|
|
41
|
+
expect(browser.frame(id: 'no_such_id')).not_to exist
|
|
42
|
+
expect(browser.frame(name: 'no_such_text')).not_to exist
|
|
43
|
+
expect(browser.frame(index: 1337)).not_to exist
|
|
44
|
+
expect(browser.frame(src: 'no_such_src')).not_to exist
|
|
45
|
+
expect(browser.frame(class: 'no_such_class')).not_to exist
|
|
46
|
+
expect(browser.frame(id: /no_such_id/)).not_to exist
|
|
47
|
+
expect(browser.frame(name: /no_such_text/)).not_to exist
|
|
48
|
+
expect(browser.frame(src: /no_such_src/)).not_to exist
|
|
49
|
+
expect(browser.frame(class: /no_such_class/)).not_to exist
|
|
50
|
+
expect(browser.frame(xpath: "//frame[@id='no_such_id']")).not_to exist
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'handles nested frames' do
|
|
54
|
+
browser.goto(WatirSpec.url_for('nested_frames.html'))
|
|
55
|
+
|
|
56
|
+
browser.frame(id: 'two').frame(id: 'three').link(id: 'four').click
|
|
57
|
+
|
|
58
|
+
browser.wait_until(title: 'definition_lists')
|
|
59
|
+
expect { browser.goto(WatirSpec.url_for('nested_frames.html')) }.not_to raise_exception
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
63
|
+
expect { browser.frame(id: 3.14).exists? }.to raise_error(TypeError)
|
|
64
|
+
end
|
|
50
65
|
end
|
|
51
66
|
|
|
52
|
-
it '
|
|
53
|
-
browser.
|
|
54
|
-
|
|
55
|
-
browser.frame(id: 'two').frame(id: 'three').link(id: 'four').click
|
|
56
|
-
|
|
57
|
-
browser.wait_until(title: 'definition_lists')
|
|
58
|
-
expect { browser.goto(WatirSpec.url_for('nested_frames.html')) }.to_not raise_exception
|
|
67
|
+
it 'raises UnknownFrameException when accessing elements inside non-existing frame' do
|
|
68
|
+
expect { browser.frame(name: 'no_such_name').p(index: 0).id }.to raise_unknown_frame_exception
|
|
59
69
|
end
|
|
60
70
|
|
|
61
|
-
it
|
|
62
|
-
expect { browser.frame(
|
|
71
|
+
it 'raises UnknownFrameException when accessing a non-existing frame' do
|
|
72
|
+
expect { browser.frame(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
|
63
73
|
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it 'raises UnknownFrameException when accessing elements inside non-existing frame' do
|
|
67
|
-
expect { browser.frame(name: 'no_such_name').p(index: 0).id }.to raise_unknown_frame_exception
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it 'raises UnknownFrameException when accessing a non-existing frame' do
|
|
71
|
-
expect { browser.frame(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
|
72
|
-
end
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
it 'raises UnknownFrameException when accessing a non-existing subframe' do
|
|
76
|
+
expect { browser.frame(name: 'frame1').frame(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
|
77
|
+
end
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
it 'raises UnknownObjectException when accessing a non-existing element inside an existing frame' do
|
|
80
|
+
expect { browser.frame(index: 0).p(index: 1337).id }.to raise_unknown_object_exception
|
|
81
|
+
end
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
it "raises NoMethodError when trying to access attributes it doesn't have" do
|
|
84
|
+
expect { browser.frame(index: 0).foo }.to raise_error(NoMethodError)
|
|
85
|
+
end
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
it 'is able to set a field' do
|
|
88
|
+
browser.frame(index: 0).text_field(name: 'senderElement').set('new value')
|
|
89
|
+
expect(browser.frame(index: 0).text_field(name: 'senderElement').value).to eq 'new value'
|
|
90
|
+
end
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
it "can access the frame's parent element after use" do
|
|
93
|
+
el = browser.frameset
|
|
94
|
+
el.frame.text_field.value
|
|
95
|
+
expect(el.attribute_value('cols')).to be_a(String)
|
|
96
|
+
end
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
describe '#execute_script' do
|
|
99
|
+
it 'executes the given javascript in the specified frame',
|
|
100
|
+
except: {browser: :safari, reason: 'Safari does not strip text'} do
|
|
101
|
+
frame = browser.frame(index: 0)
|
|
102
|
+
expect(frame.div(id: 'set_by_js').text).to eq ''
|
|
103
|
+
inner_html = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
|
104
|
+
frame.execute_script(%{document.getElementById('set_by_js').innerHTML = '#{inner_html}'})
|
|
105
|
+
text = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
|
106
|
+
expect(frame.div(id: 'set_by_js').text).to eq text
|
|
107
|
+
end
|
|
106
108
|
end
|
|
107
|
-
end
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
describe '#html' do
|
|
111
|
+
it 'returns the full HTML source of the frame' do
|
|
112
|
+
browser.goto WatirSpec.url_for('frames.html')
|
|
113
|
+
expect(browser.frame.html.downcase).to include('<title>frame 1</title>')
|
|
114
|
+
end
|
|
113
115
|
end
|
|
114
116
|
end
|
|
115
117
|
end
|
|
@@ -2,40 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
require 'watirspec_helper'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
module Watir
|
|
6
|
+
describe FrameCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('frames.html'))
|
|
9
|
+
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.frames(name: 'frame2').to_a).to eq [browser.frame(name: 'frame2')]
|
|
14
|
+
end
|
|
13
15
|
end
|
|
14
|
-
end
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the correct number of frames' do
|
|
19
|
+
expect(browser.frames.length).to eq 2
|
|
20
|
+
end
|
|
19
21
|
end
|
|
20
|
-
end
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
describe '#[]' do
|
|
24
|
+
it 'returns the frame at the given index' do
|
|
25
|
+
expect(browser.frames[0].id).to eq 'frame_1'
|
|
26
|
+
end
|
|
25
27
|
end
|
|
26
|
-
end
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
describe '#each' do
|
|
30
|
+
it 'iterates through frames correctly' do
|
|
31
|
+
count = 0
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
browser.frames.each_with_index do |f, index|
|
|
34
|
+
expect(f.name).to eq browser.frame(index: index).name
|
|
35
|
+
expect(f.id).to eq browser.frame(index: index).id
|
|
36
|
+
count += 1
|
|
37
|
+
end
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
expect(count).to be > 0
|
|
40
|
+
end
|
|
39
41
|
end
|
|
40
42
|
end
|
|
41
43
|
end
|