watir 1.4.1 → 7.3.0

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.
Files changed (422) hide show
  1. checksums.yaml +7 -0
  2. data/.document +4 -0
  3. data/.github/ISSUE_TEMPLATE.md +16 -0
  4. data/.github/workflows/chrome.yml +55 -0
  5. data/.github/workflows/edge.yml +44 -0
  6. data/.github/workflows/firefox.yml +55 -0
  7. data/.github/workflows/ie.yml +30 -0
  8. data/.github/workflows/safari.yml +38 -0
  9. data/.github/workflows/unit.yml +60 -0
  10. data/.gitignore +21 -0
  11. data/.rubocop.yml +114 -0
  12. data/.rubocop_todo.yml +17 -0
  13. data/CHANGES.md +2212 -0
  14. data/Gemfile +15 -0
  15. data/LICENSE +24 -0
  16. data/README.md +113 -0
  17. data/Rakefile +173 -0
  18. data/lib/watir/adjacent.rb +128 -0
  19. data/lib/watir/after_hooks.rb +135 -0
  20. data/lib/watir/alert.rb +113 -0
  21. data/lib/watir/aliases.rb +8 -0
  22. data/lib/watir/attribute_helper.rb +97 -0
  23. data/lib/watir/browser.rb +323 -0
  24. data/lib/watir/capabilities.rb +179 -0
  25. data/lib/watir/cell_container.rb +25 -0
  26. data/lib/watir/container.rb +33 -0
  27. data/lib/watir/cookies.rb +130 -0
  28. data/lib/watir/element_collection.rb +223 -0
  29. data/lib/watir/elements/button.rb +28 -0
  30. data/lib/watir/elements/cell.rb +18 -0
  31. data/lib/watir/elements/checkbox.rb +56 -0
  32. data/lib/watir/elements/date_field.rb +42 -0
  33. data/lib/watir/elements/date_time_field.rb +42 -0
  34. data/lib/watir/elements/dlist.rb +12 -0
  35. data/lib/watir/elements/element.rb +807 -0
  36. data/lib/watir/elements/file_field.rb +43 -0
  37. data/lib/watir/elements/font.rb +26 -0
  38. data/lib/watir/elements/form.rb +16 -0
  39. data/lib/watir/elements/hidden.rb +26 -0
  40. data/lib/watir/elements/html_elements.rb +1981 -0
  41. data/lib/watir/elements/iframe.rb +156 -0
  42. data/lib/watir/elements/image.rb +22 -0
  43. data/lib/watir/elements/input.rb +15 -0
  44. data/lib/watir/elements/link.rb +8 -0
  45. data/lib/watir/elements/list.rb +51 -0
  46. data/lib/watir/elements/option.rb +60 -0
  47. data/lib/watir/elements/radio.rb +65 -0
  48. data/lib/watir/elements/row.rb +18 -0
  49. data/lib/watir/elements/select.rb +214 -0
  50. data/lib/watir/elements/svg_elements.rb +497 -0
  51. data/lib/watir/elements/table.rb +77 -0
  52. data/lib/watir/elements/table_cell.rb +32 -0
  53. data/lib/watir/elements/table_row.rb +34 -0
  54. data/lib/watir/elements/table_section.rb +17 -0
  55. data/lib/watir/elements/text_area.rb +7 -0
  56. data/lib/watir/elements/text_field.rb +39 -0
  57. data/lib/watir/exception.rb +16 -0
  58. data/lib/watir/extensions/nokogiri.rb +14 -0
  59. data/lib/watir/generator/base/generator.rb +114 -0
  60. data/lib/watir/generator/base/idl_sorter.rb +51 -0
  61. data/lib/watir/generator/base/spec_extractor.rb +158 -0
  62. data/lib/watir/generator/base/util.rb +21 -0
  63. data/lib/watir/generator/base/visitor.rb +133 -0
  64. data/lib/watir/generator/base.rb +12 -0
  65. data/lib/watir/generator/html/generator.rb +36 -0
  66. data/lib/watir/generator/html/spec_extractor.rb +52 -0
  67. data/lib/watir/generator/html/visitor.rb +23 -0
  68. data/lib/watir/generator/html.rb +17 -0
  69. data/lib/watir/generator/svg/generator.rb +38 -0
  70. data/lib/watir/generator/svg/spec_extractor.rb +55 -0
  71. data/lib/watir/generator/svg/visitor.rb +23 -0
  72. data/lib/watir/generator/svg.rb +9 -0
  73. data/lib/watir/generator.rb +5 -0
  74. data/lib/watir/has_window.rb +72 -0
  75. data/lib/watir/http_client.rb +11 -0
  76. data/lib/watir/js_execution.rb +165 -0
  77. data/lib/watir/js_snippets/attributeValues.js +11 -0
  78. data/lib/watir/js_snippets/backgroundColor.js +7 -0
  79. data/lib/watir/js_snippets/elementObscured.js +14 -0
  80. data/lib/watir/js_snippets/fireEvent.js +31 -0
  81. data/lib/watir/js_snippets/focus.js +3 -0
  82. data/lib/watir/js_snippets/getElementTags.js +3 -0
  83. data/lib/watir/js_snippets/getInnerHtml.js +19 -0
  84. data/lib/watir/js_snippets/getInnerText.js +19 -0
  85. data/lib/watir/js_snippets/getOuterHtml.js +20 -0
  86. data/lib/watir/js_snippets/getTextContent.js +19 -0
  87. data/lib/watir/js_snippets/isElementInViewport.js +20 -0
  88. data/lib/watir/js_snippets/isImageLoaded.js +3 -0
  89. data/lib/watir/js_snippets/selectOptionsLabel.js +10 -0
  90. data/lib/watir/js_snippets/selectOptionsText.js +10 -0
  91. data/lib/watir/js_snippets/selectOptionsValue.js +10 -0
  92. data/lib/watir/js_snippets/selectText.js +64 -0
  93. data/lib/watir/js_snippets/selectedOptions.js +11 -0
  94. data/lib/watir/js_snippets/selectedText.js +17 -0
  95. data/lib/watir/js_snippets/setText.js +3 -0
  96. data/lib/watir/js_snippets/setValue.js +3 -0
  97. data/lib/watir/js_snippets.rb +18 -0
  98. data/lib/watir/locators/anchor/selector_builder.rb +43 -0
  99. data/lib/watir/locators/button/matcher.rb +19 -0
  100. data/lib/watir/locators/button/selector_builder/xpath.rb +69 -0
  101. data/lib/watir/locators/button/selector_builder.rb +10 -0
  102. data/lib/watir/locators/cell/selector_builder/xpath.rb +23 -0
  103. data/lib/watir/locators/cell/selector_builder.rb +13 -0
  104. data/lib/watir/locators/element/locator.rb +81 -0
  105. data/lib/watir/locators/element/matcher.rb +118 -0
  106. data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +69 -0
  107. data/lib/watir/locators/element/selector_builder/xpath.rb +268 -0
  108. data/lib/watir/locators/element/selector_builder/xpath_support.rb +29 -0
  109. data/lib/watir/locators/element/selector_builder.rb +164 -0
  110. data/lib/watir/locators/option/matcher.rb +26 -0
  111. data/lib/watir/locators/option/selector_builder/xpath.rb +39 -0
  112. data/lib/watir/locators/option/selector_builder.rb +10 -0
  113. data/lib/watir/locators/row/selector_builder/xpath.rb +53 -0
  114. data/lib/watir/locators/row/selector_builder.rb +18 -0
  115. data/lib/watir/locators/text_area/selector_builder/xpath.rb +21 -0
  116. data/lib/watir/locators/text_area/selector_builder.rb +10 -0
  117. data/lib/watir/locators/text_field/matcher.rb +37 -0
  118. data/lib/watir/locators/text_field/selector_builder/xpath.rb +50 -0
  119. data/lib/watir/locators/text_field/selector_builder.rb +10 -0
  120. data/lib/watir/locators.rb +77 -0
  121. data/lib/watir/logger.rb +30 -0
  122. data/lib/watir/navigation.rb +51 -0
  123. data/lib/watir/radio_set.rb +230 -0
  124. data/lib/watir/row_container.rb +36 -0
  125. data/lib/watir/screenshot.rb +51 -0
  126. data/lib/watir/scroll.rb +95 -0
  127. data/lib/watir/search_context.rb +96 -0
  128. data/lib/watir/shadow_root.rb +60 -0
  129. data/lib/watir/user_editable.rb +85 -0
  130. data/lib/watir/version.rb +5 -0
  131. data/lib/watir/wait/timer.rb +52 -0
  132. data/lib/watir/wait.rb +171 -0
  133. data/lib/watir/window.rb +276 -0
  134. data/lib/watir/window_collection.rb +82 -0
  135. data/lib/watir.rb +108 -0
  136. data/lib/watirspec/guards.rb +65 -0
  137. data/lib/watirspec/implementation.rb +56 -0
  138. data/lib/watirspec/rake_tasks.rb +118 -0
  139. data/lib/watirspec/remote_server.rb +39 -0
  140. data/lib/watirspec/runner.rb +64 -0
  141. data/lib/watirspec/server/app.rb +86 -0
  142. data/lib/watirspec/server.rb +104 -0
  143. data/lib/watirspec.rb +93 -0
  144. data/spec/locator_spec_helper.rb +88 -0
  145. data/spec/spec_helper.rb +24 -0
  146. data/spec/unit/capabilities_spec.rb +670 -0
  147. data/spec/unit/element_locator_spec.rb +97 -0
  148. data/spec/unit/match_elements/button_spec.rb +76 -0
  149. data/spec/unit/match_elements/element_spec.rb +424 -0
  150. data/spec/unit/match_elements/text_field_spec.rb +84 -0
  151. data/spec/unit/selector_builder/anchor_spec.rb +59 -0
  152. data/spec/unit/selector_builder/button_spec.rb +217 -0
  153. data/spec/unit/selector_builder/cell_spec.rb +71 -0
  154. data/spec/unit/selector_builder/element_spec.rb +804 -0
  155. data/spec/unit/selector_builder/row_spec.rb +128 -0
  156. data/spec/unit/selector_builder/text_field_spec.rb +203 -0
  157. data/spec/unit/selector_builder/textarea_spec.rb +35 -0
  158. data/spec/unit/unit_helper.rb +4 -0
  159. data/spec/unit/wait_spec.rb +99 -0
  160. data/spec/watirspec/adjacent_spec.rb +256 -0
  161. data/spec/watirspec/after_hooks_spec.rb +204 -0
  162. data/spec/watirspec/alert_spec.rb +89 -0
  163. data/spec/watirspec/browser_spec.rb +536 -0
  164. data/spec/watirspec/capabilities_spec.rb +556 -0
  165. data/spec/watirspec/cookies_spec.rb +196 -0
  166. data/spec/watirspec/drag_and_drop_spec.rb +38 -0
  167. data/spec/watirspec/element_hidden_spec.rb +86 -0
  168. data/spec/watirspec/elements/area_spec.rb +69 -0
  169. data/spec/watirspec/elements/areas_spec.rb +44 -0
  170. data/spec/watirspec/elements/button_spec.rb +265 -0
  171. data/spec/watirspec/elements/buttons_spec.rb +57 -0
  172. data/spec/watirspec/elements/checkbox_spec.rb +290 -0
  173. data/spec/watirspec/elements/checkboxes_spec.rb +46 -0
  174. data/spec/watirspec/elements/collections_spec.rb +132 -0
  175. data/spec/watirspec/elements/date_field_spec.rb +209 -0
  176. data/spec/watirspec/elements/date_fields_spec.rb +46 -0
  177. data/spec/watirspec/elements/date_time_field_spec.rb +223 -0
  178. data/spec/watirspec/elements/date_time_fields_spec.rb +47 -0
  179. data/spec/watirspec/elements/dd_spec.rb +108 -0
  180. data/spec/watirspec/elements/dds_spec.rb +44 -0
  181. data/spec/watirspec/elements/del_spec.rb +113 -0
  182. data/spec/watirspec/elements/dels_spec.rb +42 -0
  183. data/spec/watirspec/elements/div_spec.rb +232 -0
  184. data/spec/watirspec/elements/divs_spec.rb +56 -0
  185. data/spec/watirspec/elements/dl_spec.rb +117 -0
  186. data/spec/watirspec/elements/dls_spec.rb +45 -0
  187. data/spec/watirspec/elements/dt_spec.rb +107 -0
  188. data/spec/watirspec/elements/dts_spec.rb +44 -0
  189. data/spec/watirspec/elements/element_spec.rb +1069 -0
  190. data/spec/watirspec/elements/elements_spec.rb +60 -0
  191. data/spec/watirspec/elements/em_spec.rb +85 -0
  192. data/spec/watirspec/elements/ems_spec.rb +45 -0
  193. data/spec/watirspec/elements/filefield_spec.rb +135 -0
  194. data/spec/watirspec/elements/filefields_spec.rb +45 -0
  195. data/spec/watirspec/elements/font_spec.rb +31 -0
  196. data/spec/watirspec/elements/form_spec.rb +70 -0
  197. data/spec/watirspec/elements/forms_spec.rb +46 -0
  198. data/spec/watirspec/elements/frame_spec.rb +117 -0
  199. data/spec/watirspec/elements/frames_spec.rb +43 -0
  200. data/spec/watirspec/elements/hidden_spec.rb +106 -0
  201. data/spec/watirspec/elements/hiddens_spec.rb +45 -0
  202. data/spec/watirspec/elements/hn_spec.rb +80 -0
  203. data/spec/watirspec/elements/hns_spec.rb +42 -0
  204. data/spec/watirspec/elements/iframe_spec.rb +244 -0
  205. data/spec/watirspec/elements/iframes_spec.rb +49 -0
  206. data/spec/watirspec/elements/image_spec.rb +160 -0
  207. data/spec/watirspec/elements/images_spec.rb +42 -0
  208. data/spec/watirspec/elements/input_spec.rb +17 -0
  209. data/spec/watirspec/elements/ins_spec.rb +113 -0
  210. data/spec/watirspec/elements/inses_spec.rb +42 -0
  211. data/spec/watirspec/elements/label_spec.rb +77 -0
  212. data/spec/watirspec/elements/labels_spec.rb +42 -0
  213. data/spec/watirspec/elements/li_spec.rb +99 -0
  214. data/spec/watirspec/elements/link_spec.rb +180 -0
  215. data/spec/watirspec/elements/links_spec.rb +66 -0
  216. data/spec/watirspec/elements/lis_spec.rb +44 -0
  217. data/spec/watirspec/elements/list_spec.rb +50 -0
  218. data/spec/watirspec/elements/map_spec.rb +78 -0
  219. data/spec/watirspec/elements/maps_spec.rb +43 -0
  220. data/spec/watirspec/elements/meta_spec.rb +27 -0
  221. data/spec/watirspec/elements/metas_spec.rb +42 -0
  222. data/spec/watirspec/elements/ol_spec.rb +63 -0
  223. data/spec/watirspec/elements/ols_spec.rb +42 -0
  224. data/spec/watirspec/elements/option_spec.rb +113 -0
  225. data/spec/watirspec/elements/p_spec.rb +102 -0
  226. data/spec/watirspec/elements/pre_spec.rb +100 -0
  227. data/spec/watirspec/elements/pres_spec.rb +42 -0
  228. data/spec/watirspec/elements/ps_spec.rb +42 -0
  229. data/spec/watirspec/elements/radio_spec.rb +259 -0
  230. data/spec/watirspec/elements/radios_spec.rb +45 -0
  231. data/spec/watirspec/elements/select_list_spec.rb +701 -0
  232. data/spec/watirspec/elements/select_lists_spec.rb +49 -0
  233. data/spec/watirspec/elements/span_spec.rb +119 -0
  234. data/spec/watirspec/elements/spans_spec.rb +42 -0
  235. data/spec/watirspec/elements/strong_spec.rb +78 -0
  236. data/spec/watirspec/elements/strongs_spec.rb +45 -0
  237. data/spec/watirspec/elements/table_spec.rb +210 -0
  238. data/spec/watirspec/elements/tables_spec.rb +44 -0
  239. data/spec/watirspec/elements/tbody_spec.rb +94 -0
  240. data/spec/watirspec/elements/tbodys_spec.rb +64 -0
  241. data/spec/watirspec/elements/td_spec.rb +92 -0
  242. data/spec/watirspec/elements/tds_spec.rb +55 -0
  243. data/spec/watirspec/elements/text_field_spec.rb +223 -0
  244. data/spec/watirspec/elements/text_fields_spec.rb +47 -0
  245. data/spec/watirspec/elements/textarea_spec.rb +30 -0
  246. data/spec/watirspec/elements/textareas_spec.rb +28 -0
  247. data/spec/watirspec/elements/tfoot_spec.rb +89 -0
  248. data/spec/watirspec/elements/tfoots_spec.rb +72 -0
  249. data/spec/watirspec/elements/thead_spec.rb +88 -0
  250. data/spec/watirspec/elements/theads_spec.rb +72 -0
  251. data/spec/watirspec/elements/tr_spec.rb +69 -0
  252. data/spec/watirspec/elements/trs_spec.rb +63 -0
  253. data/spec/watirspec/elements/ul_spec.rb +63 -0
  254. data/spec/watirspec/elements/uls_spec.rb +42 -0
  255. data/spec/watirspec/html/alerts.html +12 -0
  256. data/spec/watirspec/html/aria_attributes.html +9 -0
  257. data/spec/watirspec/html/child_frame.html +29 -0
  258. data/spec/watirspec/html/class_locator.html +11 -0
  259. data/spec/watirspec/html/clicks.html +19 -0
  260. data/spec/watirspec/html/closeable.html +21 -0
  261. data/spec/watirspec/html/collections.html +15 -0
  262. data/spec/watirspec/html/css/jquery-ui-1.8.17.custom.css +287 -0
  263. data/spec/watirspec/html/data_attributes.html +10 -0
  264. data/spec/watirspec/html/definition_lists.html +48 -0
  265. data/spec/watirspec/html/drag_and_drop.html +106 -0
  266. data/spec/watirspec/html/font.html +10 -0
  267. data/spec/watirspec/html/forms_with_input_elements.html +194 -0
  268. data/spec/watirspec/html/frame_1.html +22 -0
  269. data/spec/watirspec/html/frame_2.html +16 -0
  270. data/spec/watirspec/html/frames.html +11 -0
  271. data/spec/watirspec/html/iframe_1.html +22 -0
  272. data/spec/watirspec/html/iframes.html +15 -0
  273. data/spec/watirspec/html/images/button.png +0 -0
  274. data/spec/watirspec/html/images/circle.png +0 -0
  275. data/spec/watirspec/html/images/map.gif +0 -0
  276. data/spec/watirspec/html/images/map2.gif +0 -0
  277. data/spec/watirspec/html/images/originaltriangle.png +0 -0
  278. data/spec/watirspec/html/images/square.png +0 -0
  279. data/spec/watirspec/html/images/triangle.png +0 -0
  280. data/spec/watirspec/html/images.html +28 -0
  281. data/spec/watirspec/html/inner_outer.html +5 -0
  282. data/spec/watirspec/html/javascript/angular.min.js +332 -0
  283. data/spec/watirspec/html/javascript/helpers.js +16 -0
  284. data/spec/watirspec/html/javascript/jquery-1.7.1.min.js +4 -0
  285. data/spec/watirspec/html/javascript/jquery-ui-1.8.17.custom.min.js +68 -0
  286. data/spec/watirspec/html/keylogger.html +15 -0
  287. data/spec/watirspec/html/modal_dialog.html +9 -0
  288. data/spec/watirspec/html/multiple_ids.html +15 -0
  289. data/spec/watirspec/html/nested_elements.html +44 -0
  290. data/spec/watirspec/html/nested_frame_1.html +1 -0
  291. data/spec/watirspec/html/nested_frame_2.html +9 -0
  292. data/spec/watirspec/html/nested_frame_3.html +14 -0
  293. data/spec/watirspec/html/nested_frames.html +10 -0
  294. data/spec/watirspec/html/nested_iframe_2.html +12 -0
  295. data/spec/watirspec/html/nested_iframes.html +13 -0
  296. data/spec/watirspec/html/nested_tables.html +203 -0
  297. data/spec/watirspec/html/non_control_elements.html +145 -0
  298. data/spec/watirspec/html/obscured.html +36 -0
  299. data/spec/watirspec/html/removed_element.html +24 -0
  300. data/spec/watirspec/html/right_click.html +23 -0
  301. data/spec/watirspec/html/scroll.html +15 -0
  302. data/spec/watirspec/html/scroll_nested.html +17 -0
  303. data/spec/watirspec/html/scroll_nested_offscreen.html +18 -0
  304. data/spec/watirspec/html/shadow_dom.html +28 -0
  305. data/spec/watirspec/html/special_chars.html +15 -0
  306. data/spec/watirspec/html/sticky_elements.html +10 -0
  307. data/spec/watirspec/html/tables.html +121 -0
  308. data/spec/watirspec/html/timeout_window_location.html +19 -0
  309. data/spec/watirspec/html/uneven_table.html +20 -0
  310. data/spec/watirspec/html/wait.html +99 -0
  311. data/spec/watirspec/html/watirspec.css +0 -0
  312. data/spec/watirspec/html/window_switching.html +22 -0
  313. data/spec/watirspec/radio_set_spec.rb +346 -0
  314. data/spec/watirspec/screenshot_spec.rb +33 -0
  315. data/spec/watirspec/scroll_spec.rb +208 -0
  316. data/spec/watirspec/shadow_root_spec.rb +108 -0
  317. data/spec/watirspec/support/rspec_matchers.rb +161 -0
  318. data/spec/watirspec/user_editable_spec.rb +207 -0
  319. data/spec/watirspec/wait_spec.rb +345 -0
  320. data/spec/watirspec/window_switching_spec.rb +580 -0
  321. data/spec/watirspec_helper.rb +163 -0
  322. data/support/doctest_helper.rb +101 -0
  323. data/support/version_differ.rb +60 -0
  324. data/watir.gemspec +50 -0
  325. metadata +652 -148
  326. data/readme.rb +0 -211
  327. data/unittests/WindowLogonExample.rb +0 -30
  328. data/unittests/WindowLogonExtra.rb +0 -7
  329. data/unittests/all_tests.rb +0 -10
  330. data/unittests/all_tests_concurrent.rb +0 -57
  331. data/unittests/attachToExistingWindow_test.rb +0 -40
  332. data/unittests/buttons_test.rb +0 -131
  333. data/unittests/checkbox_test.rb +0 -149
  334. data/unittests/core_tests.rb +0 -9
  335. data/unittests/css_test.rb +0 -60
  336. data/unittests/div_test.rb +0 -179
  337. data/unittests/errorchecker_test.rb +0 -29
  338. data/unittests/filefield_test.rb +0 -35
  339. data/unittests/form_test.rb +0 -279
  340. data/unittests/frame_test.rb +0 -141
  341. data/unittests/html/blankpage.html +0 -12
  342. data/unittests/html/buttons1.html +0 -40
  343. data/unittests/html/checkboxes1.html +0 -69
  344. data/unittests/html/complex_table.html +0 -36
  345. data/unittests/html/cssTest.html +0 -42
  346. data/unittests/html/div.html +0 -105
  347. data/unittests/html/fileupload.html +0 -45
  348. data/unittests/html/formTest1.html +0 -39
  349. data/unittests/html/forms2.html +0 -45
  350. data/unittests/html/forms3.html +0 -132
  351. data/unittests/html/forms4.html +0 -27
  352. data/unittests/html/frame_buttons.html +0 -4
  353. data/unittests/html/frame_links.html +0 -4
  354. data/unittests/html/frame_multi.html +0 -5
  355. data/unittests/html/iframeTest.html +0 -13
  356. data/unittests/html/iframeTest1.html +0 -7
  357. data/unittests/html/iframeTest2.html +0 -6
  358. data/unittests/html/images/button.jpg +0 -0
  359. data/unittests/html/images/circle.jpg +0 -0
  360. data/unittests/html/images/originaltriangle.jpg +0 -0
  361. data/unittests/html/images/square.jpg +0 -0
  362. data/unittests/html/images/triangle.jpg +0 -0
  363. data/unittests/html/images1.html +0 -52
  364. data/unittests/html/javascriptevents.html +0 -39
  365. data/unittests/html/link_pass.html +0 -11
  366. data/unittests/html/links1.html +0 -37
  367. data/unittests/html/links2.html +0 -11
  368. data/unittests/html/nestedFrames.html +0 -6
  369. data/unittests/html/pass.html +0 -10
  370. data/unittests/html/popups1.html +0 -60
  371. data/unittests/html/radioButtons1.html +0 -71
  372. data/unittests/html/select_tealeaf.html +0 -54
  373. data/unittests/html/selectboxes1.html +0 -55
  374. data/unittests/html/simple_table.html +0 -26
  375. data/unittests/html/simple_table_buttons.html +0 -104
  376. data/unittests/html/simple_table_columns.html +0 -76
  377. data/unittests/html/table1.html +0 -142
  378. data/unittests/html/textarea.html +0 -30
  379. data/unittests/html/textfields1.html +0 -87
  380. data/unittests/html/textsearch.html +0 -44
  381. data/unittests/ie_mock.rb +0 -93
  382. data/unittests/ie_test.rb +0 -50
  383. data/unittests/images_test.rb +0 -179
  384. data/unittests/iostring.rb +0 -30
  385. data/unittests/iostring_test.rb +0 -48
  386. data/unittests/js_events_test.rb +0 -77
  387. data/unittests/jscriptExtraAlert.rb +0 -6
  388. data/unittests/jscriptExtraConfirmCancel.rb +0 -7
  389. data/unittests/jscriptExtraConfirmOk.rb +0 -7
  390. data/unittests/jscriptPushButton.rb +0 -5
  391. data/unittests/jscript_test.rb +0 -57
  392. data/unittests/links_test.rb +0 -169
  393. data/unittests/minmax_test.rb +0 -31
  394. data/unittests/navigate_test.rb +0 -56
  395. data/unittests/non_core_tests.rb +0 -9
  396. data/unittests/pagecontainstext_test.rb +0 -49
  397. data/unittests/popups_test.rb +0 -44
  398. data/unittests/radios_test.rb +0 -164
  399. data/unittests/screen_capture_test.rb +0 -53
  400. data/unittests/selectbox_test.rb +0 -197
  401. data/unittests/send_keys_test.rb +0 -29
  402. data/unittests/setup.rb +0 -47
  403. data/unittests/table_test.rb +0 -306
  404. data/unittests/textAreafields_test.rb +0 -81
  405. data/unittests/textfields_test.rb +0 -239
  406. data/watir/AutoItX3.dll +0 -0
  407. data/watir/WindowHelper.rb +0 -47
  408. data/watir/camel_case.rb +0 -37
  409. data/watir/clickJSDialog.rb +0 -19
  410. data/watir/cookiemanager.rb +0 -53
  411. data/watir/exceptions.rb +0 -60
  412. data/watir/screen_capture.rb +0 -115
  413. data/watir/setFileDialog.rb +0 -16
  414. data/watir/testUnitAddons.rb +0 -47
  415. data/watir/watir_simple.rb +0 -475
  416. data/watir/winClicker.rb +0 -505
  417. data/watir.rb +0 -3744
  418. /data/{unittests → spec/watirspec}/html/images/1.gif +0 -0
  419. /data/{unittests/html/images/2.GIF → spec/watirspec/html/images/2.gif} +0 -0
  420. /data/{unittests/html/images/3.GIF → spec/watirspec/html/images/3.gif} +0 -0
  421. /data/{unittests/html/images/minus.GIF → spec/watirspec/html/images/minus.gif} +0 -0
  422. /data/{unittests → spec/watirspec}/html/images/plus.gif +0 -0
@@ -0,0 +1,701 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'watirspec_helper'
4
+
5
+ module Watir
6
+ describe Select do
7
+ before do
8
+ browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
9
+ end
10
+
11
+ # Exists method
12
+ describe '#exists?' do
13
+ it 'returns true if the select list exists' do
14
+ expect(browser.select_list(id: 'new_user_country')).to exist
15
+ expect(browser.select_list(id: /new_user_country/)).to exist
16
+ expect(browser.select_list(name: 'new_user_country')).to exist
17
+ expect(browser.select_list(name: /new_user_country/)).to exist
18
+ expect(browser.select_list(class: 'country')).to exist
19
+ expect(browser.select_list(class: /country/)).to exist
20
+ expect(browser.select_list(index: 0)).to exist
21
+ expect(browser.select_list(xpath: "//select[@id='new_user_country']")).to exist
22
+ end
23
+
24
+ it 'returns the first select if given no args' do
25
+ expect(browser.select_list).to exist
26
+ end
27
+
28
+ it "returns false if the select list doesn't exist" do
29
+ expect(browser.select_list(id: 'no_such_id')).not_to exist
30
+ expect(browser.select_list(id: /no_such_id/)).not_to exist
31
+ expect(browser.select_list(name: 'no_such_name')).not_to exist
32
+ expect(browser.select_list(name: /no_such_name/)).not_to exist
33
+ expect(browser.select_list(value: 'no_such_value')).not_to exist
34
+ expect(browser.select_list(value: /no_such_value/)).not_to exist
35
+ expect(browser.select_list(text: 'no_such_text')).not_to exist
36
+ expect(browser.select_list(text: /no_such_text/)).not_to exist
37
+ expect(browser.select_list(class: 'no_such_class')).not_to exist
38
+ expect(browser.select_list(class: /no_such_class/)).not_to exist
39
+ expect(browser.select_list(index: 1337)).not_to exist
40
+ expect(browser.select_list(xpath: "//select[@id='no_such_id']")).not_to exist
41
+ end
42
+
43
+ it "raises TypeError when 'what' argument is invalid" do
44
+ expect { browser.select_list(id: 3.14).exists? }.to raise_error(TypeError)
45
+ end
46
+ end
47
+
48
+ # Attribute methods
49
+ describe '#id' do
50
+ it 'returns the id of the element' do
51
+ expect(browser.select_list(index: 0).id).to eq 'new_user_country'
52
+ end
53
+
54
+ it "raises UnknownObjectException if the select list doesn't exist" do
55
+ expect { browser.select_list(index: 1337).id }.to raise_unknown_object_exception
56
+ end
57
+ end
58
+
59
+ describe '#name' do
60
+ it 'returns the name of the element' do
61
+ expect(browser.select_list(index: 0).name).to eq 'new_user_country'
62
+ end
63
+
64
+ it "raises UnknownObjectException if the select list doesn't exist" do
65
+ expect { browser.select_list(index: 1337).name }.to raise_unknown_object_exception
66
+ end
67
+ end
68
+
69
+ describe '#multiple?' do
70
+ it 'knows whether the select list allows multiple selections' do
71
+ expect(browser.select_list(index: 0)).not_to be_multiple
72
+ expect(browser.select_list(index: 1)).to be_multiple
73
+ end
74
+
75
+ it "raises UnknownObjectException if the select list doesn't exist" do
76
+ expect { browser.select_list(index: 1337).multiple? }.to raise_unknown_object_exception
77
+ end
78
+ end
79
+
80
+ describe '#value' do
81
+ it 'returns the value of the selected option' do
82
+ expect(browser.select_list(index: 0).value).to eq '2'
83
+ browser.select_list(index: 0).select(/Sweden/)
84
+ expect(browser.select_list(index: 0).value).to eq '3'
85
+ end
86
+
87
+ it 'returns the value of the selected options' do
88
+ browser.select_list(name: 'new_user_languages').select('1')
89
+ expect(browser.select_list(name: 'new_user_languages').value).to eq '1'
90
+ browser.select_list(name: 'new_user_languages').clear
91
+ browser.select_list(name: 'new_user_languages').select('NO')
92
+ expect(browser.select_list(name: 'new_user_languages').value).to eq '3'
93
+ end
94
+
95
+ it 'returns null when no values selected' do
96
+ browser.select_list(name: 'new_user_languages').clear
97
+ expect(browser.select_list(name: 'new_user_languages').value).to be_nil
98
+ end
99
+
100
+ it "raises UnknownObjectException if the select list doesn't exist" do
101
+ expect { browser.select_list(index: 1337).value }.to raise_unknown_object_exception
102
+ end
103
+ end
104
+
105
+ describe '#text' do
106
+ it 'returns the text of the selected option' do
107
+ expect(browser.select_list(index: 0).text).to eq 'Norway'
108
+ browser.select_list(index: 0).select(/Sweden/)
109
+ expect(browser.select_list(index: 0).text).to eq 'Sweden'
110
+ end
111
+
112
+ it "raises UnknownObjectException if the select list doesn't exist" do
113
+ expect { browser.select_list(index: 1337).text }.to raise_unknown_object_exception
114
+ end
115
+ end
116
+
117
+ describe '#respond_to?' do
118
+ it 'returns true for all attribute methods' do
119
+ expect(browser.select_list(index: 0)).to respond_to(:class_name)
120
+ expect(browser.select_list(index: 0)).to respond_to(:id)
121
+ expect(browser.select_list(index: 0)).to respond_to(:name)
122
+ expect(browser.select_list(index: 0)).to respond_to(:value)
123
+ end
124
+ end
125
+
126
+ # Access methods
127
+ describe '#enabled?' do
128
+ it 'returns true if the select list is enabled' do
129
+ expect(browser.select_list(name: 'new_user_country')).to be_enabled
130
+ end
131
+
132
+ it 'returns false if the select list is disabled' do
133
+ expect(browser.select_list(name: 'new_user_role')).not_to be_enabled
134
+ end
135
+
136
+ it "raises UnknownObjectException if the select_list doesn't exist" do
137
+ expect { browser.select_list(name: 'no_such_name').enabled? }.to raise_unknown_object_exception
138
+ end
139
+ end
140
+
141
+ describe '#disabled?' do
142
+ it 'returns true if the select list is disabled' do
143
+ expect(browser.select_list(index: 2)).to be_disabled
144
+ end
145
+
146
+ it 'returns false if the select list is enabled' do
147
+ expect(browser.select_list(index: 0)).not_to be_disabled
148
+ end
149
+
150
+ it 'raises UnknownObjectException when the select list does not exist' do
151
+ expect { browser.select_list(index: 1337).disabled? }.to raise_unknown_object_exception
152
+ end
153
+ end
154
+
155
+ # Other
156
+ describe '#option' do
157
+ it 'returns an instance of Option' do
158
+ option = browser.select_list(name: 'new_user_country').option(text: 'Denmark')
159
+ expect(option).to be_instance_of(Watir::Option)
160
+ expect(option.value).to eq '1'
161
+ end
162
+ end
163
+
164
+ describe '#options' do
165
+ it 'returns all the options' do
166
+ options = browser.select_list(name: 'new_user_country').options
167
+ expect(options.map(&:text)).to eq ['Denmark', 'Norway', 'Sweden', 'United Kingdom', 'USA', 'Germany']
168
+ end
169
+ end
170
+
171
+ describe '#selected_options' do
172
+ it "raises UnknownObjectException if the select list doesn't exist" do
173
+ expect { browser.select_list(name: 'no_such_name').selected_options }.to raise_unknown_object_exception
174
+ end
175
+
176
+ it 'gets the currently selected item(s)' do
177
+ expect(browser.select_list(name: 'new_user_country').selected_options.map(&:text)).to eq ['Norway']
178
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[EN NO]
179
+ end
180
+ end
181
+
182
+ describe '#clear' do
183
+ it 'clears the selection when possible' do
184
+ browser.select_list(name: 'new_user_languages').clear
185
+ expect(browser.select_list(name: 'new_user_languages').selected_options).to be_empty
186
+ end
187
+
188
+ it 'does not clear selections if the select list does not allow multiple selections' do
189
+ expect {
190
+ browser.select_list(name: 'new_user_country').clear
191
+ }.to raise_error(/you can only clear multi-selects/)
192
+
193
+ expect(browser.select_list(name: 'new_user_country').selected_options.map(&:text)).to eq ['Norway']
194
+ end
195
+
196
+ it "raises UnknownObjectException if the select list doesn't exist" do
197
+ expect { browser.select_list(name: 'no_such_name').clear }.to raise_unknown_object_exception
198
+ end
199
+
200
+ it 'fires onchange event' do
201
+ browser.select_list(name: 'new_user_languages').clear
202
+ expect(messages.size).to eq 2
203
+ end
204
+
205
+ it "doesn't fire onchange event for already cleared option" do
206
+ browser.select_list(name: 'new_user_languages').option.clear
207
+ expect(messages.size).to eq 0
208
+ end
209
+ end
210
+
211
+ describe '#include?' do
212
+ it 'returns true if the given option exists by text' do
213
+ expect(browser.select_list(name: 'new_user_country')).to include('Denmark')
214
+ end
215
+
216
+ it 'returns true if the given option exists by label' do
217
+ expect(browser.select_list(name: 'new_user_country')).to include('Germany')
218
+ end
219
+
220
+ it "returns false if the given option doesn't exist" do
221
+ expect(browser.select_list(name: 'new_user_country')).not_to include('Ireland')
222
+ end
223
+ end
224
+
225
+ describe '#selected?' do
226
+ it 'evaluates true by text' do
227
+ browser.select_list(name: 'new_user_country').select('1')
228
+ expect(browser.select_list(name: 'new_user_country')).to be_selected('Denmark')
229
+ end
230
+
231
+ it 'evaluates false by text' do
232
+ expect(browser.select_list(name: 'new_user_country')).not_to be_selected('Sweden')
233
+ end
234
+
235
+ it 'evaluates true exclusively by text' do
236
+ browser.select_list(name: 'new_user_country').select('1')
237
+ expect(browser.select_list(name: 'new_user_country')).to be_selected(text: 'Denmark')
238
+ end
239
+
240
+ it 'evaluates false exclusively by text' do
241
+ expect(browser.select_list(name: 'new_user_country')).not_to be_selected(text: 'Sweden')
242
+ end
243
+
244
+ it 'evaluates true by label' do
245
+ browser.select_list(name: 'new_user_country').select('Germany')
246
+ expect(browser.select_list(name: 'new_user_country')).to be_selected('Germany')
247
+ end
248
+
249
+ it 'evaluates false by label' do
250
+ expect(browser.select_list(name: 'new_user_country')).not_to be_selected('Germany')
251
+ end
252
+
253
+ it 'evaluates true exclusively by label' do
254
+ browser.select_list(name: 'new_user_country').select('Germany')
255
+ expect(browser.select_list(name: 'new_user_country')).to be_selected(label: 'Germany')
256
+ end
257
+
258
+ it 'evaluates false exclusively by label' do
259
+ expect(browser.select_list(name: 'new_user_country')).not_to be_selected(label: 'Germany')
260
+ end
261
+
262
+ it 'evaluates true by value' do
263
+ browser.select_list(name: 'new_user_country').select('USA')
264
+ expect(browser.select_list(name: 'new_user_country')).to be_selected('5')
265
+ end
266
+
267
+ it 'evaluates false by value' do
268
+ expect(browser.select_list(name: 'new_user_country')).not_to be_selected('5')
269
+ end
270
+
271
+ it 'evaluates true exclusively by value' do
272
+ browser.select_list(name: 'new_user_country').select('USA')
273
+ expect(browser.select_list(name: 'new_user_country')).to be_selected(value: '5')
274
+ end
275
+
276
+ it 'evaluates false exclusively by value' do
277
+ expect(browser.select_list(name: 'new_user_country')).not_to be_selected(value: '5')
278
+ end
279
+
280
+ it "raises NoValueFoundException if the option doesn't exist" do
281
+ expect { browser.select_list(name: 'new_user_country').selected?('missing_option') }
282
+ .to raise_no_value_found_exception
283
+ end
284
+ end
285
+
286
+ describe '#select method' do
287
+ context 'when working with multiple select list' do
288
+ before do
289
+ @select_list = browser.select_list(name: 'new_user_languages')
290
+ @select_list.clear
291
+ end
292
+
293
+ context 'when finding by value' do
294
+ it 'selects an option with a String' do
295
+ @select_list.select('2')
296
+ expect(@select_list.selected_options.first.text).to eq 'EN'
297
+ end
298
+
299
+ it 'selects an option with a Number' do
300
+ @select_list.select(2)
301
+ expect(@select_list.selected_options.first.text).to eq 'EN'
302
+ end
303
+
304
+ it 'selects an option with a Regexp' do
305
+ @select_list.select(/2|3/)
306
+ expect(@select_list.selected_options.first.text).to eq 'EN'
307
+ end
308
+
309
+ it 'uses keyword with a String' do
310
+ @select_list.select(value: '2')
311
+ expect(@select_list.selected_options.first.text).to eq 'EN'
312
+ end
313
+
314
+ it 'uses keyword with a Number' do
315
+ @select_list.select(value: 2)
316
+ expect(@select_list.selected_options.first.text).to eq 'EN'
317
+ end
318
+
319
+ it 'uses keyword with a Regexp' do
320
+ @select_list.select(value: /2|3/)
321
+ expect(@select_list.selected_options.first.text).to eq 'EN'
322
+ end
323
+ end
324
+
325
+ context 'when finding by text' do
326
+ it 'selects an option with a String' do
327
+ @select_list.select('Norwegian')
328
+ expect(@select_list.selected_options.first.value).to eq '3'
329
+ end
330
+
331
+ it 'selects an option with a Regexp' do
332
+ @select_list.select(/wegia/)
333
+ expect(@select_list.selected_options.first.value).to eq '3'
334
+ end
335
+
336
+ it 'uses keyword with a String' do
337
+ @select_list.select(text: 'Norwegian')
338
+ expect(@select_list.selected_options.first.value).to eq '3'
339
+ end
340
+
341
+ it 'uses keyword with a Regexp' do
342
+ @select_list.select(text: /wegia/)
343
+ expect(@select_list.selected_options.first.value).to eq '3'
344
+ end
345
+ end
346
+
347
+ context 'when finding by label' do
348
+ it 'selects an option with a String' do
349
+ @select_list.select('NO')
350
+ expect(@select_list.selected_options.first.value).to eq '3'
351
+ end
352
+
353
+ it 'selects an option with a Regexp' do
354
+ @select_list.select(/^N/)
355
+ expect(@select_list.selected_options.first.value).to eq '3'
356
+ end
357
+
358
+ it 'uses keyword with a String' do
359
+ @select_list.select(label: 'NO')
360
+ expect(@select_list.selected_options.first.value).to eq '3'
361
+ end
362
+
363
+ it 'uses keyword with a Regexp' do
364
+ @select_list.select(label: /^N/)
365
+ expect(@select_list.selected_options.first.value).to eq '3'
366
+ end
367
+ end
368
+
369
+ it 'selects multiple options successively' do
370
+ @select_list.select('Danish')
371
+ @select_list.select('Swedish')
372
+ expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
373
+ end
374
+
375
+ it 'selects each item in an Array' do
376
+ @select_list.select(%w[Danish Swedish])
377
+ expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
378
+ end
379
+
380
+ it 'selects each item in a parameter list' do
381
+ @select_list.select('Danish', 'Swedish')
382
+ expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
383
+ end
384
+
385
+ it 'selects empty options',
386
+ except: {browser: :safari, reason: 'Safari throwing ElementNotInteractableError'} do
387
+ browser.select_list(id: 'delete_user_username').select('')
388
+ expect(browser.select_list(id: 'delete_user_username').selected_options.map(&:text)).to eq ['']
389
+ end
390
+
391
+ it 'returns the value selected' do
392
+ expect(@select_list.select('Danish')).to eq 'Danish'
393
+ end
394
+
395
+ it 'fires onchange event when selecting or deselecting an item' do
396
+ @select_list.select('Danish')
397
+ expect(messages).to eq ['changed language', 'changed language', 'changed language']
398
+ end
399
+
400
+ it "doesn't fire onchange event when selecting an already selected item" do
401
+ @select_list.select('English')
402
+ expect(messages.size).to eq 3
403
+
404
+ @select_list.select('English')
405
+ expect(messages.size).to eq 3
406
+ end
407
+ end
408
+
409
+ it 'returns an empty string when selecting an option that disappears when selected',
410
+ except: {browser: :safari, reason: 'Safari throwing ElementNotInteractableError'} do
411
+ expect(browser.select_list(id: 'obsolete').select('sweden')).to eq ''
412
+ end
413
+
414
+ it 'selects options with a single-quoted value as String' do
415
+ select_list = browser.select_list(id: 'single-quote')
416
+ select_list.select("'foo'")
417
+
418
+ expect(select_list).to be_selected("'foo'")
419
+ end
420
+
421
+ it 'selects options with a single-quoted value as Regexp' do
422
+ select_list = browser.select_list(id: 'single-quote')
423
+ select_list.select(/'foo'/)
424
+
425
+ expect(select_list).to be_selected("'foo'")
426
+ end
427
+
428
+ it 'waits to select an option' do
429
+ browser.goto WatirSpec.url_for('wait.html')
430
+ browser.a(id: 'add_select').click
431
+ select_list = browser.select_list(id: 'languages')
432
+ expect { select_list.select('No') }.to wait_and_raise_no_value_found_exception
433
+ end
434
+
435
+ it "raises NoValueFoundException if the option doesn't exist" do
436
+ message = /#<Watir::Select: located: false; {:name=>"new_user_country", :tag_name=>"select"}>/
437
+ expect { browser.select_list(name: 'new_user_country').select('missing_option') }
438
+ .to raise_no_value_found_exception message
439
+ expect { browser.select_list(name: 'new_user_country').select(/missing_option/) }
440
+ .to raise_no_value_found_exception message
441
+ end
442
+
443
+ it 'raises ObjectDisabledException if the option is disabled', except: {browser: :safari} do
444
+ expect { browser.select_list(name: 'new_user_languages').select('Russian') }
445
+ .to raise_object_disabled_exception
446
+ end
447
+
448
+ it 'raises a TypeError if argument is not a String, Regexp or Numeric' do
449
+ expect { browser.select_list(id: 'new_user_languages').select(true) }.to raise_error(TypeError)
450
+ end
451
+
452
+ context 'when multiple options' do
453
+ it 'in an Array' do
454
+ browser.select_list(name: 'new_user_languages').clear
455
+ browser.select_list(name: 'new_user_languages').select(%w[Danish Swedish])
456
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
457
+ end
458
+
459
+ it 'in a parameter list' do
460
+ browser.select_list(name: 'new_user_languages').clear
461
+ browser.select_list(name: 'new_user_languages').select('Danish', 'Swedish')
462
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
463
+ end
464
+
465
+ it 'based on text' do
466
+ browser.select_list(name: 'new_user_languages').clear
467
+ browser.select_list(name: 'new_user_languages').select([/ish/])
468
+ list = %w[Danish EN Swedish]
469
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
470
+ end
471
+
472
+ it 'based on label and single regexp' do
473
+ browser.select_list(name: 'new_user_languages').clear
474
+ browser.select_list(name: 'new_user_languages').select([/NO|EN/])
475
+ list = %w[EN NO]
476
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
477
+ end
478
+
479
+ it 'based on label and multiple regexp' do
480
+ browser.select_list(name: 'new_user_languages').clear
481
+ browser.select_list(name: 'new_user_languages').select([/NO/, /EN/])
482
+ list = %w[EN NO]
483
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
484
+ end
485
+
486
+ it 'from an Array' do
487
+ browser.select_list(name: 'new_user_languages').clear
488
+ browser.select_list(name: 'new_user_languages').select([/ish/, /Latin/])
489
+ list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
490
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
491
+ end
492
+
493
+ it 'from multiple arguments' do
494
+ browser.select_list(name: 'new_user_languages').clear
495
+ browser.select_list(name: 'new_user_languages').select(/ish/, /Latin/)
496
+ list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
497
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
498
+ end
499
+
500
+ it 'returns the first matching value if there are multiple matches' do
501
+ expect(browser.select_list(name: 'new_user_languages').select([/ish/])).to eq 'Danish'
502
+ end
503
+ end
504
+ end
505
+
506
+ describe '#select!' do
507
+ context 'when working with multiple select list' do
508
+ before do
509
+ @select_list = browser.select_list(name: 'new_user_languages')
510
+ @select_list.clear
511
+ end
512
+
513
+ context 'when finding by value' do
514
+ it 'selects an option with a String' do
515
+ @select_list.select!('2')
516
+ expect(@select_list.selected_options.first.text).to eq 'EN'
517
+ end
518
+
519
+ it 'selects an option with a Number' do
520
+ @select_list.select!(2)
521
+ expect(@select_list.selected_options.first.text).to eq 'EN'
522
+ end
523
+
524
+ it 'selects an option with a Regexp' do
525
+ @select_list.select!(/2|3/)
526
+ expect(@select_list.selected_options.first.text).to eq 'EN'
527
+ end
528
+
529
+ it 'uses keyword with a String' do
530
+ @select_list.select!(value: '2')
531
+ expect(@select_list.selected_options.first.text).to eq 'EN'
532
+ end
533
+
534
+ it 'uses keyword with a Number' do
535
+ @select_list.select!(value: 2)
536
+ expect(@select_list.selected_options.first.text).to eq 'EN'
537
+ end
538
+
539
+ it 'uses keyword with a Regexp' do
540
+ @select_list.select!(value: /2|3/)
541
+ expect(@select_list.selected_options.first.text).to eq 'EN'
542
+ end
543
+ end
544
+
545
+ context 'when finding by text' do
546
+ it 'selects an option with a String' do
547
+ @select_list.select!('Danish')
548
+ expect(@select_list.selected_options.first.value).to eq '1'
549
+ end
550
+
551
+ it 'selects an option with a Regexp' do
552
+ @select_list.select!(/ani/)
553
+ expect(@select_list.selected_options.first.value).to eq '1'
554
+ end
555
+
556
+ it 'uses keyword with a String' do
557
+ @select_list.select!(text: 'Danish')
558
+ expect(@select_list.selected_options.first.value).to eq '1'
559
+ end
560
+
561
+ it 'uses keyword with a Regexp' do
562
+ @select_list.select!(text: /ani/)
563
+ expect(@select_list.selected_options.first.value).to eq '1'
564
+ end
565
+ end
566
+
567
+ context 'when finding by label' do
568
+ it 'selects an option with a String' do
569
+ @select_list.select!('NO')
570
+ expect(@select_list.selected_options.first.value).to eq '3'
571
+ end
572
+
573
+ it 'selects an option with a Regexp' do
574
+ @select_list.select!(/^N/)
575
+ expect(@select_list.selected_options.first.value).to eq '3'
576
+ end
577
+
578
+ it 'uses keyword with a String' do
579
+ @select_list.select!(label: 'NO')
580
+ expect(@select_list.selected_options.first.value).to eq '3'
581
+ end
582
+
583
+ it 'uses keyword with a Regexp' do
584
+ @select_list.select!(label: /^N/)
585
+ expect(@select_list.selected_options.first.value).to eq '3'
586
+ end
587
+ end
588
+
589
+ it 'selects multiple options successively' do
590
+ @select_list.select!('Danish')
591
+ @select_list.select!('Swedish')
592
+ expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
593
+ end
594
+
595
+ it 'selects each item in an Array' do
596
+ @select_list.select!(%w[Danish Swedish])
597
+ expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
598
+ end
599
+
600
+ it 'selects each item in a parameter list' do
601
+ @select_list.select!('Danish', 'Swedish')
602
+ expect(@select_list.selected_options.map(&:text)).to eq %w[Danish Swedish]
603
+ end
604
+
605
+ it 'selects empty options' do
606
+ browser.select_list(id: 'delete_user_username').select!('')
607
+ expect(browser.select_list(id: 'delete_user_username').selected_options.map(&:text)).to eq ['']
608
+ end
609
+
610
+ it 'returns the value selected' do
611
+ expect(@select_list.select!('Danish')).to eq 'Danish'
612
+ end
613
+ end
614
+
615
+ it 'selects options with a single-quoted value' do
616
+ select_list = browser.select_list(id: 'single-quote')
617
+ select_list.select!("'foo'")
618
+
619
+ expect(select_list).to be_selected("'foo'")
620
+ end
621
+
622
+ it 'selects exact matches when using String' do
623
+ browser.select_list(name: 'new_user_languages').clear
624
+ browser.select_list(name: 'new_user_languages').select!('Latin')
625
+ selected_options = browser.select_list(name: 'new_user_languages').selected_options.map(&:text)
626
+ expect(selected_options).not_to include('Azeri - Latin')
627
+ expect(selected_options).to include('Latin')
628
+ end
629
+
630
+ it "raises NoValueFoundException if the option doesn't exist" do
631
+ expect { browser.select_list(id: 'new_user_country').select!('missing_option') }
632
+ .to raise_no_value_found_exception
633
+ expect { browser.select_list(id: 'new_user_country').select!(/missing_option/) }
634
+ .to raise_no_value_found_exception
635
+ end
636
+
637
+ it 'raises ObjectDisabledException if the option is disabled', except: {browser: :safari} do
638
+ browser.select_list(id: 'new_user_languages').clear
639
+ expect { browser.select_list(name: 'new_user_languages').select!('Russian') }
640
+ .to raise_object_disabled_exception
641
+ end
642
+
643
+ it 'raises a TypeError if argument is not a String, Regexp or Numeric' do
644
+ expect { browser.select_list(id: 'new_user_languages').select!(true) }.to raise_error(TypeError)
645
+ end
646
+
647
+ context 'when multiple options' do
648
+ it 'in an Array' do
649
+ browser.select_list(name: 'new_user_languages').clear
650
+ browser.select_list(name: 'new_user_languages').select!(%w[Danish Swedish])
651
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
652
+ end
653
+
654
+ it 'in a parameter list' do
655
+ browser.select_list(name: 'new_user_languages').clear
656
+ browser.select_list(name: 'new_user_languages').select!('Danish', 'Swedish')
657
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq %w[Danish Swedish]
658
+ end
659
+
660
+ it 'based on text' do
661
+ browser.select_list(name: 'new_user_languages').clear
662
+ browser.select_list(name: 'new_user_languages').select!([/ish/])
663
+ list = %w[Danish EN Swedish]
664
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
665
+ end
666
+
667
+ it 'based on label and single regexp' do
668
+ browser.select_list(name: 'new_user_languages').clear
669
+ browser.select_list(name: 'new_user_languages').select!([/NO|EN/])
670
+ list = %w[EN NO]
671
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
672
+ end
673
+
674
+ it 'based on label and multiple regexp' do
675
+ browser.select_list(name: 'new_user_languages').clear
676
+ browser.select_list(name: 'new_user_languages').select!([/NO/, /EN/])
677
+ list = %w[EN NO]
678
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
679
+ end
680
+
681
+ it 'from an Array' do
682
+ browser.select_list(name: 'new_user_languages').clear
683
+ browser.select_list(name: 'new_user_languages').select!([/ish/, /Latin/])
684
+ list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
685
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
686
+ end
687
+
688
+ it 'from multiple arguments' do
689
+ browser.select_list(name: 'new_user_languages').clear
690
+ browser.select_list(name: 'new_user_languages').select!(/ish/, /Latin/)
691
+ list = ['Danish', 'EN', 'Swedish', 'Azeri - Latin', 'Latin']
692
+ expect(browser.select_list(name: 'new_user_languages').selected_options.map(&:text)).to eq list
693
+ end
694
+
695
+ it 'returns the first matching value if there are multiple matches' do
696
+ expect(browser.select_list(name: 'new_user_languages').select!([/ish/])).to eq 'Danish'
697
+ end
698
+ end
699
+ end
700
+ end
701
+ end