watir 7.2.0 → 7.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/chrome.yml +1 -1
  3. data/.github/workflows/edge.yml +1 -1
  4. data/.github/workflows/firefox.yml +1 -1
  5. data/.github/workflows/ie.yml +1 -1
  6. data/.github/workflows/safari.yml +1 -1
  7. data/.github/workflows/unit.yml +1 -1
  8. data/.rubocop.yml +25 -12
  9. data/.rubocop_todo.yml +8 -1
  10. data/CHANGES.md +6 -1
  11. data/LICENSE +2 -2
  12. data/lib/watir/capabilities.rb +1 -1
  13. data/lib/watir/locators/anchor/selector_builder.rb +3 -0
  14. data/lib/watir/locators/element/matcher.rb +2 -1
  15. data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +2 -1
  16. data/lib/watir/locators/text_field/matcher.rb +0 -4
  17. data/lib/watir/version.rb +1 -1
  18. data/spec/locator_spec_helper.rb +0 -8
  19. data/spec/unit/capabilities_spec.rb +553 -561
  20. data/spec/unit/element_locator_spec.rb +89 -78
  21. data/spec/unit/match_elements/button_spec.rb +69 -62
  22. data/spec/unit/match_elements/element_spec.rb +303 -309
  23. data/spec/unit/match_elements/text_field_spec.rb +76 -73
  24. data/spec/unit/selector_builder/anchor_spec.rb +39 -33
  25. data/spec/unit/selector_builder/button_spec.rb +209 -202
  26. data/spec/unit/selector_builder/cell_spec.rb +48 -42
  27. data/spec/unit/selector_builder/element_spec.rb +634 -627
  28. data/spec/unit/selector_builder/row_spec.rb +119 -113
  29. data/spec/unit/selector_builder/text_field_spec.rb +195 -188
  30. data/spec/unit/selector_builder/textarea_spec.rb +22 -14
  31. data/spec/unit/wait_spec.rb +85 -81
  32. data/spec/watirspec/adjacent_spec.rb +249 -247
  33. data/spec/watirspec/after_hooks_spec.rb +161 -159
  34. data/spec/watirspec/alert_spec.rb +61 -58
  35. data/spec/watirspec/browser_spec.rb +409 -409
  36. data/spec/watirspec/capabilities_spec.rb +89 -99
  37. data/spec/watirspec/cookies_spec.rb +120 -118
  38. data/spec/watirspec/drag_and_drop_spec.rb +26 -24
  39. data/spec/watirspec/element_hidden_spec.rb +66 -60
  40. data/spec/watirspec/elements/area_spec.rb +49 -47
  41. data/spec/watirspec/elements/areas_spec.rb +27 -25
  42. data/spec/watirspec/elements/button_spec.rb +253 -251
  43. data/spec/watirspec/elements/buttons_spec.rb +36 -34
  44. data/spec/watirspec/elements/checkbox_spec.rb +48 -36
  45. data/spec/watirspec/elements/checkboxes_spec.rb +29 -27
  46. data/spec/watirspec/elements/collections_spec.rb +126 -119
  47. data/spec/watirspec/elements/date_field_spec.rb +185 -183
  48. data/spec/watirspec/elements/date_fields_spec.rb +29 -27
  49. data/spec/watirspec/elements/date_time_field_spec.rb +197 -195
  50. data/spec/watirspec/elements/date_time_fields_spec.rb +30 -28
  51. data/spec/watirspec/elements/dd_spec.rb +87 -85
  52. data/spec/watirspec/elements/dds_spec.rb +27 -25
  53. data/spec/watirspec/elements/del_spec.rb +106 -104
  54. data/spec/watirspec/elements/dels_spec.rb +26 -24
  55. data/spec/watirspec/elements/div_spec.rb +225 -221
  56. data/spec/watirspec/elements/divs_spec.rb +37 -35
  57. data/spec/watirspec/elements/dl_spec.rb +110 -108
  58. data/spec/watirspec/elements/dls_spec.rb +28 -26
  59. data/spec/watirspec/elements/dt_spec.rb +86 -84
  60. data/spec/watirspec/elements/dts_spec.rb +27 -25
  61. data/spec/watirspec/elements/element_spec.rb +794 -775
  62. data/spec/watirspec/elements/elements_spec.rb +40 -38
  63. data/spec/watirspec/elements/em_spec.rb +62 -60
  64. data/spec/watirspec/elements/ems_spec.rb +28 -26
  65. data/spec/watirspec/elements/filefield_spec.rb +116 -114
  66. data/spec/watirspec/elements/filefields_spec.rb +28 -26
  67. data/spec/watirspec/elements/font_spec.rb +20 -18
  68. data/spec/watirspec/elements/form_spec.rb +51 -49
  69. data/spec/watirspec/elements/forms_spec.rb +29 -27
  70. data/spec/watirspec/elements/frame_spec.rb +89 -87
  71. data/spec/watirspec/elements/frames_spec.rb +27 -25
  72. data/spec/watirspec/elements/hidden_spec.rb +81 -79
  73. data/spec/watirspec/elements/hiddens_spec.rb +28 -26
  74. data/spec/watirspec/elements/hn_spec.rb +59 -57
  75. data/spec/watirspec/elements/hns_spec.rb +26 -24
  76. data/spec/watirspec/elements/iframe_spec.rb +195 -191
  77. data/spec/watirspec/elements/iframes_spec.rb +31 -29
  78. data/spec/watirspec/elements/image_spec.rb +148 -146
  79. data/spec/watirspec/elements/images_spec.rb +26 -24
  80. data/spec/watirspec/elements/input_spec.rb +9 -7
  81. data/spec/watirspec/elements/ins_spec.rb +106 -104
  82. data/spec/watirspec/elements/inses_spec.rb +26 -24
  83. data/spec/watirspec/elements/label_spec.rb +56 -54
  84. data/spec/watirspec/elements/labels_spec.rb +26 -24
  85. data/spec/watirspec/elements/li_spec.rb +76 -74
  86. data/spec/watirspec/elements/link_spec.rb +173 -177
  87. data/spec/watirspec/elements/links_spec.rb +45 -43
  88. data/spec/watirspec/elements/lis_spec.rb +27 -25
  89. data/spec/watirspec/elements/list_spec.rb +44 -42
  90. data/spec/watirspec/elements/map_spec.rb +57 -55
  91. data/spec/watirspec/elements/maps_spec.rb +27 -25
  92. data/spec/watirspec/elements/meta_spec.rb +16 -14
  93. data/spec/watirspec/elements/metas_spec.rb +26 -24
  94. data/spec/watirspec/elements/ol_spec.rb +56 -65
  95. data/spec/watirspec/elements/ols_spec.rb +26 -24
  96. data/spec/watirspec/elements/option_spec.rb +91 -89
  97. data/spec/watirspec/elements/p_spec.rb +81 -79
  98. data/spec/watirspec/elements/pre_spec.rb +77 -75
  99. data/spec/watirspec/elements/pres_spec.rb +26 -24
  100. data/spec/watirspec/elements/ps_spec.rb +26 -24
  101. data/spec/watirspec/elements/radio_spec.rb +251 -249
  102. data/spec/watirspec/elements/radios_spec.rb +28 -26
  103. data/spec/watirspec/elements/select_list_spec.rb +537 -526
  104. data/spec/watirspec/elements/select_lists_spec.rb +32 -30
  105. data/spec/watirspec/elements/span_spec.rb +112 -110
  106. data/spec/watirspec/elements/spans_spec.rb +26 -24
  107. data/spec/watirspec/elements/strong_spec.rb +58 -58
  108. data/spec/watirspec/elements/strongs_spec.rb +28 -26
  109. data/spec/watirspec/elements/table_spec.rb +192 -139
  110. data/spec/watirspec/elements/tables_spec.rb +28 -26
  111. data/spec/watirspec/elements/tbody_spec.rb +74 -72
  112. data/spec/watirspec/elements/tbodys_spec.rb +40 -38
  113. data/spec/watirspec/elements/td_spec.rb +66 -64
  114. data/spec/watirspec/elements/tds_spec.rb +41 -39
  115. data/spec/watirspec/elements/text_field_spec.rb +206 -204
  116. data/spec/watirspec/elements/text_fields_spec.rb +30 -28
  117. data/spec/watirspec/elements/textarea_spec.rb +20 -18
  118. data/spec/watirspec/elements/textareas_spec.rb +18 -16
  119. data/spec/watirspec/elements/tfoot_spec.rb +65 -63
  120. data/spec/watirspec/elements/tfoots_spec.rb +42 -40
  121. data/spec/watirspec/elements/thead_spec.rb +65 -63
  122. data/spec/watirspec/elements/theads_spec.rb +42 -40
  123. data/spec/watirspec/elements/tr_spec.rb +48 -46
  124. data/spec/watirspec/elements/trs_spec.rb +42 -40
  125. data/spec/watirspec/elements/ul_spec.rb +56 -54
  126. data/spec/watirspec/elements/uls_spec.rb +26 -24
  127. data/spec/watirspec/radio_set_spec.rb +269 -267
  128. data/spec/watirspec/screenshot_spec.rb +20 -18
  129. data/spec/watirspec/scroll_spec.rb +152 -148
  130. data/spec/watirspec/shadow_root_spec.rb +86 -83
  131. data/spec/watirspec/user_editable_spec.rb +200 -198
  132. data/spec/watirspec/wait_spec.rb +289 -295
  133. data/spec/watirspec/window_switching_spec.rb +422 -434
  134. data/spec/watirspec_helper.rb +1 -23
  135. data/watir.gemspec +5 -4
  136. metadata +44 -33
  137. data/spec/watirspec/attributes_spec.rb +0 -18
  138. data/spec/watirspec/elements/table_nesting_spec.rb +0 -51
  139. data/spec/watirspec/special_chars_spec.rb +0 -23
@@ -2,28 +2,30 @@
2
2
 
3
3
  require 'watirspec_helper'
4
4
 
5
- describe 'Font' do
6
- before :each do
7
- browser.goto(WatirSpec.url_for('font.html'))
8
- end
5
+ module Watir
6
+ describe Font do
7
+ before do
8
+ browser.goto(WatirSpec.url_for('font.html'))
9
+ end
9
10
 
10
- it 'finds the font element' do
11
- expect(browser.font(index: 0)).to exist
12
- end
11
+ it 'finds the font element' do
12
+ expect(browser.font(index: 0)).to exist
13
+ end
13
14
 
14
- it 'knows about the color attribute' do
15
- expect(browser.font(index: 0).color).to eq '#ff00ff'
16
- end
15
+ it 'knows about the color attribute' do
16
+ expect(browser.font(index: 0).color).to eq '#ff00ff'
17
+ end
17
18
 
18
- it 'knows about the face attribute' do
19
- expect(browser.font(index: 0).face).to eq 'Helvetica'
20
- end
19
+ it 'knows about the face attribute' do
20
+ expect(browser.font(index: 0).face).to eq 'Helvetica'
21
+ end
21
22
 
22
- it 'knows about the size attribute' do
23
- expect(browser.font(index: 0).size).to eq '12'
24
- end
23
+ it 'knows about the size attribute' do
24
+ expect(browser.font(index: 0).size).to eq '12'
25
+ end
25
26
 
26
- it 'finds all font elements' do
27
- expect(browser.fonts.size).to eq 1
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
- describe 'Form' do
6
- before :each do
7
- browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
8
- end
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
- describe '#exists?' do
11
- it 'returns true if the form exists' do
12
- expect(browser.form(id: 'new_user')).to exist
13
- expect(browser.form(id: /new_user/)).to exist
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
- expect(browser.form(class: 'user')).to exist
16
- expect(browser.form(class: /user/)).to exist
16
+ expect(browser.form(class: 'user')).to exist
17
+ expect(browser.form(class: /user/)).to exist
17
18
 
18
- expect(browser.form(method: 'post')).to exist
19
- expect(browser.form(method: /post/)).to exist
20
- expect(browser.form(action: /to_me/)).to exist
21
- expect(browser.form(index: 0)).to exist
22
- expect(browser.form(xpath: "//form[@id='new_user']")).to exist
23
- end
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
- it 'returns the first form if given no args' do
26
- expect(browser.form).to exist
27
- end
26
+ it 'returns the first form if given no args' do
27
+ expect(browser.form).to exist
28
+ end
28
29
 
29
- it "returns false if the form doesn't exist" do
30
- expect(browser.form(id: 'no_such_id')).to_not exist
31
- expect(browser.form(id: /no_such_id/)).to_not exist
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
- expect(browser.form(class: 'no_such_class')).to_not exist
34
- expect(browser.form(class: /no_such_class/)).to_not exist
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
- expect(browser.form(method: 'no_such_method')).to_not exist
37
- expect(browser.form(method: /no_such_method/)).to_not exist
38
- expect(browser.form(action: 'no_such_action')).to_not exist
39
- expect(browser.form(action: /no_such_action/)).to_not exist
40
- expect(browser.form(index: 1337)).to_not exist
41
- expect(browser.form(xpath: "//form[@id='no_such_id']")).to_not exist
42
- end
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
- it "raises TypeError when 'what' argument is invalid" do
45
- expect { browser.form(id: 3.14).exists? }.to raise_error(TypeError)
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
- describe '#submit' do
50
- it 'submits the form' do
51
- browser.form(id: 'delete_user').submit
52
- browser.wait_while(url: /forms_with_input_elements\.html$/)
53
- expect(browser.text).to include('Semantic table')
54
- end
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
- it 'triggers onsubmit event and takes its result into account' do
57
- form = browser.form(name: 'user_new')
58
- form.submit
59
- expect(form).to exist
60
- expect(messages.size).to eq 1
61
- expect(messages[0]).to eq 'submit'
62
- end
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
- it 'times out when submitting an element that is not displayed' do
65
- expect { browser.form(name: 'no').submit }.to raise_unknown_object_exception
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
- describe 'Forms' do
6
- before :each do
7
- browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
8
- end
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
- describe 'with selectors' do
11
- it 'returns the matching elements' do
12
- expect(browser.forms(method: 'post').to_a).to eq [browser.form(method: 'post')]
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
- describe '#length' do
17
- it 'returns the number of forms in the container' do
18
- expect(browser.forms.length).to eq 2
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
- describe '#[]n' do
23
- it 'provides access to the nth form' do
24
- expect(browser.forms[0].action).to match(/post_to_me$/) # varies between browsers
25
- expect(browser.forms[0].attribute_value('method')).to eq 'post'
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
- describe '#each' do
30
- it 'iterates through forms correctly' do
31
- count = 0
30
+ describe '#each' do
31
+ it 'iterates through forms correctly' do
32
+ count = 0
32
33
 
33
- browser.forms.each_with_index do |f, index|
34
- expect(f.name).to eq browser.form(index: index).name
35
- expect(f.id).to eq browser.form(index: index).id
36
- expect(f.class_name).to eq browser.form(index: index).class_name
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
- count += 1
39
- end
39
+ count += 1
40
+ end
40
41
 
41
- expect(count).to be > 0
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
- describe 'Frame' do
10
- before :each do
11
- browser.goto(WatirSpec.url_for('frames.html'))
12
- end
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 'returns the first frame if given no args' do
36
- expect(browser.frame).to exist
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
- it "returns false if the frame doesn't exist" do
40
- expect(browser.frame(id: 'no_such_id')).to_not exist
41
- expect(browser.frame(name: 'no_such_text')).to_not exist
42
- expect(browser.frame(index: 1337)).to_not exist
43
- expect(browser.frame(src: 'no_such_src')).to_not exist
44
- expect(browser.frame(class: 'no_such_class')).to_not exist
45
- expect(browser.frame(id: /no_such_id/)).to_not exist
46
- expect(browser.frame(name: /no_such_text/)).to_not exist
47
- expect(browser.frame(src: /no_such_src/)).to_not exist
48
- expect(browser.frame(class: /no_such_class/)).to_not exist
49
- expect(browser.frame(xpath: "//frame[@id='no_such_id']")).to_not exist
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 'handles nested frames' do
53
- browser.goto(WatirSpec.url_for('nested_frames.html'))
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 "raises TypeError when 'what' argument is invalid" do
62
- expect { browser.frame(id: 3.14).exists? }.to raise_error(TypeError)
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
- it 'raises UnknownFrameException when accessing a non-existing subframe' do
75
- expect { browser.frame(name: 'frame1').frame(name: 'no_such_name').id }.to raise_unknown_frame_exception
76
- end
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
- it 'raises UnknownObjectException when accessing a non-existing element inside an existing frame' do
79
- expect { browser.frame(index: 0).p(index: 1337).id }.to raise_unknown_object_exception
80
- end
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
- it "raises NoMethodError when trying to access attributes it doesn't have" do
83
- expect { browser.frame(index: 0).foo }.to raise_error(NoMethodError)
84
- end
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
- it 'is able to set a field' do
87
- browser.frame(index: 0).text_field(name: 'senderElement').set('new value')
88
- expect(browser.frame(index: 0).text_field(name: 'senderElement').value).to eq 'new value'
89
- end
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
- it "can access the frame's parent element after use" do
92
- el = browser.frameset
93
- el.frame.text_field.value
94
- expect(el.attribute_value('cols')).to be_kind_of(String)
95
- end
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
- describe '#execute_script' do
98
- it 'executes the given javascript in the specified frame',
99
- except: {browser: :safari, reason: 'Safari does not strip text'} do
100
- frame = browser.frame(index: 0)
101
- expect(frame.div(id: 'set_by_js').text).to eq ''
102
- inner_html = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
103
- frame.execute_script(%{document.getElementById('set_by_js').innerHTML = '#{inner_html}'})
104
- text = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
105
- expect(frame.div(id: 'set_by_js').text).to eq text
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
- describe '#html' do
110
- it 'returns the full HTML source of the frame' do
111
- browser.goto WatirSpec.url_for('frames.html')
112
- expect(browser.frame.html.downcase).to include('<title>frame 1</title>')
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
- describe 'Frames' do
6
- before :each do
7
- browser.goto(WatirSpec.url_for('frames.html'))
8
- end
5
+ module Watir
6
+ describe FrameCollection do
7
+ before do
8
+ browser.goto(WatirSpec.url_for('frames.html'))
9
+ end
9
10
 
10
- describe 'with selectors' do
11
- it 'returns the matching elements' do
12
- expect(browser.frames(name: 'frame2').to_a).to eq [browser.frame(name: 'frame2')]
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
- describe '#length' do
17
- it 'returns the correct number of frames' do
18
- expect(browser.frames.length).to eq 2
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
- describe '#[]' do
23
- it 'returns the frame at the given index' do
24
- expect(browser.frames[0].id).to eq 'frame_1'
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
- describe '#each' do
29
- it 'iterates through frames correctly' do
30
- count = 0
29
+ describe '#each' do
30
+ it 'iterates through frames correctly' do
31
+ count = 0
31
32
 
32
- browser.frames.each_with_index do |f, index|
33
- expect(f.name).to eq browser.frame(index: index).name
34
- expect(f.id).to eq browser.frame(index: index).id
35
- count += 1
36
- end
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
- expect(count).to be > 0
39
+ expect(count).to be > 0
40
+ end
39
41
  end
40
42
  end
41
43
  end