watir 7.1.0 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (253) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/chrome.yml +29 -16
  3. data/.github/workflows/edge.yml +19 -11
  4. data/.github/workflows/firefox.yml +28 -16
  5. data/.github/workflows/ie.yml +13 -7
  6. data/.github/workflows/safari.yml +22 -11
  7. data/.github/workflows/unit.yml +31 -23
  8. data/.rubocop.yml +14 -7
  9. data/.rubocop_todo.yml +0 -26
  10. data/CHANGES.md +16 -1
  11. data/Gemfile +6 -1
  12. data/README.md +15 -11
  13. data/Rakefile +9 -7
  14. data/lib/watir/adjacent.rb +3 -1
  15. data/lib/watir/after_hooks.rb +5 -3
  16. data/lib/watir/alert.rb +2 -0
  17. data/lib/watir/aliases.rb +2 -0
  18. data/lib/watir/attribute_helper.rb +4 -2
  19. data/lib/watir/browser.rb +10 -14
  20. data/lib/watir/capabilities.rb +56 -33
  21. data/lib/watir/cell_container.rb +2 -0
  22. data/lib/watir/container.rb +2 -0
  23. data/lib/watir/cookies.rb +5 -5
  24. data/lib/watir/element_collection.rb +3 -1
  25. data/lib/watir/elements/button.rb +2 -0
  26. data/lib/watir/elements/cell.rb +2 -0
  27. data/lib/watir/elements/checkbox.rb +2 -0
  28. data/lib/watir/elements/date_field.rb +2 -0
  29. data/lib/watir/elements/date_time_field.rb +2 -0
  30. data/lib/watir/elements/dlist.rb +3 -1
  31. data/lib/watir/elements/element.rb +29 -105
  32. data/lib/watir/elements/file_field.rb +2 -0
  33. data/lib/watir/elements/font.rb +2 -0
  34. data/lib/watir/elements/form.rb +2 -0
  35. data/lib/watir/elements/hidden.rb +2 -0
  36. data/lib/watir/elements/iframe.rb +2 -0
  37. data/lib/watir/elements/image.rb +2 -0
  38. data/lib/watir/elements/input.rb +2 -0
  39. data/lib/watir/elements/link.rb +2 -0
  40. data/lib/watir/elements/list.rb +2 -0
  41. data/lib/watir/elements/option.rb +2 -0
  42. data/lib/watir/elements/radio.rb +2 -0
  43. data/lib/watir/elements/row.rb +2 -0
  44. data/lib/watir/elements/select.rb +2 -0
  45. data/lib/watir/elements/table.rb +3 -1
  46. data/lib/watir/elements/table_cell.rb +2 -0
  47. data/lib/watir/elements/table_row.rb +2 -0
  48. data/lib/watir/elements/table_section.rb +2 -0
  49. data/lib/watir/elements/text_area.rb +2 -0
  50. data/lib/watir/elements/text_field.rb +2 -0
  51. data/lib/watir/exception.rb +2 -0
  52. data/lib/watir/extensions/nokogiri.rb +2 -0
  53. data/lib/watir/generator/base/generator.rb +2 -0
  54. data/lib/watir/generator/base/idl_sorter.rb +3 -1
  55. data/lib/watir/generator/base/spec_extractor.rb +6 -4
  56. data/lib/watir/generator/base/util.rb +2 -0
  57. data/lib/watir/generator/base/visitor.rb +5 -5
  58. data/lib/watir/generator/base.rb +2 -1
  59. data/lib/watir/generator/html/generator.rb +2 -0
  60. data/lib/watir/generator/html/spec_extractor.rb +2 -0
  61. data/lib/watir/generator/html/visitor.rb +2 -0
  62. data/lib/watir/generator/html.rb +2 -0
  63. data/lib/watir/generator/svg/generator.rb +2 -0
  64. data/lib/watir/generator/svg/spec_extractor.rb +2 -0
  65. data/lib/watir/generator/svg/visitor.rb +2 -0
  66. data/lib/watir/generator/svg.rb +2 -0
  67. data/lib/watir/generator.rb +2 -0
  68. data/lib/watir/has_window.rb +3 -1
  69. data/lib/watir/http_client.rb +2 -0
  70. data/lib/watir/js_execution.rb +2 -0
  71. data/lib/watir/js_snippets.rb +2 -0
  72. data/lib/watir/locators/anchor/selector_builder.rb +2 -0
  73. data/lib/watir/locators/button/matcher.rb +2 -0
  74. data/lib/watir/locators/button/selector_builder/xpath.rb +15 -19
  75. data/lib/watir/locators/button/selector_builder.rb +2 -0
  76. data/lib/watir/locators/cell/selector_builder/xpath.rb +2 -0
  77. data/lib/watir/locators/cell/selector_builder.rb +2 -0
  78. data/lib/watir/locators/element/locator.rb +2 -0
  79. data/lib/watir/locators/element/matcher.rb +2 -0
  80. data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +2 -0
  81. data/lib/watir/locators/element/selector_builder/xpath.rb +16 -15
  82. data/lib/watir/locators/element/selector_builder/xpath_support.rb +4 -2
  83. data/lib/watir/locators/element/selector_builder.rb +16 -6
  84. data/lib/watir/locators/option/matcher.rb +2 -0
  85. data/lib/watir/locators/option/selector_builder/xpath.rb +2 -0
  86. data/lib/watir/locators/option/selector_builder.rb +2 -0
  87. data/lib/watir/locators/row/selector_builder/xpath.rb +2 -0
  88. data/lib/watir/locators/row/selector_builder.rb +2 -0
  89. data/lib/watir/locators/text_area/selector_builder/xpath.rb +2 -0
  90. data/lib/watir/locators/text_area/selector_builder.rb +2 -0
  91. data/lib/watir/locators/text_field/matcher.rb +2 -0
  92. data/lib/watir/locators/text_field/selector_builder/xpath.rb +2 -0
  93. data/lib/watir/locators/text_field/selector_builder.rb +2 -0
  94. data/lib/watir/locators.rb +2 -0
  95. data/lib/watir/logger.rb +2 -0
  96. data/lib/watir/navigation.rb +3 -1
  97. data/lib/watir/radio_set.rb +2 -0
  98. data/lib/watir/row_container.rb +2 -0
  99. data/lib/watir/screenshot.rb +2 -0
  100. data/lib/watir/scroll.rb +27 -2
  101. data/lib/watir/search_context.rb +96 -0
  102. data/lib/watir/shadow_root.rb +60 -0
  103. data/lib/watir/user_editable.rb +3 -1
  104. data/lib/watir/version.rb +3 -1
  105. data/lib/watir/wait/timer.rb +3 -1
  106. data/lib/watir/wait.rb +5 -5
  107. data/lib/watir/window.rb +7 -3
  108. data/lib/watir/window_collection.rb +4 -1
  109. data/lib/watir.rb +4 -0
  110. data/lib/watirspec/guards.rb +2 -0
  111. data/lib/watirspec/implementation.rb +14 -10
  112. data/lib/watirspec/rake_tasks.rb +4 -4
  113. data/lib/watirspec/remote_server.rb +5 -3
  114. data/lib/watirspec/runner.rb +3 -1
  115. data/lib/watirspec/server/app.rb +2 -0
  116. data/lib/watirspec/server.rb +2 -0
  117. data/lib/watirspec.rb +7 -4
  118. data/spec/locator_spec_helper.rb +2 -0
  119. data/spec/spec_helper.rb +2 -0
  120. data/spec/unit/capabilities_spec.rb +77 -58
  121. data/spec/unit/element_locator_spec.rb +2 -0
  122. data/spec/unit/match_elements/button_spec.rb +2 -0
  123. data/spec/unit/match_elements/element_spec.rb +10 -8
  124. data/spec/unit/match_elements/text_field_spec.rb +2 -0
  125. data/spec/unit/selector_builder/anchor_spec.rb +2 -0
  126. data/spec/unit/selector_builder/button_spec.rb +31 -28
  127. data/spec/unit/selector_builder/cell_spec.rb +3 -1
  128. data/spec/unit/selector_builder/element_spec.rb +61 -60
  129. data/spec/unit/selector_builder/row_spec.rb +21 -10
  130. data/spec/unit/selector_builder/text_field_spec.rb +29 -21
  131. data/spec/unit/selector_builder/textarea_spec.rb +2 -0
  132. data/spec/unit/unit_helper.rb +2 -0
  133. data/spec/unit/wait_spec.rb +2 -0
  134. data/spec/watirspec/adjacent_spec.rb +8 -6
  135. data/spec/watirspec/after_hooks_spec.rb +19 -21
  136. data/spec/watirspec/alert_spec.rb +2 -0
  137. data/spec/watirspec/attributes_spec.rb +2 -0
  138. data/spec/watirspec/browser_spec.rb +16 -12
  139. data/spec/watirspec/capabilities_spec.rb +569 -0
  140. data/spec/watirspec/cookies_spec.rb +4 -2
  141. data/spec/watirspec/drag_and_drop_spec.rb +2 -0
  142. data/spec/watirspec/element_hidden_spec.rb +2 -0
  143. data/spec/watirspec/elements/area_spec.rb +2 -0
  144. data/spec/watirspec/elements/areas_spec.rb +2 -0
  145. data/spec/watirspec/elements/button_spec.rb +2 -0
  146. data/spec/watirspec/elements/buttons_spec.rb +2 -0
  147. data/spec/watirspec/elements/checkbox_spec.rb +2 -0
  148. data/spec/watirspec/elements/checkboxes_spec.rb +2 -0
  149. data/spec/watirspec/elements/collections_spec.rb +5 -3
  150. data/spec/watirspec/elements/date_field_spec.rb +2 -0
  151. data/spec/watirspec/elements/date_fields_spec.rb +2 -0
  152. data/spec/watirspec/elements/date_time_field_spec.rb +2 -0
  153. data/spec/watirspec/elements/date_time_fields_spec.rb +2 -0
  154. data/spec/watirspec/elements/dd_spec.rb +2 -0
  155. data/spec/watirspec/elements/dds_spec.rb +2 -0
  156. data/spec/watirspec/elements/del_spec.rb +2 -0
  157. data/spec/watirspec/elements/dels_spec.rb +2 -0
  158. data/spec/watirspec/elements/div_spec.rb +2 -1
  159. data/spec/watirspec/elements/divs_spec.rb +2 -0
  160. data/spec/watirspec/elements/dl_spec.rb +6 -6
  161. data/spec/watirspec/elements/dls_spec.rb +2 -0
  162. data/spec/watirspec/elements/dt_spec.rb +2 -0
  163. data/spec/watirspec/elements/dts_spec.rb +2 -0
  164. data/spec/watirspec/elements/element_spec.rb +9 -1
  165. data/spec/watirspec/elements/elements_spec.rb +2 -0
  166. data/spec/watirspec/elements/em_spec.rb +2 -0
  167. data/spec/watirspec/elements/ems_spec.rb +2 -0
  168. data/spec/watirspec/elements/filefield_spec.rb +2 -0
  169. data/spec/watirspec/elements/filefields_spec.rb +2 -0
  170. data/spec/watirspec/elements/font_spec.rb +2 -0
  171. data/spec/watirspec/elements/form_spec.rb +2 -0
  172. data/spec/watirspec/elements/forms_spec.rb +2 -0
  173. data/spec/watirspec/elements/frame_spec.rb +2 -0
  174. data/spec/watirspec/elements/frames_spec.rb +2 -0
  175. data/spec/watirspec/elements/hidden_spec.rb +2 -0
  176. data/spec/watirspec/elements/hiddens_spec.rb +2 -0
  177. data/spec/watirspec/elements/hn_spec.rb +2 -0
  178. data/spec/watirspec/elements/hns_spec.rb +2 -0
  179. data/spec/watirspec/elements/iframe_spec.rb +3 -1
  180. data/spec/watirspec/elements/iframes_spec.rb +2 -0
  181. data/spec/watirspec/elements/image_spec.rb +2 -0
  182. data/spec/watirspec/elements/images_spec.rb +2 -0
  183. data/spec/watirspec/elements/input_spec.rb +2 -0
  184. data/spec/watirspec/elements/ins_spec.rb +2 -0
  185. data/spec/watirspec/elements/inses_spec.rb +2 -0
  186. data/spec/watirspec/elements/label_spec.rb +2 -0
  187. data/spec/watirspec/elements/labels_spec.rb +2 -0
  188. data/spec/watirspec/elements/li_spec.rb +2 -0
  189. data/spec/watirspec/elements/link_spec.rb +4 -4
  190. data/spec/watirspec/elements/links_spec.rb +2 -0
  191. data/spec/watirspec/elements/lis_spec.rb +2 -0
  192. data/spec/watirspec/elements/list_spec.rb +2 -0
  193. data/spec/watirspec/elements/map_spec.rb +2 -0
  194. data/spec/watirspec/elements/maps_spec.rb +2 -0
  195. data/spec/watirspec/elements/meta_spec.rb +2 -0
  196. data/spec/watirspec/elements/metas_spec.rb +2 -0
  197. data/spec/watirspec/elements/ol_spec.rb +2 -0
  198. data/spec/watirspec/elements/ols_spec.rb +2 -0
  199. data/spec/watirspec/elements/option_spec.rb +2 -0
  200. data/spec/watirspec/elements/p_spec.rb +2 -0
  201. data/spec/watirspec/elements/pre_spec.rb +2 -0
  202. data/spec/watirspec/elements/pres_spec.rb +2 -0
  203. data/spec/watirspec/elements/ps_spec.rb +2 -0
  204. data/spec/watirspec/elements/radio_spec.rb +2 -0
  205. data/spec/watirspec/elements/radios_spec.rb +2 -0
  206. data/spec/watirspec/elements/select_list_spec.rb +7 -1
  207. data/spec/watirspec/elements/select_lists_spec.rb +2 -0
  208. data/spec/watirspec/elements/span_spec.rb +2 -0
  209. data/spec/watirspec/elements/spans_spec.rb +2 -0
  210. data/spec/watirspec/elements/strong_spec.rb +2 -0
  211. data/spec/watirspec/elements/strongs_spec.rb +2 -0
  212. data/spec/watirspec/elements/table_nesting_spec.rb +2 -0
  213. data/spec/watirspec/elements/table_spec.rb +2 -0
  214. data/spec/watirspec/elements/tables_spec.rb +2 -0
  215. data/spec/watirspec/elements/tbody_spec.rb +2 -0
  216. data/spec/watirspec/elements/tbodys_spec.rb +2 -0
  217. data/spec/watirspec/elements/td_spec.rb +2 -0
  218. data/spec/watirspec/elements/tds_spec.rb +2 -0
  219. data/spec/watirspec/elements/text_field_spec.rb +2 -0
  220. data/spec/watirspec/elements/text_fields_spec.rb +2 -0
  221. data/spec/watirspec/elements/textarea_spec.rb +2 -0
  222. data/spec/watirspec/elements/textareas_spec.rb +2 -0
  223. data/spec/watirspec/elements/tfoot_spec.rb +2 -0
  224. data/spec/watirspec/elements/tfoots_spec.rb +2 -0
  225. data/spec/watirspec/elements/thead_spec.rb +2 -0
  226. data/spec/watirspec/elements/theads_spec.rb +2 -0
  227. data/spec/watirspec/elements/tr_spec.rb +2 -0
  228. data/spec/watirspec/elements/trs_spec.rb +2 -0
  229. data/spec/watirspec/elements/ul_spec.rb +2 -0
  230. data/spec/watirspec/elements/uls_spec.rb +2 -0
  231. data/spec/watirspec/html/child_frame.html +29 -0
  232. data/spec/watirspec/html/class_locator.html +2 -0
  233. data/spec/watirspec/html/scroll_nested.html +17 -0
  234. data/spec/watirspec/html/scroll_nested_offscreen.html +18 -0
  235. data/spec/watirspec/html/shadow_dom.html +28 -0
  236. data/spec/watirspec/radio_set_spec.rb +2 -0
  237. data/spec/watirspec/screenshot_spec.rb +4 -2
  238. data/spec/watirspec/scroll_spec.rb +75 -7
  239. data/spec/watirspec/shadow_root_spec.rb +103 -0
  240. data/spec/watirspec/special_chars_spec.rb +2 -0
  241. data/spec/watirspec/support/rspec_matchers.rb +35 -32
  242. data/spec/watirspec/user_editable_spec.rb +2 -0
  243. data/spec/watirspec/wait_spec.rb +2 -0
  244. data/spec/watirspec/window_switching_spec.rb +48 -38
  245. data/spec/watirspec_helper.rb +24 -18
  246. data/support/doctest_helper.rb +2 -0
  247. data/support/version_differ.rb +2 -0
  248. data/watir.gemspec +11 -8
  249. metadata +54 -215
  250. data/.github/actions/enable-safari/action.yml +0 -11
  251. data/.github/actions/install-chrome/action.yml +0 -12
  252. data/.github/actions/setup-linux/action.yml +0 -8
  253. data/lib/watir-webdriver.rb +0 -2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../unit_helper'
2
4
 
3
5
  describe Watir::Locators::TextField::SelectorBuilder do
@@ -7,18 +9,18 @@ describe Watir::Locators::TextField::SelectorBuilder do
7
9
  let(:uppercase) { 'ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞŸŽŠŒ' }
8
10
  let(:lowercase) { 'abcdefghijklmnopqrstuvwxyzàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿžšœ' }
9
11
  let(:negative_types) do
10
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('file','#{uppercase}','#{lowercase}') and "\
11
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('radio','#{uppercase}','#{lowercase}') and " \
12
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('checkbox','#{uppercase}','#{lowercase}') and " \
13
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('submit','#{uppercase}','#{lowercase}') and " \
14
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('reset','#{uppercase}','#{lowercase}') and " \
15
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('image','#{uppercase}','#{lowercase}') and " \
16
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('button','#{uppercase}','#{lowercase}') and " \
17
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('hidden','#{uppercase}','#{lowercase}') and " \
18
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('range','#{uppercase}','#{lowercase}') and " \
19
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('color','#{uppercase}','#{lowercase}') and " \
20
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('date','#{uppercase}','#{lowercase}') and " \
21
- "translate(@type,'#{uppercase}','#{lowercase}')!=translate('datetime-local','#{uppercase}','#{lowercase}')"
12
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('file','#{uppercase}','#{lowercase}') and " \
13
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('radio','#{uppercase}','#{lowercase}') and " \
14
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('checkbox','#{uppercase}','#{lowercase}') and " \
15
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('submit','#{uppercase}','#{lowercase}') and " \
16
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('reset','#{uppercase}','#{lowercase}') and " \
17
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('image','#{uppercase}','#{lowercase}') and " \
18
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('button','#{uppercase}','#{lowercase}') and " \
19
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('hidden','#{uppercase}','#{lowercase}') and " \
20
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('range','#{uppercase}','#{lowercase}') and " \
21
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('color','#{uppercase}','#{lowercase}') and " \
22
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('date','#{uppercase}','#{lowercase}') and " \
23
+ "translate(@type,'#{uppercase}','#{lowercase}')!=translate('datetime-local','#{uppercase}','#{lowercase}')"
22
24
  end
23
25
 
24
26
  describe '#build' do
@@ -33,7 +35,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
33
35
  it 'specified text field type that is text' do
34
36
  selector = {type: 'text'}
35
37
  built = {xpath: ".//*[local-name()='input']" \
36
- "[translate(@type,'#{uppercase}','#{lowercase}')=translate('text','#{uppercase}','#{lowercase}')]"}
38
+ "[translate(@type,'#{uppercase}','#{lowercase}')=" \
39
+ "translate('text','#{uppercase}','#{lowercase}')]"}
37
40
 
38
41
  expect(selector_builder.build(selector)).to eq built
39
42
  end
@@ -41,7 +44,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
41
44
  it 'specified text field type that is not text' do
42
45
  selector = {type: 'number'}
43
46
  built = {xpath: ".//*[local-name()='input']" \
44
- "[translate(@type,'#{uppercase}','#{lowercase}')=translate('number','#{uppercase}','#{lowercase}')]"}
47
+ "[translate(@type,'#{uppercase}','#{lowercase}')=" \
48
+ "translate('number','#{uppercase}','#{lowercase}')]"}
45
49
 
46
50
  expect(selector_builder.build(selector)).to eq built
47
51
  end
@@ -143,7 +147,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
143
147
  it 'using String' do
144
148
  selector = {label: 'First name'}
145
149
  built = {xpath: ".//*[local-name()='input'][not(@type) or (#{negative_types})]" \
146
- "[@id=//label[normalize-space()='First name']/@for or parent::label[normalize-space()='First name']]"}
150
+ "[@id=//label[normalize-space()='First name']" \
151
+ "/@for or parent::label[normalize-space()='First name']]"}
147
152
 
148
153
  expect(selector_builder.build(selector)).to eq built
149
154
  end
@@ -151,7 +156,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
151
156
  it 'uses String with hidden text' do
152
157
  selector = {label: 'With hidden text'}
153
158
  built = {xpath: ".//*[local-name()='input'][not(@type) or (#{negative_types})]" \
154
- "[@id=//label[normalize-space()='With hidden text']/@for or parent::label[normalize-space()='With hidden text']]"}
159
+ "[@id=//label[normalize-space()='With hidden text']" \
160
+ "/@for or parent::label[normalize-space()='With hidden text']]"}
155
161
 
156
162
  expect(selector_builder.build(selector)).to eq built
157
163
  end
@@ -159,7 +165,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
159
165
  it 'using simple Regexp' do
160
166
  selector = {label: /First/}
161
167
  built = {xpath: ".//*[local-name()='input'][not(@type) or (#{negative_types})]" \
162
- "[@id=//label[contains(normalize-space(), 'First')]/@for or parent::label[contains(normalize-space(), 'First')]]"}
168
+ '[@id=//label[contains(normalize-space(), "First")]' \
169
+ '/@for or parent::label[contains(normalize-space(), "First")]]'}
163
170
 
164
171
  expect(selector_builder.build(selector)).to eq built
165
172
  end
@@ -167,8 +174,9 @@ describe Watir::Locators::TextField::SelectorBuilder do
167
174
  it 'using complex Regexp' do
168
175
  selector = {label: /([qa])st? name/}
169
176
  built = {xpath: ".//*[local-name()='input'][not(@type) or (#{negative_types})]" \
170
- "[@id=//label[contains(normalize-space(), 's') and contains(normalize-space(), ' name')]/@for or " \
171
- "parent::label[contains(normalize-space(), 's') and contains(normalize-space(), ' name')]]",
177
+ '[@id=//label[contains(normalize-space(), "s") and contains(normalize-space(), " name")]' \
178
+ '/@for or parent::label[contains(normalize-space(), "s") ' \
179
+ 'and contains(normalize-space(), " name")]]',
172
180
  label_element: /([qa])st? name/}
173
181
 
174
182
  expect(selector_builder.build(selector)).to eq built
@@ -178,8 +186,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
178
186
  context 'with multiple locators' do
179
187
  it 'locates using tag name, class, attributes and text' do
180
188
  selector = {text: 'Developer', class: /c/, id: true}
181
- built = {xpath: ".//*[local-name()='input'][contains(@class, 'c')]" \
182
- "[not(@type) or (#{negative_types})][@id]", text: 'Developer'}
189
+ built = {xpath: ".//*[local-name()='input'][contains(@class, \"c\")]" \
190
+ "[not(@type) or (#{negative_types})][@id]", text: 'Developer'}
183
191
 
184
192
  expect(selector_builder.build(selector)).to eq built
185
193
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../unit_helper'
2
4
 
3
5
  describe Watir::Locators::TextArea::SelectorBuilder do
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'watirspec/support/rspec_matchers'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'unit_helper'
2
4
 
3
5
  describe Watir::Wait do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'watirspec_helper'
2
4
 
3
5
  describe 'Adjacent Elements' do
@@ -53,13 +55,13 @@ describe 'Adjacent Elements' do
53
55
  it 'accepts a tag name argument' do
54
56
  siblings = browser.div(id: 'second_sibling').siblings(tag_name: 'div')
55
57
  expect(siblings.size).to eq 3
56
- expect(siblings.all? { |sib| sib.is_a? Watir::Div }).to eq true
58
+ expect(siblings.all?(Watir::Div)).to eq true
57
59
  end
58
60
 
59
61
  it 'accepts custom tag name argument' do
60
62
  siblings = browser.div(id: 'regular_child').siblings(tag_name: 'childelement')
61
63
  expect(siblings.size).to eq 3
62
- expect(siblings.all? { |sib| sib.is_a? Watir::HTMLElement }).to eq true
64
+ expect(siblings.all?(Watir::HTMLElement)).to eq true
63
65
  end
64
66
 
65
67
  it 'accepts a class_name argument' do
@@ -67,7 +69,7 @@ describe 'Adjacent Elements' do
67
69
  expect(siblings.first).to be_a Watir::Div
68
70
  expect(siblings[0]).to be_a Watir::Div
69
71
  expect(siblings.size).to eq 2
70
- expect(siblings.all? { |sib| sib.is_a? Watir::Div }).to eq true
72
+ expect(siblings.all?(Watir::Div)).to eq true
71
73
  end
72
74
  end
73
75
 
@@ -234,19 +236,19 @@ describe 'Adjacent Elements' do
234
236
  it 'accepts tag_name argument' do
235
237
  children = browser.div(id: 'parent').children(tag_name: 'div')
236
238
  expect(children.size).to eq 3
237
- expect(children.all? { |child| child.is_a? Watir::Div }).to eq true
239
+ expect(children.all?(Watir::Div)).to eq true
238
240
  end
239
241
 
240
242
  it 'accepts custom tag_name argument' do
241
243
  children = browser.element(id: 'custom_parent').children(tag_name: 'childelement')
242
244
  expect(children.size).to eq 3
243
- expect(children.all? { |child| child.is_a? Watir::HTMLElement }).to eq true
245
+ expect(children.all?(Watir::HTMLElement)).to eq true
244
246
  end
245
247
 
246
248
  it 'accepts a class_name argument' do
247
249
  children = browser.div(id: 'parent').children(class_name: 'b')
248
250
  expect(children.size).to eq 2
249
- expect(children.all? { |child| child.is_a? Watir::Div }).to eq true
251
+ expect(children.all?(Watir::Div)).to eq true
250
252
  end
251
253
  end
252
254
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'watirspec_helper'
2
4
 
3
5
  describe 'Browser::AfterHooks' do
@@ -7,45 +9,40 @@ describe 'Browser::AfterHooks' do
7
9
  end
8
10
 
9
11
  it 'runs the given proc on each page load' do
10
- output = ''
11
- proc = proc { |browser| output << browser.text }
12
+ proc = proc { |browser| @output = browser.text }
12
13
 
13
14
  begin
14
15
  browser.alert.dismiss if browser.alert.exists?
15
16
  browser.after_hooks.add(proc)
16
17
  browser.goto(WatirSpec.url_for('non_control_elements.html'))
17
18
 
18
- expect(output).to include('Dubito, ergo cogito, ergo sum')
19
+ expect(@output).to include('Dubito, ergo cogito, ergo sum')
19
20
  ensure
20
21
  browser.after_hooks.delete(proc)
21
22
  end
22
23
  end
23
24
 
24
25
  it 'runs the given block on each page load' do
25
- output = ''
26
- begin
27
- browser.after_hooks.add { |browser| output << browser.text }
28
- browser.goto(WatirSpec.url_for('non_control_elements.html'))
26
+ browser.after_hooks.add { |browser| @output = browser.text }
27
+ browser.goto(WatirSpec.url_for('non_control_elements.html'))
29
28
 
30
- expect(output).to include('Dubito, ergo cogito, ergo sum')
31
- ensure
32
- browser.after_hooks.delete browser.after_hooks[0]
33
- end
29
+ expect(@output).to include('Dubito, ergo cogito, ergo sum')
30
+ ensure
31
+ browser.after_hooks.delete browser.after_hooks[0]
34
32
  end
35
33
  end
36
34
 
37
35
  describe '#delete' do
38
36
  it 'removes a previously added after_hook' do
39
- output = ''
40
- after_hook = ->(browser) { output << browser.text }
37
+ after_hook = ->(browser) { @output = browser.text }
41
38
 
42
39
  browser.after_hooks.add(after_hook)
43
40
  browser.goto(WatirSpec.url_for('non_control_elements.html'))
44
- expect(output).to include('Dubito, ergo cogito, ergo sum')
41
+ expect(@output).to include('Dubito, ergo cogito, ergo sum')
45
42
 
46
43
  browser.after_hooks.delete(after_hook)
47
44
  browser.goto(WatirSpec.url_for('definition_lists.html'))
48
- expect(output).to_not include('definition_lists')
45
+ expect(@output).to_not include('definition_lists')
49
46
  end
50
47
  end
51
48
 
@@ -53,7 +50,6 @@ describe 'Browser::AfterHooks' do
53
50
  before { @yield = nil }
54
51
 
55
52
  after(:each) do
56
- browser.original_window.use
57
53
  browser.after_hooks.delete @page_after_hook
58
54
  end
59
55
 
@@ -162,11 +158,13 @@ describe 'Browser::AfterHooks' do
162
158
  end
163
159
 
164
160
  it 'does not raise error when running error checks on closed window',
165
- except: {browser: :safari,
166
- reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'},
167
- exclude: {browser: :firefox,
168
- platform: :windows,
169
- reason: 'https://github.com/mozilla/geckodriver/issues/1847'} do
161
+ exclude: [{browser: :safari,
162
+ reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'},
163
+ {browser: :firefox,
164
+ platform: :windows,
165
+ reason: 'https://github.com/mozilla/geckodriver/issues/1847'},
166
+ {browser: :ie,
167
+ reason: 'IE and windows do not play well together'}] do
170
168
  url = WatirSpec.url_for('window_switching.html')
171
169
  @page_after_hook = proc { browser.url }
172
170
  browser.after_hooks.add @page_after_hook
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'watirspec_helper'
2
4
 
3
5
  describe 'Alert API' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'watirspec_helper'
2
4
 
3
5
  describe 'Attributes' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'watirspec_helper'
2
4
 
3
5
  describe 'Browser' do
@@ -9,7 +11,9 @@ describe 'Browser' do
9
11
 
10
12
  it 'returns false if window is closed',
11
13
  except: {browser: :safari,
12
- reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'} do
14
+ reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'},
15
+ exclude: {browser: :ie,
16
+ reason: 'IE does not like switching windows'} do
13
17
  browser.goto WatirSpec.url_for('window_switching.html')
14
18
  browser.a(id: 'open').click
15
19
  browser.windows.wait_until(size: 2)
@@ -182,7 +186,7 @@ describe 'Browser' do
182
186
  @opts[:url] = url
183
187
  @new_browser = WatirSpec.new_browser
184
188
 
185
- server_url = @new_browser.driver.instance_variable_get('@bridge').http.instance_variable_get('@server_url')
189
+ server_url = @new_browser.driver.instance_variable_get(:@bridge).http.instance_variable_get(:@server_url)
186
190
  expect(server_url).to eq URI.parse(url)
187
191
  end
188
192
 
@@ -190,7 +194,7 @@ describe 'Browser' do
190
194
  @opts.merge!(url: url, open_timeout: 44, read_timeout: 47)
191
195
  @new_browser = WatirSpec.new_browser
192
196
 
193
- http = @new_browser.driver.instance_variable_get('@bridge').http
197
+ http = @new_browser.driver.instance_variable_get(:@bridge).http
194
198
 
195
199
  expect(http.open_timeout).to eq 44
196
200
  expect(http.read_timeout).to eq 47
@@ -202,7 +206,7 @@ describe 'Browser' do
202
206
  @opts[:http_client] = http_client
203
207
  @new_browser = WatirSpec.new_browser
204
208
 
205
- expect(@new_browser.driver.instance_variable_get('@bridge').http).to eq http_client
209
+ expect(@new_browser.driver.instance_variable_get(:@bridge).http).to eq http_client
206
210
  end
207
211
 
208
212
  it 'accepts Remote::Capabilities instance as :desired_capabilities', only: {browser: :firefox} do
@@ -250,7 +254,7 @@ describe 'Browser' do
250
254
  WatirSpec.implementation.browser_args = [:remote, opts]
251
255
  msg = /You can pass values directly into Watir::Browser opt without needing to use :desired_capabilities/
252
256
  expect { @new_browser = WatirSpec.new_browser }.to output(msg).to_stdout_from_any_process
253
- server_url = @new_browser.driver.instance_variable_get('@bridge').http.instance_variable_get('@server_url')
257
+ server_url = @new_browser.driver.instance_variable_get(:@bridge).http.instance_variable_get(:@server_url)
254
258
  expect(server_url).to eq URI.parse(url)
255
259
  end
256
260
 
@@ -285,16 +289,16 @@ describe 'Browser' do
285
289
 
286
290
  service = Selenium::WebDriver::Service.send(browser_name, port: '2314', args: ['foo'])
287
291
 
288
- @opts.merge!(service: service,
289
- listener: LocalConfig::SelectorListener.new)
292
+ @opts[:service] = service
293
+ @opts[:listener] = LocalConfig::SelectorListener.new
290
294
 
291
295
  @new_browser = WatirSpec.new_browser
292
296
 
293
- bridge = @new_browser.wd.instance_variable_get('@bridge')
297
+ bridge = @new_browser.wd.instance_variable_get(:@bridge)
294
298
  expect(bridge).to be_a Selenium::WebDriver::Support::EventFiringBridge
295
- service = @new_browser.wd.instance_variable_get('@service')
296
- expect(service.instance_variable_get('@extra_args')).to eq ['foo']
297
- expect(service.instance_variable_get('@port')).to eq 2314
299
+ service = @new_browser.wd.instance_variable_get(:@service)
300
+ expect(service.instance_variable_get(:@extra_args)).to eq ['foo']
301
+ expect(service.instance_variable_get(:@port)).to eq 2314
298
302
 
299
303
  @new_browser.close
300
304
  ensure
@@ -385,7 +389,7 @@ describe 'Browser' do
385
389
  end
386
390
 
387
391
  it 'returns correct Ruby objects' do
388
- expect(browser.execute_script('return {a: 1, "b": 2}')).to eq Hash['a' => 1, 'b' => 2]
392
+ expect(browser.execute_script('return {a: 1, "b": 2}')).to eq({'a' => 1, 'b' => 2})
389
393
  expect(browser.execute_script('return [1, 2, "3"]')).to match_array([1, 2, '3'])
390
394
  expect(browser.execute_script('return 1.2 + 1.3')).to eq 2.5
391
395
  expect(browser.execute_script('return 2 + 2')).to eq 4