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.
- checksums.yaml +7 -0
- data/.document +4 -0
- data/.github/ISSUE_TEMPLATE.md +16 -0
- data/.github/workflows/chrome.yml +55 -0
- data/.github/workflows/edge.yml +44 -0
- data/.github/workflows/firefox.yml +55 -0
- data/.github/workflows/ie.yml +30 -0
- data/.github/workflows/safari.yml +38 -0
- data/.github/workflows/unit.yml +60 -0
- data/.gitignore +21 -0
- data/.rubocop.yml +114 -0
- data/.rubocop_todo.yml +17 -0
- data/CHANGES.md +2212 -0
- data/Gemfile +15 -0
- data/LICENSE +24 -0
- data/README.md +113 -0
- data/Rakefile +173 -0
- data/lib/watir/adjacent.rb +128 -0
- data/lib/watir/after_hooks.rb +135 -0
- data/lib/watir/alert.rb +113 -0
- data/lib/watir/aliases.rb +8 -0
- data/lib/watir/attribute_helper.rb +97 -0
- data/lib/watir/browser.rb +323 -0
- data/lib/watir/capabilities.rb +179 -0
- data/lib/watir/cell_container.rb +25 -0
- data/lib/watir/container.rb +33 -0
- data/lib/watir/cookies.rb +130 -0
- data/lib/watir/element_collection.rb +223 -0
- data/lib/watir/elements/button.rb +28 -0
- data/lib/watir/elements/cell.rb +18 -0
- data/lib/watir/elements/checkbox.rb +56 -0
- data/lib/watir/elements/date_field.rb +42 -0
- data/lib/watir/elements/date_time_field.rb +42 -0
- data/lib/watir/elements/dlist.rb +12 -0
- data/lib/watir/elements/element.rb +807 -0
- data/lib/watir/elements/file_field.rb +43 -0
- data/lib/watir/elements/font.rb +26 -0
- data/lib/watir/elements/form.rb +16 -0
- data/lib/watir/elements/hidden.rb +26 -0
- data/lib/watir/elements/html_elements.rb +1981 -0
- data/lib/watir/elements/iframe.rb +156 -0
- data/lib/watir/elements/image.rb +22 -0
- data/lib/watir/elements/input.rb +15 -0
- data/lib/watir/elements/link.rb +8 -0
- data/lib/watir/elements/list.rb +51 -0
- data/lib/watir/elements/option.rb +60 -0
- data/lib/watir/elements/radio.rb +65 -0
- data/lib/watir/elements/row.rb +18 -0
- data/lib/watir/elements/select.rb +214 -0
- data/lib/watir/elements/svg_elements.rb +497 -0
- data/lib/watir/elements/table.rb +77 -0
- data/lib/watir/elements/table_cell.rb +32 -0
- data/lib/watir/elements/table_row.rb +34 -0
- data/lib/watir/elements/table_section.rb +17 -0
- data/lib/watir/elements/text_area.rb +7 -0
- data/lib/watir/elements/text_field.rb +39 -0
- data/lib/watir/exception.rb +16 -0
- data/lib/watir/extensions/nokogiri.rb +14 -0
- data/lib/watir/generator/base/generator.rb +114 -0
- data/lib/watir/generator/base/idl_sorter.rb +51 -0
- data/lib/watir/generator/base/spec_extractor.rb +158 -0
- data/lib/watir/generator/base/util.rb +21 -0
- data/lib/watir/generator/base/visitor.rb +133 -0
- data/lib/watir/generator/base.rb +12 -0
- data/lib/watir/generator/html/generator.rb +36 -0
- data/lib/watir/generator/html/spec_extractor.rb +52 -0
- data/lib/watir/generator/html/visitor.rb +23 -0
- data/lib/watir/generator/html.rb +17 -0
- data/lib/watir/generator/svg/generator.rb +38 -0
- data/lib/watir/generator/svg/spec_extractor.rb +55 -0
- data/lib/watir/generator/svg/visitor.rb +23 -0
- data/lib/watir/generator/svg.rb +9 -0
- data/lib/watir/generator.rb +5 -0
- data/lib/watir/has_window.rb +72 -0
- data/lib/watir/http_client.rb +11 -0
- data/lib/watir/js_execution.rb +165 -0
- data/lib/watir/js_snippets/attributeValues.js +11 -0
- data/lib/watir/js_snippets/backgroundColor.js +7 -0
- data/lib/watir/js_snippets/elementObscured.js +14 -0
- data/lib/watir/js_snippets/fireEvent.js +31 -0
- data/lib/watir/js_snippets/focus.js +3 -0
- data/lib/watir/js_snippets/getElementTags.js +3 -0
- data/lib/watir/js_snippets/getInnerHtml.js +19 -0
- data/lib/watir/js_snippets/getInnerText.js +19 -0
- data/lib/watir/js_snippets/getOuterHtml.js +20 -0
- data/lib/watir/js_snippets/getTextContent.js +19 -0
- data/lib/watir/js_snippets/isElementInViewport.js +20 -0
- data/lib/watir/js_snippets/isImageLoaded.js +3 -0
- data/lib/watir/js_snippets/selectOptionsLabel.js +10 -0
- data/lib/watir/js_snippets/selectOptionsText.js +10 -0
- data/lib/watir/js_snippets/selectOptionsValue.js +10 -0
- data/lib/watir/js_snippets/selectText.js +64 -0
- data/lib/watir/js_snippets/selectedOptions.js +11 -0
- data/lib/watir/js_snippets/selectedText.js +17 -0
- data/lib/watir/js_snippets/setText.js +3 -0
- data/lib/watir/js_snippets/setValue.js +3 -0
- data/lib/watir/js_snippets.rb +18 -0
- data/lib/watir/locators/anchor/selector_builder.rb +43 -0
- data/lib/watir/locators/button/matcher.rb +19 -0
- data/lib/watir/locators/button/selector_builder/xpath.rb +69 -0
- data/lib/watir/locators/button/selector_builder.rb +10 -0
- data/lib/watir/locators/cell/selector_builder/xpath.rb +23 -0
- data/lib/watir/locators/cell/selector_builder.rb +13 -0
- data/lib/watir/locators/element/locator.rb +81 -0
- data/lib/watir/locators/element/matcher.rb +118 -0
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +69 -0
- data/lib/watir/locators/element/selector_builder/xpath.rb +268 -0
- data/lib/watir/locators/element/selector_builder/xpath_support.rb +29 -0
- data/lib/watir/locators/element/selector_builder.rb +164 -0
- data/lib/watir/locators/option/matcher.rb +26 -0
- data/lib/watir/locators/option/selector_builder/xpath.rb +39 -0
- data/lib/watir/locators/option/selector_builder.rb +10 -0
- data/lib/watir/locators/row/selector_builder/xpath.rb +53 -0
- data/lib/watir/locators/row/selector_builder.rb +18 -0
- data/lib/watir/locators/text_area/selector_builder/xpath.rb +21 -0
- data/lib/watir/locators/text_area/selector_builder.rb +10 -0
- data/lib/watir/locators/text_field/matcher.rb +37 -0
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +50 -0
- data/lib/watir/locators/text_field/selector_builder.rb +10 -0
- data/lib/watir/locators.rb +77 -0
- data/lib/watir/logger.rb +30 -0
- data/lib/watir/navigation.rb +51 -0
- data/lib/watir/radio_set.rb +230 -0
- data/lib/watir/row_container.rb +36 -0
- data/lib/watir/screenshot.rb +51 -0
- data/lib/watir/scroll.rb +95 -0
- data/lib/watir/search_context.rb +96 -0
- data/lib/watir/shadow_root.rb +60 -0
- data/lib/watir/user_editable.rb +85 -0
- data/lib/watir/version.rb +5 -0
- data/lib/watir/wait/timer.rb +52 -0
- data/lib/watir/wait.rb +171 -0
- data/lib/watir/window.rb +276 -0
- data/lib/watir/window_collection.rb +82 -0
- data/lib/watir.rb +108 -0
- data/lib/watirspec/guards.rb +65 -0
- data/lib/watirspec/implementation.rb +56 -0
- data/lib/watirspec/rake_tasks.rb +118 -0
- data/lib/watirspec/remote_server.rb +39 -0
- data/lib/watirspec/runner.rb +64 -0
- data/lib/watirspec/server/app.rb +86 -0
- data/lib/watirspec/server.rb +104 -0
- data/lib/watirspec.rb +93 -0
- data/spec/locator_spec_helper.rb +88 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/unit/capabilities_spec.rb +670 -0
- data/spec/unit/element_locator_spec.rb +97 -0
- data/spec/unit/match_elements/button_spec.rb +76 -0
- data/spec/unit/match_elements/element_spec.rb +424 -0
- data/spec/unit/match_elements/text_field_spec.rb +84 -0
- data/spec/unit/selector_builder/anchor_spec.rb +59 -0
- data/spec/unit/selector_builder/button_spec.rb +217 -0
- data/spec/unit/selector_builder/cell_spec.rb +71 -0
- data/spec/unit/selector_builder/element_spec.rb +804 -0
- data/spec/unit/selector_builder/row_spec.rb +128 -0
- data/spec/unit/selector_builder/text_field_spec.rb +203 -0
- data/spec/unit/selector_builder/textarea_spec.rb +35 -0
- data/spec/unit/unit_helper.rb +4 -0
- data/spec/unit/wait_spec.rb +99 -0
- data/spec/watirspec/adjacent_spec.rb +256 -0
- data/spec/watirspec/after_hooks_spec.rb +204 -0
- data/spec/watirspec/alert_spec.rb +89 -0
- data/spec/watirspec/browser_spec.rb +536 -0
- data/spec/watirspec/capabilities_spec.rb +556 -0
- data/spec/watirspec/cookies_spec.rb +196 -0
- data/spec/watirspec/drag_and_drop_spec.rb +38 -0
- data/spec/watirspec/element_hidden_spec.rb +86 -0
- data/spec/watirspec/elements/area_spec.rb +69 -0
- data/spec/watirspec/elements/areas_spec.rb +44 -0
- data/spec/watirspec/elements/button_spec.rb +265 -0
- data/spec/watirspec/elements/buttons_spec.rb +57 -0
- data/spec/watirspec/elements/checkbox_spec.rb +290 -0
- data/spec/watirspec/elements/checkboxes_spec.rb +46 -0
- data/spec/watirspec/elements/collections_spec.rb +132 -0
- data/spec/watirspec/elements/date_field_spec.rb +209 -0
- data/spec/watirspec/elements/date_fields_spec.rb +46 -0
- data/spec/watirspec/elements/date_time_field_spec.rb +223 -0
- data/spec/watirspec/elements/date_time_fields_spec.rb +47 -0
- data/spec/watirspec/elements/dd_spec.rb +108 -0
- data/spec/watirspec/elements/dds_spec.rb +44 -0
- data/spec/watirspec/elements/del_spec.rb +113 -0
- data/spec/watirspec/elements/dels_spec.rb +42 -0
- data/spec/watirspec/elements/div_spec.rb +232 -0
- data/spec/watirspec/elements/divs_spec.rb +56 -0
- data/spec/watirspec/elements/dl_spec.rb +117 -0
- data/spec/watirspec/elements/dls_spec.rb +45 -0
- data/spec/watirspec/elements/dt_spec.rb +107 -0
- data/spec/watirspec/elements/dts_spec.rb +44 -0
- data/spec/watirspec/elements/element_spec.rb +1069 -0
- data/spec/watirspec/elements/elements_spec.rb +60 -0
- data/spec/watirspec/elements/em_spec.rb +85 -0
- data/spec/watirspec/elements/ems_spec.rb +45 -0
- data/spec/watirspec/elements/filefield_spec.rb +135 -0
- data/spec/watirspec/elements/filefields_spec.rb +45 -0
- data/spec/watirspec/elements/font_spec.rb +31 -0
- data/spec/watirspec/elements/form_spec.rb +70 -0
- data/spec/watirspec/elements/forms_spec.rb +46 -0
- data/spec/watirspec/elements/frame_spec.rb +117 -0
- data/spec/watirspec/elements/frames_spec.rb +43 -0
- data/spec/watirspec/elements/hidden_spec.rb +106 -0
- data/spec/watirspec/elements/hiddens_spec.rb +45 -0
- data/spec/watirspec/elements/hn_spec.rb +80 -0
- data/spec/watirspec/elements/hns_spec.rb +42 -0
- data/spec/watirspec/elements/iframe_spec.rb +244 -0
- data/spec/watirspec/elements/iframes_spec.rb +49 -0
- data/spec/watirspec/elements/image_spec.rb +160 -0
- data/spec/watirspec/elements/images_spec.rb +42 -0
- data/spec/watirspec/elements/input_spec.rb +17 -0
- data/spec/watirspec/elements/ins_spec.rb +113 -0
- data/spec/watirspec/elements/inses_spec.rb +42 -0
- data/spec/watirspec/elements/label_spec.rb +77 -0
- data/spec/watirspec/elements/labels_spec.rb +42 -0
- data/spec/watirspec/elements/li_spec.rb +99 -0
- data/spec/watirspec/elements/link_spec.rb +180 -0
- data/spec/watirspec/elements/links_spec.rb +66 -0
- data/spec/watirspec/elements/lis_spec.rb +44 -0
- data/spec/watirspec/elements/list_spec.rb +50 -0
- data/spec/watirspec/elements/map_spec.rb +78 -0
- data/spec/watirspec/elements/maps_spec.rb +43 -0
- data/spec/watirspec/elements/meta_spec.rb +27 -0
- data/spec/watirspec/elements/metas_spec.rb +42 -0
- data/spec/watirspec/elements/ol_spec.rb +63 -0
- data/spec/watirspec/elements/ols_spec.rb +42 -0
- data/spec/watirspec/elements/option_spec.rb +113 -0
- data/spec/watirspec/elements/p_spec.rb +102 -0
- data/spec/watirspec/elements/pre_spec.rb +100 -0
- data/spec/watirspec/elements/pres_spec.rb +42 -0
- data/spec/watirspec/elements/ps_spec.rb +42 -0
- data/spec/watirspec/elements/radio_spec.rb +259 -0
- data/spec/watirspec/elements/radios_spec.rb +45 -0
- data/spec/watirspec/elements/select_list_spec.rb +701 -0
- data/spec/watirspec/elements/select_lists_spec.rb +49 -0
- data/spec/watirspec/elements/span_spec.rb +119 -0
- data/spec/watirspec/elements/spans_spec.rb +42 -0
- data/spec/watirspec/elements/strong_spec.rb +78 -0
- data/spec/watirspec/elements/strongs_spec.rb +45 -0
- data/spec/watirspec/elements/table_spec.rb +210 -0
- data/spec/watirspec/elements/tables_spec.rb +44 -0
- data/spec/watirspec/elements/tbody_spec.rb +94 -0
- data/spec/watirspec/elements/tbodys_spec.rb +64 -0
- data/spec/watirspec/elements/td_spec.rb +92 -0
- data/spec/watirspec/elements/tds_spec.rb +55 -0
- data/spec/watirspec/elements/text_field_spec.rb +223 -0
- data/spec/watirspec/elements/text_fields_spec.rb +47 -0
- data/spec/watirspec/elements/textarea_spec.rb +30 -0
- data/spec/watirspec/elements/textareas_spec.rb +28 -0
- data/spec/watirspec/elements/tfoot_spec.rb +89 -0
- data/spec/watirspec/elements/tfoots_spec.rb +72 -0
- data/spec/watirspec/elements/thead_spec.rb +88 -0
- data/spec/watirspec/elements/theads_spec.rb +72 -0
- data/spec/watirspec/elements/tr_spec.rb +69 -0
- data/spec/watirspec/elements/trs_spec.rb +63 -0
- data/spec/watirspec/elements/ul_spec.rb +63 -0
- data/spec/watirspec/elements/uls_spec.rb +42 -0
- data/spec/watirspec/html/alerts.html +12 -0
- data/spec/watirspec/html/aria_attributes.html +9 -0
- data/spec/watirspec/html/child_frame.html +29 -0
- data/spec/watirspec/html/class_locator.html +11 -0
- data/spec/watirspec/html/clicks.html +19 -0
- data/spec/watirspec/html/closeable.html +21 -0
- data/spec/watirspec/html/collections.html +15 -0
- data/spec/watirspec/html/css/jquery-ui-1.8.17.custom.css +287 -0
- data/spec/watirspec/html/data_attributes.html +10 -0
- data/spec/watirspec/html/definition_lists.html +48 -0
- data/spec/watirspec/html/drag_and_drop.html +106 -0
- data/spec/watirspec/html/font.html +10 -0
- data/spec/watirspec/html/forms_with_input_elements.html +194 -0
- data/spec/watirspec/html/frame_1.html +22 -0
- data/spec/watirspec/html/frame_2.html +16 -0
- data/spec/watirspec/html/frames.html +11 -0
- data/spec/watirspec/html/iframe_1.html +22 -0
- data/spec/watirspec/html/iframes.html +15 -0
- data/spec/watirspec/html/images/button.png +0 -0
- data/spec/watirspec/html/images/circle.png +0 -0
- data/spec/watirspec/html/images/map.gif +0 -0
- data/spec/watirspec/html/images/map2.gif +0 -0
- data/spec/watirspec/html/images/originaltriangle.png +0 -0
- data/spec/watirspec/html/images/square.png +0 -0
- data/spec/watirspec/html/images/triangle.png +0 -0
- data/spec/watirspec/html/images.html +28 -0
- data/spec/watirspec/html/inner_outer.html +5 -0
- data/spec/watirspec/html/javascript/angular.min.js +332 -0
- data/spec/watirspec/html/javascript/helpers.js +16 -0
- data/spec/watirspec/html/javascript/jquery-1.7.1.min.js +4 -0
- data/spec/watirspec/html/javascript/jquery-ui-1.8.17.custom.min.js +68 -0
- data/spec/watirspec/html/keylogger.html +15 -0
- data/spec/watirspec/html/modal_dialog.html +9 -0
- data/spec/watirspec/html/multiple_ids.html +15 -0
- data/spec/watirspec/html/nested_elements.html +44 -0
- data/spec/watirspec/html/nested_frame_1.html +1 -0
- data/spec/watirspec/html/nested_frame_2.html +9 -0
- data/spec/watirspec/html/nested_frame_3.html +14 -0
- data/spec/watirspec/html/nested_frames.html +10 -0
- data/spec/watirspec/html/nested_iframe_2.html +12 -0
- data/spec/watirspec/html/nested_iframes.html +13 -0
- data/spec/watirspec/html/nested_tables.html +203 -0
- data/spec/watirspec/html/non_control_elements.html +145 -0
- data/spec/watirspec/html/obscured.html +36 -0
- data/spec/watirspec/html/removed_element.html +24 -0
- data/spec/watirspec/html/right_click.html +23 -0
- data/spec/watirspec/html/scroll.html +15 -0
- data/spec/watirspec/html/scroll_nested.html +17 -0
- data/spec/watirspec/html/scroll_nested_offscreen.html +18 -0
- data/spec/watirspec/html/shadow_dom.html +28 -0
- data/spec/watirspec/html/special_chars.html +15 -0
- data/spec/watirspec/html/sticky_elements.html +10 -0
- data/spec/watirspec/html/tables.html +121 -0
- data/spec/watirspec/html/timeout_window_location.html +19 -0
- data/spec/watirspec/html/uneven_table.html +20 -0
- data/spec/watirspec/html/wait.html +99 -0
- data/spec/watirspec/html/watirspec.css +0 -0
- data/spec/watirspec/html/window_switching.html +22 -0
- data/spec/watirspec/radio_set_spec.rb +346 -0
- data/spec/watirspec/screenshot_spec.rb +33 -0
- data/spec/watirspec/scroll_spec.rb +208 -0
- data/spec/watirspec/shadow_root_spec.rb +108 -0
- data/spec/watirspec/support/rspec_matchers.rb +161 -0
- data/spec/watirspec/user_editable_spec.rb +207 -0
- data/spec/watirspec/wait_spec.rb +345 -0
- data/spec/watirspec/window_switching_spec.rb +580 -0
- data/spec/watirspec_helper.rb +163 -0
- data/support/doctest_helper.rb +101 -0
- data/support/version_differ.rb +60 -0
- data/watir.gemspec +50 -0
- metadata +652 -148
- data/readme.rb +0 -211
- data/unittests/WindowLogonExample.rb +0 -30
- data/unittests/WindowLogonExtra.rb +0 -7
- data/unittests/all_tests.rb +0 -10
- data/unittests/all_tests_concurrent.rb +0 -57
- data/unittests/attachToExistingWindow_test.rb +0 -40
- data/unittests/buttons_test.rb +0 -131
- data/unittests/checkbox_test.rb +0 -149
- data/unittests/core_tests.rb +0 -9
- data/unittests/css_test.rb +0 -60
- data/unittests/div_test.rb +0 -179
- data/unittests/errorchecker_test.rb +0 -29
- data/unittests/filefield_test.rb +0 -35
- data/unittests/form_test.rb +0 -279
- data/unittests/frame_test.rb +0 -141
- data/unittests/html/blankpage.html +0 -12
- data/unittests/html/buttons1.html +0 -40
- data/unittests/html/checkboxes1.html +0 -69
- data/unittests/html/complex_table.html +0 -36
- data/unittests/html/cssTest.html +0 -42
- data/unittests/html/div.html +0 -105
- data/unittests/html/fileupload.html +0 -45
- data/unittests/html/formTest1.html +0 -39
- data/unittests/html/forms2.html +0 -45
- data/unittests/html/forms3.html +0 -132
- data/unittests/html/forms4.html +0 -27
- data/unittests/html/frame_buttons.html +0 -4
- data/unittests/html/frame_links.html +0 -4
- data/unittests/html/frame_multi.html +0 -5
- data/unittests/html/iframeTest.html +0 -13
- data/unittests/html/iframeTest1.html +0 -7
- data/unittests/html/iframeTest2.html +0 -6
- data/unittests/html/images/button.jpg +0 -0
- data/unittests/html/images/circle.jpg +0 -0
- data/unittests/html/images/originaltriangle.jpg +0 -0
- data/unittests/html/images/square.jpg +0 -0
- data/unittests/html/images/triangle.jpg +0 -0
- data/unittests/html/images1.html +0 -52
- data/unittests/html/javascriptevents.html +0 -39
- data/unittests/html/link_pass.html +0 -11
- data/unittests/html/links1.html +0 -37
- data/unittests/html/links2.html +0 -11
- data/unittests/html/nestedFrames.html +0 -6
- data/unittests/html/pass.html +0 -10
- data/unittests/html/popups1.html +0 -60
- data/unittests/html/radioButtons1.html +0 -71
- data/unittests/html/select_tealeaf.html +0 -54
- data/unittests/html/selectboxes1.html +0 -55
- data/unittests/html/simple_table.html +0 -26
- data/unittests/html/simple_table_buttons.html +0 -104
- data/unittests/html/simple_table_columns.html +0 -76
- data/unittests/html/table1.html +0 -142
- data/unittests/html/textarea.html +0 -30
- data/unittests/html/textfields1.html +0 -87
- data/unittests/html/textsearch.html +0 -44
- data/unittests/ie_mock.rb +0 -93
- data/unittests/ie_test.rb +0 -50
- data/unittests/images_test.rb +0 -179
- data/unittests/iostring.rb +0 -30
- data/unittests/iostring_test.rb +0 -48
- data/unittests/js_events_test.rb +0 -77
- data/unittests/jscriptExtraAlert.rb +0 -6
- data/unittests/jscriptExtraConfirmCancel.rb +0 -7
- data/unittests/jscriptExtraConfirmOk.rb +0 -7
- data/unittests/jscriptPushButton.rb +0 -5
- data/unittests/jscript_test.rb +0 -57
- data/unittests/links_test.rb +0 -169
- data/unittests/minmax_test.rb +0 -31
- data/unittests/navigate_test.rb +0 -56
- data/unittests/non_core_tests.rb +0 -9
- data/unittests/pagecontainstext_test.rb +0 -49
- data/unittests/popups_test.rb +0 -44
- data/unittests/radios_test.rb +0 -164
- data/unittests/screen_capture_test.rb +0 -53
- data/unittests/selectbox_test.rb +0 -197
- data/unittests/send_keys_test.rb +0 -29
- data/unittests/setup.rb +0 -47
- data/unittests/table_test.rb +0 -306
- data/unittests/textAreafields_test.rb +0 -81
- data/unittests/textfields_test.rb +0 -239
- data/watir/AutoItX3.dll +0 -0
- data/watir/WindowHelper.rb +0 -47
- data/watir/camel_case.rb +0 -37
- data/watir/clickJSDialog.rb +0 -19
- data/watir/cookiemanager.rb +0 -53
- data/watir/exceptions.rb +0 -60
- data/watir/screen_capture.rb +0 -115
- data/watir/setFileDialog.rb +0 -16
- data/watir/testUnitAddons.rb +0 -47
- data/watir/watir_simple.rb +0 -475
- data/watir/winClicker.rb +0 -505
- data/watir.rb +0 -3744
- /data/{unittests → spec/watirspec}/html/images/1.gif +0 -0
- /data/{unittests/html/images/2.GIF → spec/watirspec/html/images/2.gif} +0 -0
- /data/{unittests/html/images/3.GIF → spec/watirspec/html/images/3.gif} +0 -0
- /data/{unittests/html/images/minus.GIF → spec/watirspec/html/images/minus.gif} +0 -0
- /data/{unittests → spec/watirspec}/html/images/plus.gif +0 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe Button 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 button exists (tag = :input)' do
|
|
14
|
+
expect(browser.button(id: 'new_user_submit')).to exist
|
|
15
|
+
expect(browser.button(id: /new_user_submit/)).to exist
|
|
16
|
+
expect(browser.button(name: 'new_user_reset')).to exist
|
|
17
|
+
expect(browser.button(name: /new_user_reset/)).to exist
|
|
18
|
+
expect(browser.button(value: 'Button')).to exist
|
|
19
|
+
expect(browser.button(value: /Button/)).to exist
|
|
20
|
+
expect(browser.button(src: 'images/button.png')).to exist
|
|
21
|
+
expect(browser.button(src: /button\.png/)).to exist
|
|
22
|
+
expect(browser.button(text: 'Button 2')).to exist
|
|
23
|
+
expect(browser.button(text: /Button 2/)).to exist
|
|
24
|
+
expect(browser.button(class: 'image')).to exist
|
|
25
|
+
expect(browser.button(class: /image/)).to exist
|
|
26
|
+
expect(browser.button(index: 0)).to exist
|
|
27
|
+
expect(browser.button(xpath: "//input[@id='new_user_submit']")).to exist
|
|
28
|
+
expect(browser.button(alt: 'Create a new user')).to exist
|
|
29
|
+
expect(browser.button(alt: /Create a/)).to exist
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'returns true if the button exists (tag = :button)' do
|
|
33
|
+
expect(browser.button(name: 'new_user_button_2')).to exist
|
|
34
|
+
expect(browser.button(name: /new_user_button_2/)).to exist
|
|
35
|
+
expect(browser.button(value: 'button_2')).to exist
|
|
36
|
+
expect(browser.button(value: /button_2/)).to exist
|
|
37
|
+
expect(browser.button(text: 'Button 2')).to exist
|
|
38
|
+
expect(browser.button(text: /Button 2/)).to exist
|
|
39
|
+
expect(browser.button(value: 'Button 2')).to exist
|
|
40
|
+
expect(browser.button(value: /Button 2/)).to exist
|
|
41
|
+
expect(browser.button(value: 'Button 4 With Child Text')).to exist
|
|
42
|
+
expect(browser.button(value: /Button 4 With Child Text/)).to exist
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'returns the first button if given no args' do
|
|
46
|
+
expect(browser.button).to exist
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'returns true for element with upper case type' do
|
|
50
|
+
expect(browser.button(id: 'new_user_button_preview')).to exist
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "returns false if the button doesn't exist" do
|
|
54
|
+
expect(browser.button(id: 'no_such_id')).not_to exist
|
|
55
|
+
expect(browser.button(id: /no_such_id/)).not_to exist
|
|
56
|
+
expect(browser.button(name: 'no_such_name')).not_to exist
|
|
57
|
+
expect(browser.button(name: /no_such_name/)).not_to exist
|
|
58
|
+
expect(browser.button(value: 'no_such_value')).not_to exist
|
|
59
|
+
expect(browser.button(value: /no_such_value/)).not_to exist
|
|
60
|
+
expect(browser.button(src: 'no_such_src')).not_to exist
|
|
61
|
+
expect(browser.button(src: /no_such_src/)).not_to exist
|
|
62
|
+
expect(browser.button(text: 'no_such_text')).not_to exist
|
|
63
|
+
expect(browser.button(text: /no_such_text/)).not_to exist
|
|
64
|
+
expect(browser.button(class: 'no_such_class')).not_to exist
|
|
65
|
+
expect(browser.button(class: /no_such_class/)).not_to exist
|
|
66
|
+
expect(browser.button(index: 1337)).not_to exist
|
|
67
|
+
expect(browser.button(xpath: "//input[@id='no_such_id']")).not_to exist
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'checks the tag name and type attribute when locating by xpath' do
|
|
71
|
+
expect(browser.button(xpath: "//input[@type='text']")).not_to exist
|
|
72
|
+
expect(browser.button(xpath: "//input[@type='button']")).to exist
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'matches the specific type when locating by type' do
|
|
76
|
+
expect(browser.button(type: 'button').type).to eq 'button'
|
|
77
|
+
expect(browser.button(type: 'reset').type).to eq 'reset'
|
|
78
|
+
expect(browser.button(type: 'submit').type).to eq 'submit'
|
|
79
|
+
expect(browser.button(type: 'image').type).to eq 'image'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'matches valid input types when type is boolean' do
|
|
83
|
+
expect(browser.buttons(type: false).map(&:tag_name)).to all eq('button')
|
|
84
|
+
|
|
85
|
+
input_buttons = browser.buttons(type: true).select { |e| e.tag_name == 'input' }
|
|
86
|
+
expect(input_buttons.map(&:type).uniq).to match_array(Button::VALID_TYPES)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
90
|
+
expect { browser.button(id: 3.14).exists? }.to raise_error(TypeError)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Attribute methods
|
|
95
|
+
describe '#id' do
|
|
96
|
+
it 'returns the id if the button exists' do
|
|
97
|
+
expect(browser.button(index: 0).id).to eq 'new_user_submit'
|
|
98
|
+
expect(browser.button(index: 1).id).to eq 'new_user_reset'
|
|
99
|
+
expect(browser.button(index: 2).id).to eq 'new_user_button'
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'raises UnknownObjectException if button does not exist' do
|
|
103
|
+
expect { browser.button(index: 1337).id }.to raise_unknown_object_exception
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
describe '#name' do
|
|
108
|
+
it 'returns the name if button exists' do
|
|
109
|
+
expect(browser.button(index: 0).name).to eq 'new_user_submit'
|
|
110
|
+
expect(browser.button(index: 1).name).to eq 'new_user_reset'
|
|
111
|
+
expect(browser.button(index: 2).name).to eq 'new_user_button'
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it 'raises UnknownObjectException if the button does not exist' do
|
|
115
|
+
expect { browser.button(name: 'no_such_name').name }.to raise_unknown_object_exception
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
describe '#src' do
|
|
120
|
+
it 'returns the src attribute for the button image' do
|
|
121
|
+
# varies between browsers
|
|
122
|
+
expect(browser.button(name: 'new_user_image').src).to include('images/button.png')
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'raises UnknownObjectException if the button does not exist' do
|
|
126
|
+
expect { browser.button(name: 'no_such_name').src }.to raise_unknown_object_exception
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe '#style' do
|
|
131
|
+
it 'returns the style attribute if the button exists' do
|
|
132
|
+
expect(browser.button(id: 'delete_user_submit').style).to include 'border: 4px solid red;'
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "returns an empty string if the element exists and the attribute doesn't exist" do
|
|
136
|
+
expect(browser.button(id: 'new_user_submit').style).to eq ''
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it 'raises UnknownObjectException if the button does not exist' do
|
|
140
|
+
expect { browser.button(name: 'no_such_name').style }.to raise_unknown_object_exception
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
describe '#title' do
|
|
145
|
+
it 'returns the title of the button' do
|
|
146
|
+
expect(browser.button(index: 0).title).to eq 'Submit the form'
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it 'returns an empty string for button without title' do
|
|
150
|
+
expect(browser.button(index: 1).title).to eq ''
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe '#type' do
|
|
155
|
+
it 'returns the type if button exists' do
|
|
156
|
+
expect(browser.button(index: 0).type).to eq 'submit'
|
|
157
|
+
expect(browser.button(index: 1).type).to eq 'reset'
|
|
158
|
+
expect(browser.button(index: 2).type).to eq 'button'
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it 'raises UnknownObjectException if button does not exist' do
|
|
162
|
+
expect { browser.button(name: 'no_such_name').type }.to raise_unknown_object_exception
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
describe '#value' do
|
|
167
|
+
it 'returns the value if button exists' do
|
|
168
|
+
expect(browser.button(index: 0).value).to eq 'Submit'
|
|
169
|
+
expect(browser.button(index: 1).value).to eq 'Reset'
|
|
170
|
+
expect(browser.button(index: 2).value).to eq 'Button'
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it 'raises UnknownObjectException if button does not exist' do
|
|
174
|
+
expect { browser.button(name: 'no_such_name').value }.to raise_unknown_object_exception
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
describe '#text' do
|
|
179
|
+
it 'returns the text of an input button' do
|
|
180
|
+
expect(browser.button(index: 0).text).to eq 'Submit'
|
|
181
|
+
expect(browser.button(index: 1).text).to eq 'Reset'
|
|
182
|
+
expect(browser.button(index: 2).text).to eq 'Button'
|
|
183
|
+
expect(browser.button(index: 3).text).to eq 'Preview'
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it 'returns the text of a button element' do
|
|
187
|
+
expect(browser.button(name: 'new_user_button_2').text).to eq 'Button 2'
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
|
191
|
+
expect { browser.button(id: 'no_such_id').text }.to raise_unknown_object_exception
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
describe '#respond_to?' do
|
|
196
|
+
it 'returns true for all attribute methods' do
|
|
197
|
+
expect(browser.button(index: 0)).to respond_to(:class_name)
|
|
198
|
+
expect(browser.button(index: 0)).to respond_to(:id)
|
|
199
|
+
expect(browser.button(index: 0)).to respond_to(:name)
|
|
200
|
+
expect(browser.button(index: 0)).to respond_to(:src)
|
|
201
|
+
expect(browser.button(index: 0)).to respond_to(:style)
|
|
202
|
+
expect(browser.button(index: 0)).to respond_to(:title)
|
|
203
|
+
expect(browser.button(index: 0)).to respond_to(:type)
|
|
204
|
+
expect(browser.button(index: 0)).to respond_to(:value)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Access methods
|
|
209
|
+
describe '#enabled?' do
|
|
210
|
+
it 'returns true if the button is enabled' do
|
|
211
|
+
expect(browser.button(name: 'new_user_submit')).to be_enabled
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it 'returns false if the button is disabled' do
|
|
215
|
+
expect(browser.button(name: 'new_user_submit_disabled')).not_to be_enabled
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "raises UnknownObjectException if the button doesn't exist" do
|
|
219
|
+
expect { browser.button(name: 'no_such_name').enabled? }.to raise_unknown_object_exception
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it 'raises ObjectDisabledException if disabled button is clicked' do
|
|
223
|
+
expect { browser.button(name: 'new_user_submit_disabled').click }.to raise_object_disabled_exception
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
describe '#disabled?' do
|
|
228
|
+
it 'returns false when button is enabled' do
|
|
229
|
+
expect(browser.button(name: 'new_user_submit')).not_to be_disabled
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it 'returns true when button is disabled' do
|
|
233
|
+
expect(browser.button(name: 'new_user_submit_disabled')).to be_disabled
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
it 'raises UnknownObjectException if button does not exist' do
|
|
237
|
+
expect { browser.button(name: 'no_such_name').disabled? }.to raise_unknown_object_exception
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Manipulation methods
|
|
242
|
+
describe '#click' do
|
|
243
|
+
it 'clicks the button if it exists' do
|
|
244
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
245
|
+
browser.button(id: 'delete_user_submit').click
|
|
246
|
+
browser.wait_while(url: /forms_with_input_elements\.html$/)
|
|
247
|
+
expect(browser.text).to include('Semantic table')
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
it 'fires events' do
|
|
251
|
+
browser.button(id: 'new_user_button').click
|
|
252
|
+
expect(browser.button(id: 'new_user_button').value).to eq 'new_value_set_by_onclick_event'
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
it "raises UnknownObjectException when clicking a button that doesn't exist" do
|
|
256
|
+
expect { browser.button(value: 'no_such_value').click }.to raise_unknown_object_exception
|
|
257
|
+
expect { browser.button(id: 'no_such_id').click }.to raise_unknown_object_exception
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
it 'raises ObjectDisabledException when clicking a disabled button' do
|
|
261
|
+
expect { browser.button(value: 'Disabled').click }.to raise_object_disabled_exception
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe ButtonCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.buttons(name: 'new_user_button').to_a).to eq [browser.button(name: 'new_user_button')]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the number of buttons' do
|
|
19
|
+
expect(browser.buttons.length).to eq 11
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#[]' do
|
|
24
|
+
it 'returns the button at the given index' do
|
|
25
|
+
expect(browser.buttons[0].title).to eq 'Submit the form'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#first' do
|
|
30
|
+
it 'returns the first element in the collection' do
|
|
31
|
+
expect(browser.buttons.first.value).to eq browser.buttons[0].value
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe '#last' do
|
|
36
|
+
it 'returns the last element in the collection' do
|
|
37
|
+
expect(browser.buttons.last.value).to eq browser.buttons[-1].value
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe '#each' do
|
|
42
|
+
it 'iterates through buttons correctly' do
|
|
43
|
+
count = 0
|
|
44
|
+
|
|
45
|
+
browser.buttons.each_with_index do |b, index|
|
|
46
|
+
expect(b.name).to eq browser.button(index: index).name
|
|
47
|
+
expect(b.id).to eq browser.button(index: index).id
|
|
48
|
+
expect(b.value).to eq browser.button(index: index).value
|
|
49
|
+
|
|
50
|
+
count += 1
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
expect(count).to be > 0
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
describe 'CheckBox' do
|
|
6
|
+
before do
|
|
7
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Exists method
|
|
11
|
+
|
|
12
|
+
describe '#exists?' do
|
|
13
|
+
it 'returns true if the checkbox button exists' do
|
|
14
|
+
expect(browser.checkbox(id: 'new_user_interests_books')).to exist
|
|
15
|
+
expect(browser.checkbox(id: /new_user_interests_books/)).to exist
|
|
16
|
+
expect(browser.checkbox(label: 'Cars')).to exist
|
|
17
|
+
expect(browser.checkbox(label: /Cars/)).to exist
|
|
18
|
+
expect(browser.checkbox(name: 'new_user_interests')).to exist
|
|
19
|
+
expect(browser.checkbox(name: /new_user_interests/)).to exist
|
|
20
|
+
expect(browser.checkbox(value: 'books')).to exist
|
|
21
|
+
expect(browser.checkbox(value: /books/)).to exist
|
|
22
|
+
# not sure what :text is supposed to represent here
|
|
23
|
+
# browser.checkbox(text: "books").to exist
|
|
24
|
+
# browser.checkbox(text: /books/).to exist
|
|
25
|
+
expect(browser.checkbox(class: 'fun')).to exist
|
|
26
|
+
expect(browser.checkbox(class: /fun/)).to exist
|
|
27
|
+
expect(browser.checkbox(index: 0)).to exist
|
|
28
|
+
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_books']")).to exist
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context 'when some text hidden' do
|
|
32
|
+
it 'locates matching hidden text' do
|
|
33
|
+
expect(browser.checkbox(label: /some visible/)).to exist
|
|
34
|
+
expect(browser.checkbox(label: /some (visible|Jeff)/)).to exist
|
|
35
|
+
expect(browser.checkbox(label: /none visible/)).to exist
|
|
36
|
+
expect(browser.checkbox(label: /some visible some hidden/)).to exist
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'does not locate when matches without hidden text' do
|
|
40
|
+
expect(browser.checkbox(label: /some visible$/)).not_to exist
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'returns true if the checkbox button exists (search by name and value)' do
|
|
45
|
+
expect(browser.checkbox(name: 'new_user_interests', value: 'cars')).to exist
|
|
46
|
+
browser.checkbox(xpath: "//input[@name='new_user_interests' and @value='cars']").set
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'returns the first checkbox if given no args' do
|
|
50
|
+
expect(browser.checkbox).to exist
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'returns false if the checkbox button does not exist' do
|
|
54
|
+
expect(browser.checkbox(id: 'no_such_id')).not_to exist
|
|
55
|
+
expect(browser.checkbox(id: /no_such_id/)).not_to exist
|
|
56
|
+
expect(browser.checkbox(name: 'no_such_name')).not_to exist
|
|
57
|
+
expect(browser.checkbox(name: /no_such_name/)).not_to exist
|
|
58
|
+
expect(browser.checkbox(value: 'no_such_value')).not_to exist
|
|
59
|
+
expect(browser.checkbox(value: /no_such_value/)).not_to exist
|
|
60
|
+
expect(browser.checkbox(text: 'no_such_text')).not_to exist
|
|
61
|
+
expect(browser.checkbox(text: /no_such_text/)).not_to exist
|
|
62
|
+
expect(browser.checkbox(class: 'no_such_class')).not_to exist
|
|
63
|
+
expect(browser.checkbox(class: /no_such_class/)).not_to exist
|
|
64
|
+
expect(browser.checkbox(index: 1337)).not_to exist
|
|
65
|
+
expect(browser.checkbox(xpath: "//input[@id='no_such_id']")).not_to exist
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'returns false if the checkbox button does not exist (search by name and value)' do
|
|
69
|
+
expect(browser.checkbox(name: 'new_user_interests', value: 'no_such_value')).not_to exist
|
|
70
|
+
expect(browser.checkbox(xpath: "//input[@name='new_user_interests' and @value='no_such_value']")).not_to exist
|
|
71
|
+
expect(browser.checkbox(name: 'no_such_name', value: 'cars')).not_to exist
|
|
72
|
+
expect(browser.checkbox(xpath: "//input[@name='no_such_name' and @value='cars']")).not_to exist
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'returns true for checkboxes with a string value' do
|
|
76
|
+
expect(browser.checkbox(name: 'new_user_interests', value: 'books')).to exist
|
|
77
|
+
expect(browser.checkbox(name: 'new_user_interests', value: 'cars')).to exist
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'returns true for checkbox with upper case type' do
|
|
81
|
+
expect(browser.checkbox(id: 'new_user_interests_draw')).to exist
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
85
|
+
expect { browser.checkbox(id: 3.14).exists? }.to raise_error(TypeError)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Attribute methods
|
|
90
|
+
describe '#id' do
|
|
91
|
+
it 'returns the id attribute if the checkbox exists and has an attribute' do
|
|
92
|
+
expect(browser.checkbox(index: 0).id).to eq 'new_user_interests_books'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "returns an empty string if the checkbox exists and the attribute doesn't" do
|
|
96
|
+
expect(browser.checkbox(index: 1).id).to eq ''
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
|
100
|
+
expect { browser.checkbox(index: 1337).id }.to raise_unknown_object_exception
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
describe '#name' do
|
|
105
|
+
it 'returns the name attribute if the checkbox exists' do
|
|
106
|
+
expect(browser.checkbox(id: 'new_user_interests_books').name).to eq 'new_user_interests'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "returns an empty string if the checkbox exists and the attribute doesn't" do
|
|
110
|
+
expect(browser.checkbox(id: 'new_user_interests_food').name).to eq ''
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
|
114
|
+
expect { browser.checkbox(index: 1337).name }.to raise_unknown_object_exception
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe '#title' do
|
|
119
|
+
it 'returns the title attribute if the checkbox exists' do
|
|
120
|
+
expect(browser.checkbox(id: 'new_user_interests_dancing').title).to eq 'Dancing is fun!'
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "returns an empty string if the checkbox exists and the attribute doesn't" do
|
|
124
|
+
expect(browser.checkbox(id: 'new_user_interests_books').title).to eq ''
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
|
128
|
+
expect { browser.checkbox(index: 1337).title }.to raise_unknown_object_exception
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
describe '#type' do
|
|
133
|
+
it 'returns the type attribute if the checkbox exists' do
|
|
134
|
+
expect(browser.checkbox(index: 0).type).to eq 'checkbox'
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
|
138
|
+
expect { browser.checkbox(index: 1337).type }.to raise_unknown_object_exception
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
describe '#value' do
|
|
143
|
+
it 'returns the value attribute if the checkbox exists' do
|
|
144
|
+
expect(browser.checkbox(id: 'new_user_interests_books').value).to eq 'books'
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
|
148
|
+
expect { browser.checkbox(index: 1337).value }.to raise_unknown_object_exception
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
describe '#respond_to?' do
|
|
153
|
+
it 'returns true for all attribute methods' do
|
|
154
|
+
expect(browser.checkbox(index: 0)).to respond_to(:class_name)
|
|
155
|
+
expect(browser.checkbox(index: 0)).to respond_to(:id)
|
|
156
|
+
expect(browser.checkbox(index: 0)).to respond_to(:name)
|
|
157
|
+
expect(browser.checkbox(index: 0)).to respond_to(:title)
|
|
158
|
+
expect(browser.checkbox(index: 0)).to respond_to(:type)
|
|
159
|
+
expect(browser.checkbox(index: 0)).to respond_to(:value)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
describe '#tabindex' do
|
|
164
|
+
it 'finds tab index' do
|
|
165
|
+
expect(browser.checkbox(tabindex: '4').tabindex).to eq 4
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'finds element with boolean' do
|
|
169
|
+
expect(browser.checkbox(tabindex: false).id).to eq 'toggle_button_checkbox'
|
|
170
|
+
expect(browser.checkbox(tabindex: true).id).to eq 'new_user_interests_books'
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Access methods
|
|
175
|
+
|
|
176
|
+
describe '#enabled?' do
|
|
177
|
+
it 'returns true if the checkbox button is enabled' do
|
|
178
|
+
expect(browser.checkbox(id: 'new_user_interests_books')).to be_enabled
|
|
179
|
+
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_books']")).to be_enabled
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it 'returns false if the checkbox button is disabled' do
|
|
183
|
+
expect(browser.checkbox(id: 'new_user_interests_dentistry')).not_to be_enabled
|
|
184
|
+
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_dentistry']")).not_to be_enabled
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it "raises UnknownObjectException if the checkbox button doesn't exist" do
|
|
188
|
+
expect { browser.checkbox(id: 'no_such_id').enabled? }.to raise_unknown_object_exception
|
|
189
|
+
expect { browser.checkbox(xpath: "//input[@id='no_such_id']").enabled? }.to raise_unknown_object_exception
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
describe '#disabled?' do
|
|
194
|
+
it 'returns true if the checkbox is disabled' do
|
|
195
|
+
expect(browser.checkbox(id: 'new_user_interests_dentistry')).to be_disabled
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it 'returns false if the checkbox is enabled' do
|
|
199
|
+
expect(browser.checkbox(id: 'new_user_interests_books')).not_to be_disabled
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it "raises UnknownObjectException if the checkbox doesn't exist" do
|
|
203
|
+
expect { browser.checkbox(index: 1337).disabled? }.to raise_unknown_object_exception
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Manipulation methods
|
|
208
|
+
|
|
209
|
+
describe '#clear' do
|
|
210
|
+
it 'raises ObjectDisabledException if the checkbox is disabled' do
|
|
211
|
+
expect(browser.checkbox(id: 'new_user_interests_dentistry')).not_to be_set
|
|
212
|
+
expect { browser.checkbox(id: 'new_user_interests_dentistry').clear }
|
|
213
|
+
.to raise_object_disabled_exception
|
|
214
|
+
expect { browser.checkbox(xpath: "//input[@id='new_user_interests_dentistry']").clear }
|
|
215
|
+
.to raise_object_disabled_exception
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it 'clears the checkbox button if it is set' do
|
|
219
|
+
browser.checkbox(id: 'new_user_interests_books').clear
|
|
220
|
+
expect(browser.checkbox(id: 'new_user_interests_books')).not_to be_set
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
it 'clears the checkbox button when found by :xpath' do
|
|
224
|
+
browser.checkbox(xpath: "//input[@id='new_user_interests_books']").clear
|
|
225
|
+
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_books']")).not_to be_set
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
it "raises UnknownObjectException if the checkbox button doesn't exist" do
|
|
229
|
+
expect { browser.checkbox(name: 'no_such_id').clear }.to raise_unknown_object_exception
|
|
230
|
+
expect { browser.checkbox(xpath: "//input[@id='no_such_id']").clear }.to raise_unknown_object_exception
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
describe '#set' do
|
|
235
|
+
it 'sets the checkbox button' do
|
|
236
|
+
browser.checkbox(id: 'new_user_interests_cars').set
|
|
237
|
+
expect(browser.checkbox(id: 'new_user_interests_cars')).to be_set
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
it 'sets the checkbox button when found by :xpath' do
|
|
241
|
+
browser.checkbox(xpath: "//input[@id='new_user_interests_cars']").set
|
|
242
|
+
expect(browser.checkbox(xpath: "//input[@id='new_user_interests_cars']")).to be_set
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it 'fires the onclick event' do
|
|
246
|
+
expect(browser.button(id: 'disabled_button')).to be_disabled
|
|
247
|
+
browser.checkbox(id: 'toggle_button_checkbox').set
|
|
248
|
+
expect(browser.button(id: 'disabled_button')).not_to be_disabled
|
|
249
|
+
browser.checkbox(id: 'toggle_button_checkbox').clear
|
|
250
|
+
expect(browser.button(id: 'disabled_button')).to be_disabled
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
it "raises UnknownObjectException if the checkbox button doesn't exist" do
|
|
254
|
+
expect { browser.checkbox(name: 'no_such_name').set }.to raise_unknown_object_exception
|
|
255
|
+
expect { browser.checkbox(xpath: "//input[@name='no_such_name']").set }.to raise_unknown_object_exception
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it 'raises ObjectDisabledException if the checkbox is disabled' do
|
|
259
|
+
expect { browser.checkbox(id: 'new_user_interests_dentistry').set }
|
|
260
|
+
.to raise_object_disabled_exception
|
|
261
|
+
expect { browser.checkbox(xpath: "//input[@id='new_user_interests_dentistry']").set }
|
|
262
|
+
.to raise_object_disabled_exception
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# Other
|
|
267
|
+
|
|
268
|
+
describe '#set?' do
|
|
269
|
+
it 'returns true if the checkbox button is set' do
|
|
270
|
+
expect(browser.checkbox(id: 'new_user_interests_books')).to be_set
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
it 'returns false if the checkbox button unset' do
|
|
274
|
+
expect(browser.checkbox(id: 'new_user_interests_cars')).not_to be_set
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
it 'returns the state for checkboxes with string values' do
|
|
278
|
+
expect(browser.checkbox(name: 'new_user_interests', value: 'cars')).not_to be_set
|
|
279
|
+
browser.checkbox(name: 'new_user_interests', value: 'cars').set
|
|
280
|
+
expect(browser.checkbox(name: 'new_user_interests', value: 'cars')).to be_set
|
|
281
|
+
browser.checkbox(name: 'new_user_interests', value: 'cars').clear
|
|
282
|
+
expect(browser.checkbox(name: 'new_user_interests', value: 'cars')).not_to be_set
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
it "raises UnknownObjectException if the checkbox button doesn't exist" do
|
|
286
|
+
expect { browser.checkbox(id: 'no_such_id').set? }.to raise_unknown_object_exception
|
|
287
|
+
expect { browser.checkbox(xpath: "//input[@id='no_such_id']").set? }.to raise_unknown_object_exception
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe CheckBoxCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.checkboxes(value: 'books').to_a).to eq [browser.checkbox(value: 'books')]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the number of checkboxes' do
|
|
19
|
+
expect(browser.checkboxes.length).to eq 11
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#[]' do
|
|
24
|
+
it 'returns the checkbox at the given index' do
|
|
25
|
+
expect(browser.checkboxes[0].id).to eq 'new_user_interests_books'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#each' do
|
|
30
|
+
it 'iterates through checkboxes correctly' do
|
|
31
|
+
count = 0
|
|
32
|
+
|
|
33
|
+
browser.checkboxes.each_with_index do |c, index|
|
|
34
|
+
expect(c).to be_instance_of(CheckBox)
|
|
35
|
+
expect(c.name).to eq browser.checkbox(index: index).name
|
|
36
|
+
expect(c.id).to eq browser.checkbox(index: index).id
|
|
37
|
+
expect(c.value).to eq browser.checkbox(index: index).value
|
|
38
|
+
|
|
39
|
+
count += 1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
expect(count).to be > 0
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|