watir 6.13.0 → 6.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +141 -0
  3. data/.travis.yml +6 -0
  4. data/CHANGES.md +12 -0
  5. data/Gemfile +4 -10
  6. data/README.md +64 -49
  7. data/Rakefile +28 -16
  8. data/lib/watir.rb +13 -15
  9. data/lib/watir/adjacent.rb +15 -13
  10. data/lib/watir/after_hooks.rb +8 -10
  11. data/lib/watir/alert.rb +7 -8
  12. data/lib/watir/aliases.rb +2 -2
  13. data/lib/watir/attribute_helper.rb +18 -20
  14. data/lib/watir/browser.rb +42 -75
  15. data/lib/watir/capabilities.rb +19 -10
  16. data/lib/watir/cell_container.rb +0 -2
  17. data/lib/watir/container.rb +4 -4
  18. data/lib/watir/cookies.rb +7 -8
  19. data/lib/watir/element_collection.rb +37 -22
  20. data/lib/watir/elements/area.rb +0 -2
  21. data/lib/watir/elements/button.rb +1 -3
  22. data/lib/watir/elements/cell.rb +0 -1
  23. data/lib/watir/elements/checkbox.rb +5 -7
  24. data/lib/watir/elements/date_field.rb +5 -9
  25. data/lib/watir/elements/date_time_field.rb +6 -10
  26. data/lib/watir/elements/dlist.rb +2 -4
  27. data/lib/watir/elements/element.rb +201 -99
  28. data/lib/watir/elements/file_field.rb +3 -4
  29. data/lib/watir/elements/font.rb +2 -4
  30. data/lib/watir/elements/form.rb +0 -2
  31. data/lib/watir/elements/hidden.rb +3 -4
  32. data/lib/watir/elements/html_elements.rb +24 -76
  33. data/lib/watir/elements/iframe.rb +57 -71
  34. data/lib/watir/elements/image.rb +3 -4
  35. data/lib/watir/elements/input.rb +0 -2
  36. data/lib/watir/elements/link.rb +2 -5
  37. data/lib/watir/elements/list.rb +4 -4
  38. data/lib/watir/elements/option.rb +3 -6
  39. data/lib/watir/elements/radio.rb +4 -6
  40. data/lib/watir/elements/row.rb +0 -1
  41. data/lib/watir/elements/select.rb +41 -43
  42. data/lib/watir/elements/svg_elements.rb +0 -116
  43. data/lib/watir/elements/table.rb +1 -2
  44. data/lib/watir/elements/table_cell.rb +2 -3
  45. data/lib/watir/elements/text_field.rb +4 -6
  46. data/lib/watir/exception.rb +0 -1
  47. data/lib/watir/extensions/nokogiri.rb +2 -4
  48. data/lib/watir/generator.rb +3 -3
  49. data/lib/watir/generator/base.rb +10 -10
  50. data/lib/watir/generator/base/generator.rb +26 -29
  51. data/lib/watir/generator/base/idl_sorter.rb +34 -32
  52. data/lib/watir/generator/base/spec_extractor.rb +132 -114
  53. data/lib/watir/generator/base/util.rb +1 -3
  54. data/lib/watir/generator/base/visitor.rb +140 -140
  55. data/lib/watir/generator/html.rb +4 -4
  56. data/lib/watir/generator/html/generator.rb +2 -4
  57. data/lib/watir/generator/html/spec_extractor.rb +33 -33
  58. data/lib/watir/generator/html/visitor.rb +14 -14
  59. data/lib/watir/generator/svg.rb +3 -3
  60. data/lib/watir/generator/svg/generator.rb +1 -3
  61. data/lib/watir/generator/svg/spec_extractor.rb +35 -35
  62. data/lib/watir/generator/svg/visitor.rb +14 -14
  63. data/lib/watir/has_window.rb +2 -4
  64. data/lib/watir/js_execution.rb +7 -9
  65. data/lib/watir/js_snippets.rb +3 -3
  66. data/lib/watir/js_snippets/attributeValues.js +11 -0
  67. data/lib/watir/legacy_wait.rb +7 -12
  68. data/lib/watir/locators.rb +9 -11
  69. data/lib/watir/locators/button/locator.rb +2 -3
  70. data/lib/watir/locators/button/selector_builder.rb +9 -9
  71. data/lib/watir/locators/button/selector_builder/xpath.rb +1 -1
  72. data/lib/watir/locators/button/validator.rb +2 -2
  73. data/lib/watir/locators/cell/locator.rb +0 -2
  74. data/lib/watir/locators/cell/selector_builder.rb +3 -5
  75. data/lib/watir/locators/element/locator.rb +85 -64
  76. data/lib/watir/locators/element/selector_builder.rb +40 -38
  77. data/lib/watir/locators/element/selector_builder/xpath.rb +20 -18
  78. data/lib/watir/locators/element/validator.rb +1 -1
  79. data/lib/watir/locators/row/locator.rb +0 -2
  80. data/lib/watir/locators/row/selector_builder.rb +6 -9
  81. data/lib/watir/locators/text_area/selector_builder.rb +1 -1
  82. data/lib/watir/locators/text_field/locator.rb +1 -3
  83. data/lib/watir/locators/text_field/selector_builder.rb +5 -5
  84. data/lib/watir/locators/text_field/selector_builder/xpath.rb +1 -1
  85. data/lib/watir/locators/text_field/validator.rb +3 -2
  86. data/lib/watir/logger.rb +11 -21
  87. data/lib/watir/navigation.rb +49 -0
  88. data/lib/watir/radio_set.rb +17 -18
  89. data/lib/watir/row_container.rb +3 -5
  90. data/lib/watir/screenshot.rb +2 -4
  91. data/lib/watir/user_editable.rb +13 -8
  92. data/lib/watir/version.rb +3 -0
  93. data/lib/watir/wait.rb +56 -55
  94. data/lib/watir/wait/timer.rb +1 -3
  95. data/lib/watir/window.rb +36 -45
  96. data/lib/watir/xpath_support.rb +1 -3
  97. data/lib/watirspec.rb +11 -11
  98. data/lib/watirspec/guards.rb +10 -7
  99. data/lib/watirspec/implementation.rb +3 -4
  100. data/lib/watirspec/rake_tasks.rb +30 -29
  101. data/lib/watirspec/remote_server.rb +3 -3
  102. data/lib/watirspec/runner.rb +1 -2
  103. data/lib/watirspec/server.rb +3 -0
  104. data/lib/watirspec/server/app.rb +14 -6
  105. data/spec/implementation_spec.rb +9 -9
  106. data/spec/locator_spec_helper.rb +3 -4
  107. data/spec/spec_helper.rb +3 -7
  108. data/spec/unit/container_spec.rb +9 -10
  109. data/spec/unit/element_locator_spec.rb +224 -219
  110. data/spec/unit/logger_spec.rb +4 -4
  111. data/spec/unit/unit_helper.rb +0 -2
  112. data/spec/unit/wait_spec.rb +26 -28
  113. data/spec/watirspec/adjacent_spec.rb +130 -130
  114. data/spec/watirspec/after_hooks_spec.rb +63 -63
  115. data/spec/watirspec/alert_spec.rb +6 -6
  116. data/spec/watirspec/attributes_spec.rb +6 -6
  117. data/spec/watirspec/browser_spec.rb +161 -162
  118. data/spec/watirspec/click_spec.rb +9 -9
  119. data/spec/watirspec/cookies_spec.rb +15 -14
  120. data/spec/watirspec/drag_and_drop_spec.rb +15 -16
  121. data/spec/watirspec/element_hidden_spec.rb +19 -21
  122. data/spec/watirspec/elements/area_spec.rb +18 -21
  123. data/spec/watirspec/elements/areas_spec.rb +13 -15
  124. data/spec/watirspec/elements/button_spec.rb +96 -99
  125. data/spec/watirspec/elements/buttons_spec.rb +17 -19
  126. data/spec/watirspec/elements/checkbox_spec.rb +102 -100
  127. data/spec/watirspec/elements/checkboxes_spec.rb +13 -15
  128. data/spec/watirspec/elements/collections_spec.rb +35 -37
  129. data/spec/watirspec/elements/date_field_spec.rb +46 -47
  130. data/spec/watirspec/elements/date_fields_spec.rb +13 -15
  131. data/spec/watirspec/elements/date_time_field_spec.rb +62 -57
  132. data/spec/watirspec/elements/date_time_fields_spec.rb +14 -15
  133. data/spec/watirspec/elements/dd_spec.rb +46 -48
  134. data/spec/watirspec/elements/dds_spec.rb +13 -15
  135. data/spec/watirspec/elements/del_spec.rb +27 -28
  136. data/spec/watirspec/elements/dels_spec.rb +13 -15
  137. data/spec/watirspec/elements/div_spec.rb +89 -91
  138. data/spec/watirspec/elements/divs_spec.rb +17 -19
  139. data/spec/watirspec/elements/dl_spec.rb +52 -54
  140. data/spec/watirspec/elements/dls_spec.rb +13 -15
  141. data/spec/watirspec/elements/dt_spec.rb +46 -48
  142. data/spec/watirspec/elements/dts_spec.rb +13 -15
  143. data/spec/watirspec/elements/element_spec.rb +240 -189
  144. data/spec/watirspec/elements/elements_spec.rb +16 -16
  145. data/spec/watirspec/elements/em_spec.rb +38 -40
  146. data/spec/watirspec/elements/ems_spec.rb +13 -15
  147. data/spec/watirspec/elements/filefield_spec.rb +45 -46
  148. data/spec/watirspec/elements/filefields_spec.rb +13 -15
  149. data/spec/watirspec/elements/font_spec.rb +11 -13
  150. data/spec/watirspec/elements/form_spec.rb +13 -15
  151. data/spec/watirspec/elements/forms_spec.rb +13 -15
  152. data/spec/watirspec/elements/frame_spec.rb +48 -50
  153. data/spec/watirspec/elements/frames_spec.rb +13 -15
  154. data/spec/watirspec/elements/hidden_spec.rb +23 -25
  155. data/spec/watirspec/elements/hiddens_spec.rb +13 -15
  156. data/spec/watirspec/elements/hn_spec.rb +22 -24
  157. data/spec/watirspec/elements/hns_spec.rb +13 -13
  158. data/spec/watirspec/elements/iframe_spec.rb +106 -74
  159. data/spec/watirspec/elements/iframes_spec.rb +16 -18
  160. data/spec/watirspec/elements/image_spec.rb +30 -32
  161. data/spec/watirspec/elements/images_spec.rb +13 -15
  162. data/spec/watirspec/elements/input_spec.rb +4 -5
  163. data/spec/watirspec/elements/ins_spec.rb +27 -29
  164. data/spec/watirspec/elements/inses_spec.rb +13 -15
  165. data/spec/watirspec/elements/label_spec.rb +17 -19
  166. data/spec/watirspec/elements/labels_spec.rb +13 -15
  167. data/spec/watirspec/elements/li_spec.rb +23 -25
  168. data/spec/watirspec/elements/link_spec.rb +45 -48
  169. data/spec/watirspec/elements/links_spec.rb +14 -16
  170. data/spec/watirspec/elements/lis_spec.rb +13 -15
  171. data/spec/watirspec/elements/list_spec.rb +14 -15
  172. data/spec/watirspec/elements/map_spec.rb +19 -20
  173. data/spec/watirspec/elements/maps_spec.rb +13 -15
  174. data/spec/watirspec/elements/meta_spec.rb +10 -10
  175. data/spec/watirspec/elements/metas_spec.rb +13 -15
  176. data/spec/watirspec/elements/ol_spec.rb +20 -21
  177. data/spec/watirspec/elements/ols_spec.rb +13 -15
  178. data/spec/watirspec/elements/option_spec.rb +63 -63
  179. data/spec/watirspec/elements/p_spec.rb +27 -26
  180. data/spec/watirspec/elements/pre_spec.rb +24 -25
  181. data/spec/watirspec/elements/pres_spec.rb +13 -15
  182. data/spec/watirspec/elements/ps_spec.rb +13 -15
  183. data/spec/watirspec/elements/radio_spec.rb +96 -97
  184. data/spec/watirspec/elements/radios_spec.rb +13 -15
  185. data/spec/watirspec/elements/select_list_spec.rb +244 -237
  186. data/spec/watirspec/elements/select_lists_spec.rb +15 -16
  187. data/spec/watirspec/elements/span_spec.rb +32 -31
  188. data/spec/watirspec/elements/spans_spec.rb +13 -15
  189. data/spec/watirspec/elements/strong_spec.rb +23 -24
  190. data/spec/watirspec/elements/strongs_spec.rb +13 -15
  191. data/spec/watirspec/elements/table_nesting_spec.rb +15 -14
  192. data/spec/watirspec/elements/table_spec.rb +61 -62
  193. data/spec/watirspec/elements/tables_spec.rb +15 -17
  194. data/spec/watirspec/elements/tbody_spec.rb +25 -26
  195. data/spec/watirspec/elements/tbodys_spec.rb +17 -19
  196. data/spec/watirspec/elements/td_spec.rb +20 -22
  197. data/spec/watirspec/elements/tds_spec.rb +9 -11
  198. data/spec/watirspec/elements/text_field_spec.rb +55 -56
  199. data/spec/watirspec/elements/text_fields_spec.rb +15 -16
  200. data/spec/watirspec/elements/textarea_spec.rb +2 -2
  201. data/spec/watirspec/elements/textareas_spec.rb +1 -1
  202. data/spec/watirspec/elements/tfoot_spec.rb +22 -23
  203. data/spec/watirspec/elements/tfoots_spec.rb +19 -19
  204. data/spec/watirspec/elements/thead_spec.rb +21 -23
  205. data/spec/watirspec/elements/theads_spec.rb +19 -19
  206. data/spec/watirspec/elements/tr_spec.rb +20 -22
  207. data/spec/watirspec/elements/trs_spec.rb +17 -19
  208. data/spec/watirspec/elements/ul_spec.rb +17 -19
  209. data/spec/watirspec/elements/uls_spec.rb +13 -14
  210. data/spec/watirspec/html/data_attributes.html +1 -0
  211. data/spec/watirspec/radio_set_spec.rb +100 -99
  212. data/spec/watirspec/relaxed_locate_spec.rb +19 -43
  213. data/spec/watirspec/screenshot_spec.rb +4 -4
  214. data/spec/watirspec/special_chars_spec.rb +2 -4
  215. data/spec/watirspec/support/rspec_matchers.rb +85 -22
  216. data/spec/watirspec/user_editable_spec.rb +84 -85
  217. data/spec/watirspec/wait_spec.rb +74 -95
  218. data/spec/watirspec/window_switching_spec.rb +131 -132
  219. data/spec/watirspec_helper.rb +12 -9
  220. data/support/travis.sh +4 -0
  221. data/support/version_differ.rb +12 -13
  222. data/watir.gemspec +29 -22
  223. metadata +76 -50
@@ -1,17 +1,16 @@
1
- require "watirspec_helper"
2
-
3
- describe "Label" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'Label' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
5
+ browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
7
6
  end
8
7
 
9
8
  # Exists method
10
- describe "#exists?" do
11
- it "returns true if the element exists" do
9
+ describe '#exists?' do
10
+ it 'returns true if the element exists' do
12
11
  expect(browser.label(id: 'first_label')).to exist
13
12
  expect(browser.label(id: /first_label/)).to exist
14
- expect(browser.label(for: "new_user_first_name")).to exist
13
+ expect(browser.label(for: 'new_user_first_name')).to exist
15
14
  expect(browser.label(for: /new_user_first_name/)).to exist
16
15
  expect(browser.label(text: 'First name')).to exist
17
16
  expect(browser.label(text: /First name/)).to exist
@@ -19,11 +18,11 @@ describe "Label" do
19
18
  expect(browser.label(xpath: "//label[@id='first_label']")).to exist
20
19
  end
21
20
 
22
- it "returns the first label if given no args" do
21
+ it 'returns the first label if given no args' do
23
22
  expect(browser.label).to exist
24
23
  end
25
24
 
26
- it "returns false if the element does not exist" do
25
+ it 'returns false if the element does not exist' do
27
26
  expect(browser.label(id: 'no_such_id')).to_not exist
28
27
  expect(browser.label(id: /no_such_id/)).to_not exist
29
28
  expect(browser.label(text: 'no_such_text')).to_not exist
@@ -37,17 +36,17 @@ describe "Label" do
37
36
  end
38
37
  end
39
38
 
40
- describe "click" do
41
- it "fires the onclick event" do
39
+ describe 'click' do
40
+ it 'fires the onclick event' do
42
41
  browser.label(id: 'first_label').click
43
42
  expect(messages.first).to eq 'label'
44
43
  end
45
44
  end
46
45
 
47
46
  # Attribute methods
48
- describe "#id" do
49
- it "returns the id attribute if the label exists" do
50
- expect(browser.label(index: 0).id).to eq "first_label"
47
+ describe '#id' do
48
+ it 'returns the id attribute if the label exists' do
49
+ expect(browser.label(index: 0).id).to eq 'first_label'
51
50
  end
52
51
 
53
52
  it "raises UnknownObjectException if the label doesn't exist" do
@@ -55,9 +54,9 @@ describe "Label" do
55
54
  end
56
55
  end
57
56
 
58
- describe "#for" do
57
+ describe '#for' do
59
58
  it "returns the 'for' attribute if the label exists" do
60
- expect(browser.label(index: 0).for).to eq "new_user_first_name"
59
+ expect(browser.label(index: 0).for).to eq 'new_user_first_name'
61
60
  end
62
61
 
63
62
  it "raises UnknownObjectException if the label doesn't exist" do
@@ -65,11 +64,10 @@ describe "Label" do
65
64
  end
66
65
  end
67
66
 
68
- describe "#respond_to?" do
69
- it "returns true for all attribute methods" do
67
+ describe '#respond_to?' do
68
+ it 'returns true for all attribute methods' do
70
69
  expect(browser.label(index: 0)).to respond_to(:id)
71
70
  expect(browser.label(index: 0)).to respond_to(:for)
72
71
  end
73
72
  end
74
-
75
73
  end
@@ -1,31 +1,30 @@
1
- require "watirspec_helper"
2
-
3
- describe "Labels" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'Labels' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
5
+ browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
7
6
  end
8
7
 
9
- describe "with selectors" do
10
- it "returns the matching elements" do
11
- expect(browser.labels(for: "new_user_first_name").to_a).to eq [browser.label(for: "new_user_first_name")]
8
+ describe 'with selectors' do
9
+ it 'returns the matching elements' do
10
+ expect(browser.labels(for: 'new_user_first_name').to_a).to eq [browser.label(for: 'new_user_first_name')]
12
11
  end
13
12
  end
14
13
 
15
- describe "#length" do
16
- it "returns the number of labels" do
14
+ describe '#length' do
15
+ it 'returns the number of labels' do
17
16
  expect(browser.labels.length).to eq 41
18
17
  end
19
18
  end
20
19
 
21
- describe "#[]" do
22
- it "returns the label at the given index" do
23
- expect(browser.labels[0].id).to eq "first_label"
20
+ describe '#[]' do
21
+ it 'returns the label at the given index' do
22
+ expect(browser.labels[0].id).to eq 'first_label'
24
23
  end
25
24
  end
26
25
 
27
- describe "#each" do
28
- it "iterates through labels correctly" do
26
+ describe '#each' do
27
+ it 'iterates through labels correctly' do
29
28
  count = 0
30
29
 
31
30
  browser.labels.each_with_index do |l, index|
@@ -36,5 +35,4 @@ describe "Labels" do
36
35
  expect(count).to be > 0
37
36
  end
38
37
  end
39
-
40
38
  end
@@ -1,34 +1,33 @@
1
- require "watirspec_helper"
2
-
3
- describe "Li" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'Li' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("non_control_elements.html"))
5
+ browser.goto(WatirSpec.url_for('non_control_elements.html'))
7
6
  end
8
7
 
9
8
  # Exists method
10
- describe "#exist?" do
9
+ describe '#exist?' do
11
10
  it "returns true if the 'li' exists" do
12
- expect(browser.li(id: "non_link_1")).to exist
11
+ expect(browser.li(id: 'non_link_1')).to exist
13
12
  expect(browser.li(id: /non_link_1/)).to exist
14
- expect(browser.li(text: "Non-link 3")).to exist
13
+ expect(browser.li(text: 'Non-link 3')).to exist
15
14
  expect(browser.li(text: /Non-link 3/)).to exist
16
- expect(browser.li(class: "nonlink")).to exist
15
+ expect(browser.li(class: 'nonlink')).to exist
17
16
  expect(browser.li(class: /nonlink/)).to exist
18
17
  expect(browser.li(index: 0)).to exist
19
18
  expect(browser.li(xpath: "//li[@id='non_link_1']")).to exist
20
19
  end
21
20
 
22
- it "returns the first element if given no args" do
21
+ it 'returns the first element if given no args' do
23
22
  expect(browser.li).to exist
24
23
  end
25
24
 
26
25
  it "returns false if the 'li' doesn't exist" do
27
- expect(browser.li(id: "no_such_id")).to_not exist
26
+ expect(browser.li(id: 'no_such_id')).to_not exist
28
27
  expect(browser.li(id: /no_such_id/)).to_not exist
29
- expect(browser.li(text: "no_such_text")).to_not exist
28
+ expect(browser.li(text: 'no_such_text')).to_not exist
30
29
  expect(browser.li(text: /no_such_text/)).to_not exist
31
- expect(browser.li(class: "no_such_class")).to_not exist
30
+ expect(browser.li(class: 'no_such_class')).to_not exist
32
31
  expect(browser.li(class: /no_such_class/)).to_not exist
33
32
  expect(browser.li(index: 1337)).to_not exist
34
33
  expect(browser.li(xpath: "//li[@id='no_such_id']")).to_not exist
@@ -40,8 +39,8 @@ describe "Li" do
40
39
  end
41
40
 
42
41
  # Attribute methods
43
- describe "#class_name" do
44
- it "returns the class attribute" do
42
+ describe '#class_name' do
43
+ it 'returns the class attribute' do
45
44
  expect(browser.li(id: 'non_link_1').class_name).to eq 'nonlink'
46
45
  end
47
46
 
@@ -54,9 +53,9 @@ describe "Li" do
54
53
  end
55
54
  end
56
55
 
57
- describe "#id" do
58
- it "returns the id attribute" do
59
- expect(browser.li(class: 'nonlink').id).to eq "non_link_1"
56
+ describe '#id' do
57
+ it 'returns the id attribute' do
58
+ expect(browser.li(class: 'nonlink').id).to eq 'non_link_1'
60
59
  end
61
60
 
62
61
  it "returns an empty string if the element exists and the attribute doesn't" do
@@ -64,13 +63,13 @@ describe "Li" do
64
63
  end
65
64
 
66
65
  it "raises UnknownObjectException if the li doesn't exist" do
67
- expect { browser.li(id: "no_such_id").id }.to raise_unknown_object_exception
66
+ expect { browser.li(id: 'no_such_id').id }.to raise_unknown_object_exception
68
67
  expect { browser.li(index: 1337).id }.to raise_unknown_object_exception
69
68
  end
70
69
  end
71
70
 
72
- describe "#title" do
73
- it "returns the title attribute" do
71
+ describe '#title' do
72
+ it 'returns the title attribute' do
74
73
  expect(browser.li(id: 'non_link_1').title).to eq 'This is not a link!'
75
74
  end
76
75
 
@@ -84,8 +83,8 @@ describe "Li" do
84
83
  end
85
84
  end
86
85
 
87
- describe "#text" do
88
- it "returns the text of the li" do
86
+ describe '#text' do
87
+ it 'returns the text of the li' do
89
88
  expect(browser.li(id: 'non_link_1').text).to eq 'Non-link 1'
90
89
  end
91
90
 
@@ -99,13 +98,12 @@ describe "Li" do
99
98
  end
100
99
  end
101
100
 
102
- describe "#respond_to?" do
103
- it "returns true for all attribute methods" do
101
+ describe '#respond_to?' do
102
+ it 'returns true for all attribute methods' do
104
103
  expect(browser.li(index: 0)).to respond_to(:class_name)
105
104
  expect(browser.li(index: 0)).to respond_to(:id)
106
105
  expect(browser.li(index: 0)).to respond_to(:text)
107
106
  expect(browser.li(index: 0)).to respond_to(:title)
108
107
  end
109
108
  end
110
-
111
109
  end
@@ -1,19 +1,18 @@
1
- require "watirspec_helper"
2
-
3
- describe "Link" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'Link' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("non_control_elements.html"))
5
+ browser.goto(WatirSpec.url_for('non_control_elements.html'))
7
6
  end
8
7
 
9
8
  # Exists method
10
- describe "#exist?" do
11
- it "returns true if the link exists" do
9
+ describe '#exist?' do
10
+ it 'returns true if the link exists' do
12
11
  expect(browser.link(id: 'link_2')).to exist
13
12
  expect(browser.link(id: /link_2/)).to exist
14
- expect(browser.link(title: "link_title_2")).to exist
13
+ expect(browser.link(title: 'link_title_2')).to exist
15
14
  expect(browser.link(title: /link_title_2/)).to exist
16
- expect(browser.link(text: "Link 2")).to exist
15
+ expect(browser.link(text: 'Link 2')).to exist
17
16
  expect(browser.link(text: /Link 2/i)).to exist
18
17
  not_compliant_on :internet_explorer do
19
18
  expect(browser.link(href: 'non_control_elements.html')).to exist
@@ -23,20 +22,20 @@ describe "Link" do
23
22
  expect(browser.link(xpath: "//a[@id='link_2']")).to exist
24
23
  end
25
24
 
26
- it "returns the first link if given no args" do
25
+ it 'returns the first link if given no args' do
27
26
  expect(browser.link).to exist
28
27
  end
29
28
 
30
- it "strips spaces from href attribute when locating elements" do
29
+ it 'strips spaces from href attribute when locating elements' do
31
30
  expect(browser.link(href: /strip_space$/)).to exist
32
31
  end
33
32
 
34
33
  it "returns false if the link doesn't exist" do
35
34
  expect(browser.link(id: 'no_such_id')).to_not exist
36
35
  expect(browser.link(id: /no_such_id/)).to_not exist
37
- expect(browser.link(title: "no_such_title")).to_not exist
36
+ expect(browser.link(title: 'no_such_title')).to_not exist
38
37
  expect(browser.link(title: /no_such_title/)).to_not exist
39
- expect(browser.link(text: "no_such_text")).to_not exist
38
+ expect(browser.link(text: 'no_such_text')).to_not exist
40
39
  expect(browser.link(text: /no_such_text/i)).to_not exist
41
40
  expect(browser.link(href: 'no_such_href')).to_not exist
42
41
  expect(browser.link(href: /no_such_href/)).to_not exist
@@ -50,9 +49,9 @@ describe "Link" do
50
49
  end
51
50
 
52
51
  # Attribute methods
53
- describe "#class_name" do
54
- it "returns the type attribute if the link exists" do
55
- expect(browser.link(index: 1).class_name).to eq "external"
52
+ describe '#class_name' do
53
+ it 'returns the type attribute if the link exists' do
54
+ expect(browser.link(index: 1).class_name).to eq 'external'
56
55
  end
57
56
 
58
57
  it "returns an empty string if the link exists and the attribute doesn't" do
@@ -64,13 +63,13 @@ describe "Link" do
64
63
  end
65
64
  end
66
65
 
67
- describe "#href" do
68
- it "returns the href attribute if the link exists" do
66
+ describe '#href' do
67
+ it 'returns the href attribute if the link exists' do
69
68
  expect(browser.link(index: 1).href).to match(/non_control_elements/)
70
69
  end
71
70
 
72
71
  it "returns an empty string if the link exists and the attribute doesn't" do
73
- expect(browser.link(index: 0).href).to eq ""
72
+ expect(browser.link(index: 0).href).to eq ''
74
73
  end
75
74
 
76
75
  it "raises an UnknownObjectException if the link doesn't exist" do
@@ -78,19 +77,19 @@ describe "Link" do
78
77
  end
79
78
  end
80
79
 
81
- describe "#href" do
82
- it "returns the href attribute" do
80
+ describe '#href' do
81
+ it 'returns the href attribute' do
83
82
  expect(browser.link(index: 1).href).to match(/non_control_elements/)
84
83
  end
85
84
  end
86
85
 
87
- describe "#id" do
88
- it "returns the id attribute if the link exists" do
89
- expect(browser.link(index: 1).id).to eq "link_2"
86
+ describe '#id' do
87
+ it 'returns the id attribute if the link exists' do
88
+ expect(browser.link(index: 1).id).to eq 'link_2'
90
89
  end
91
90
 
92
91
  it "returns an empty string if the link exists and the attribute doesn't" do
93
- expect(browser.link(index: 0).id).to eq ""
92
+ expect(browser.link(index: 0).id).to eq ''
94
93
  end
95
94
 
96
95
  it "raises an UnknownObjectException if the link doesn't exist" do
@@ -98,13 +97,13 @@ describe "Link" do
98
97
  end
99
98
  end
100
99
 
101
- describe "#text" do
102
- it "returns the link text" do
103
- expect(browser.link(index: 1).text).to eq "Link 2"
100
+ describe '#text' do
101
+ it 'returns the link text' do
102
+ expect(browser.link(index: 1).text).to eq 'Link 2'
104
103
  end
105
104
 
106
- it "returns an empty string if the link exists and contains no text" do
107
- expect(browser.link(index: 0).text).to eq ""
105
+ it 'returns an empty string if the link exists and contains no text' do
106
+ expect(browser.link(index: 0).text).to eq ''
108
107
  end
109
108
 
110
109
  it "raises an UnknownObjectException if the link doesn't exist" do
@@ -112,13 +111,13 @@ describe "Link" do
112
111
  end
113
112
  end
114
113
 
115
- describe "#title" do
116
- it "returns the type attribute if the link exists" do
117
- expect(browser.link(index: 1).title).to eq "link_title_2"
114
+ describe '#title' do
115
+ it 'returns the type attribute if the link exists' do
116
+ expect(browser.link(index: 1).title).to eq 'link_title_2'
118
117
  end
119
118
 
120
119
  it "returns an empty string if the link exists and the attribute doesn't" do
121
- expect(browser.link(index: 0).title).to eq ""
120
+ expect(browser.link(index: 0).title).to eq ''
122
121
  end
123
122
 
124
123
  it "raises an UnknownObjectException if the link doesn't exist" do
@@ -126,8 +125,8 @@ describe "Link" do
126
125
  end
127
126
  end
128
127
 
129
- describe "#respond_to?" do
130
- it "returns true for all attribute methods" do
128
+ describe '#respond_to?' do
129
+ it 'returns true for all attribute methods' do
131
130
  expect(browser.link(index: 0)).to respond_to(:class_name)
132
131
  expect(browser.link(index: 0)).to respond_to(:href)
133
132
  expect(browser.link(index: 0)).to respond_to(:id)
@@ -138,33 +137,31 @@ describe "Link" do
138
137
  end
139
138
 
140
139
  # Manipulation methods
141
- describe "#click" do
142
- it "finds an existing link by (text: String) and clicks it" do
143
- browser.link(text: "Link 3").click
144
- expect(browser.text.include?("User administration")).to be true
140
+ describe '#click' do
141
+ it 'finds an existing link by (text: String) and clicks it' do
142
+ browser.link(text: 'Link 3').click
143
+ expect(browser.text.include?('User administration')).to be true
145
144
  end
146
145
 
147
- it "finds an existing link by (text: Regexp) and clicks it" do
146
+ it 'finds an existing link by (text: Regexp) and clicks it' do
148
147
  browser.link(href: /forms_with_input_elements/).click
149
- expect(browser.text.include?("User administration")).to be true
148
+ expect(browser.text.include?('User administration')).to be true
150
149
  end
151
150
 
152
- it "finds an existing link by (index: Integer) and clicks it" do
151
+ it 'finds an existing link by (index: Integer) and clicks it' do
153
152
  browser.link(index: 2).click
154
- expect(browser.text.include?("User administration")).to be true
153
+ expect(browser.text.include?('User administration')).to be true
155
154
  end
156
155
 
157
156
  it "raises an UnknownObjectException if the link doesn't exist" do
158
157
  expect { browser.link(index: 1337).click }.to raise_unknown_object_exception
159
158
  end
160
159
 
161
- it "clicks a link with no text content but an img child" do
162
- browser.goto WatirSpec.url_for("images.html")
160
+ it 'clicks a link with no text content but an img child' do
161
+ browser.goto WatirSpec.url_for('images.html')
163
162
  browser.link(href: /definition_lists.html/).click
164
- Watir::Wait.while { browser.title == "Images" || browser.title == ""}
163
+ Watir::Wait.while { browser.title == 'Images' || browser.title == '' }
165
164
  expect(browser.title).to eq 'definition_lists'
166
165
  end
167
-
168
166
  end
169
-
170
167
  end
@@ -1,35 +1,34 @@
1
- require "watirspec_helper"
2
-
3
- describe "Links" do
1
+ require 'watirspec_helper'
4
2
 
3
+ describe 'Links' do
5
4
  before :each do
6
- browser.goto(WatirSpec.url_for("non_control_elements.html"))
5
+ browser.goto(WatirSpec.url_for('non_control_elements.html'))
7
6
  end
8
7
 
9
- describe "with selectors" do
10
- it "returns the matching elements" do
11
- expect(browser.links(title: "link_title_2").to_a).to eq [browser.link(title: "link_title_2")]
8
+ describe 'with selectors' do
9
+ it 'returns the matching elements' do
10
+ expect(browser.links(title: 'link_title_2').to_a).to eq [browser.link(title: 'link_title_2')]
12
11
  end
13
12
  end
14
13
 
15
- describe "#length" do
16
- it "returns the number of links" do
14
+ describe '#length' do
15
+ it 'returns the number of links' do
17
16
  expect(browser.links.length).to eq 7
18
17
  end
19
18
  end
20
19
 
21
- describe "#[]" do
22
- it "returns the link at the given index" do
23
- expect(browser.links[2].id).to eq "link_3"
20
+ describe '#[]' do
21
+ it 'returns the link at the given index' do
22
+ expect(browser.links[2].id).to eq 'link_3'
24
23
  end
25
24
 
26
- it "returns a Link object also when the index is out of bounds" do
25
+ it 'returns a Link object also when the index is out of bounds' do
27
26
  expect(browser.links[2000]).to_not be_nil
28
27
  end
29
28
  end
30
29
 
31
- describe "#each" do
32
- it "iterates through links correctly" do
30
+ describe '#each' do
31
+ it 'iterates through links correctly' do
33
32
  count = 0
34
33
 
35
34
  browser.links.each_with_index do |c, index|
@@ -40,5 +39,4 @@ describe "Links" do
40
39
  expect(count).to be > 0
41
40
  end
42
41
  end
43
-
44
42
  end