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,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe SelectCollection 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
|
+
list = [browser.select_list(name: 'delete_user_username')]
|
|
14
|
+
expect(browser.select_lists(name: 'delete_user_username').to_a).to eq list
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe '#length' do
|
|
19
|
+
it 'returns the correct number of select lists on the page' do
|
|
20
|
+
expect(browser.select_lists.length).to eq 6
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe '#[]' do
|
|
25
|
+
it 'returns the correct item' do
|
|
26
|
+
expect(browser.select_lists[0].value).to eq '2'
|
|
27
|
+
expect(browser.select_lists[0].name).to eq 'new_user_country'
|
|
28
|
+
expect(browser.select_lists[0]).not_to be_multiple
|
|
29
|
+
expect(browser.select_lists[1]).to be_multiple
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#each' do
|
|
34
|
+
it 'iterates through the select lists correctly' do
|
|
35
|
+
count = 0
|
|
36
|
+
|
|
37
|
+
browser.select_lists.each_with_index do |l, index|
|
|
38
|
+
expect(browser.select_list(index: index).name).to eq l.name
|
|
39
|
+
expect(browser.select_list(index: index).id).to eq l.id
|
|
40
|
+
expect(browser.select_list(index: index).value).to eq l.value
|
|
41
|
+
|
|
42
|
+
count += 1
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
expect(count).to be > 0
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe Span do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Exists method
|
|
12
|
+
describe '#exist?' do
|
|
13
|
+
it "returns true if the 'span' exists" do
|
|
14
|
+
expect(browser.span(id: 'lead')).to exist
|
|
15
|
+
expect(browser.span(id: /lead/)).to exist
|
|
16
|
+
expect(browser.span(text: 'Dubito, ergo cogito, ergo sum.')).to exist
|
|
17
|
+
expect(browser.span(class: 'lead')).to exist
|
|
18
|
+
expect(browser.span(class: /lead/)).to exist
|
|
19
|
+
expect(browser.span(index: 0)).to exist
|
|
20
|
+
expect(browser.span(xpath: "//span[@id='lead']")).to exist
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'visible text is found by regular expression with visible text locator' do
|
|
24
|
+
expect(browser.span(visible_text: /Dubito, ergo cogito, ergo sum/)).to exist
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'returns the first span if given no args' do
|
|
28
|
+
expect(browser.span).to exist
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "returns false if the element doesn't exist" do
|
|
32
|
+
expect(browser.span(id: 'no_such_id')).not_to exist
|
|
33
|
+
expect(browser.span(id: /no_such_id/)).not_to exist
|
|
34
|
+
expect(browser.span(text: 'no_such_text')).not_to exist
|
|
35
|
+
expect(browser.span(text: /no_such_text/)).not_to exist
|
|
36
|
+
expect(browser.span(class: 'no_such_class')).not_to exist
|
|
37
|
+
expect(browser.span(class: /no_such_class/)).not_to exist
|
|
38
|
+
expect(browser.span(index: 1337)).not_to exist
|
|
39
|
+
expect(browser.span(xpath: "//span[@id='no_such_id']")).not_to exist
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
43
|
+
expect { browser.span(id: 3.14).exists? }.to raise_error(TypeError)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Attribute methods
|
|
48
|
+
describe '#id' do
|
|
49
|
+
it 'returns the id attribute' do
|
|
50
|
+
expect(browser.span(index: 0).id).to eq 'lead'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
|
54
|
+
expect(browser.span(index: 2).id).to eq ''
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "raises UnknownObjectException if the span doesn't exist" do
|
|
58
|
+
expect { browser.span(id: 'no_such_id').id }.to raise_unknown_object_exception
|
|
59
|
+
expect { browser.span(index: 1337).id }.to raise_unknown_object_exception
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe '#title' do
|
|
64
|
+
it 'returns the title attribute' do
|
|
65
|
+
expect(browser.span(index: 0).title).to eq 'Lorem ipsum'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "returns an empty string if the element exists and the attribute doesn't" do
|
|
69
|
+
expect(browser.span(index: 2).title).to eq ''
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "raises UnknownObjectException if the span doesn't exist" do
|
|
73
|
+
expect { browser.span(id: 'no_such_id').title }.to raise_unknown_object_exception
|
|
74
|
+
expect { browser.span(xpath: "//span[@id='no_such_id']").title }.to raise_unknown_object_exception
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe '#text' do
|
|
79
|
+
it 'returns the text of the span' do
|
|
80
|
+
msg = 'Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. ' \
|
|
81
|
+
'Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et ' \
|
|
82
|
+
'malesuada fames ac turpis egestas.'
|
|
83
|
+
expect(browser.span(index: 1).text).to eq msg
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "returns an empty string if the element doesn't contain any text" do
|
|
87
|
+
expect(browser.span(index: 4).text).to eq ''
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "raises UnknownObjectException if the span doesn't exist" do
|
|
91
|
+
expect { browser.span(id: 'no_such_id').text }.to raise_unknown_object_exception
|
|
92
|
+
expect { browser.span(xpath: "//span[@id='no_such_id']").text }.to raise_unknown_object_exception
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe '#respond_to?' do
|
|
97
|
+
it 'returns true for all attribute methods' do
|
|
98
|
+
expect(browser.span(index: 0)).to respond_to(:class_name)
|
|
99
|
+
expect(browser.span(index: 0)).to respond_to(:id)
|
|
100
|
+
expect(browser.span(index: 0)).to respond_to(:title)
|
|
101
|
+
expect(browser.span(index: 0)).to respond_to(:text)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Other
|
|
106
|
+
describe '#click', except: {headless: true} do
|
|
107
|
+
it 'fires events' do
|
|
108
|
+
expect(browser.span(class: 'footer').text).not_to include('Javascript')
|
|
109
|
+
browser.span(class: 'footer').click
|
|
110
|
+
expect(browser.span(class: 'footer').text).to include('Javascript')
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "raises UnknownObjectException if the span doesn't exist" do
|
|
114
|
+
expect { browser.span(id: 'no_such_id').click }.to raise_unknown_object_exception
|
|
115
|
+
expect { browser.span(title: 'no_such_title').click }.to raise_unknown_object_exception
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe SpanCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.spans(class: 'footer').to_a).to eq [browser.span(class: 'footer')]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the number of spans' do
|
|
19
|
+
expect(browser.spans.length).to eq 8
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#[]' do
|
|
24
|
+
it 'returns the p at the given index' do
|
|
25
|
+
expect(browser.spans[0].id).to eq 'lead'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#each' do
|
|
30
|
+
it 'iterates through spans correctly' do
|
|
31
|
+
count = 0
|
|
32
|
+
|
|
33
|
+
browser.spans.each_with_index do |s, index|
|
|
34
|
+
expect(s.id).to eq browser.span(index: index).id
|
|
35
|
+
count += 1
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
expect(count).to be > 0
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe 'Strong' do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Exists method
|
|
12
|
+
describe '#exist?' do
|
|
13
|
+
it 'returns true if the element exists' do
|
|
14
|
+
expect(browser.strong(id: 'descartes')).to exist
|
|
15
|
+
expect(browser.strong(id: /descartes/)).to exist
|
|
16
|
+
expect(browser.strong(text: 'Dubito, ergo cogito, ergo sum.')).to exist
|
|
17
|
+
expect(browser.strong(class: 'descartes')).to exist
|
|
18
|
+
expect(browser.strong(class: /descartes/)).to exist
|
|
19
|
+
expect(browser.strong(index: 0)).to exist
|
|
20
|
+
expect(browser.strong(xpath: "//strong[@id='descartes']")).to exist
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'visible text is found by regular expression with text locator' do
|
|
24
|
+
expect(browser.strong(visible_text: /Dubito, ergo cogito, ergo sum/)).to exist
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'returns the first strong if given no args' do
|
|
28
|
+
expect(browser.strong).to exist
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "returns false if the element doesn't exist" do
|
|
32
|
+
expect(browser.strong(id: 'no_such_id')).not_to exist
|
|
33
|
+
expect(browser.strong(id: /no_such_id/)).not_to exist
|
|
34
|
+
expect(browser.strong(text: 'no_such_text')).not_to exist
|
|
35
|
+
expect(browser.strong(text: /no_such_text/)).not_to exist
|
|
36
|
+
expect(browser.strong(class: 'no_such_class')).not_to exist
|
|
37
|
+
expect(browser.strong(class: /no_such_class/)).not_to exist
|
|
38
|
+
expect(browser.strong(index: 1337)).not_to exist
|
|
39
|
+
expect(browser.strong(xpath: "//strong[@id='no_such_id']")).not_to exist
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
43
|
+
expect { browser.strong(id: 3.14).exists? }.to raise_error(TypeError)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Attribute methods
|
|
48
|
+
describe '#id' do
|
|
49
|
+
it 'returns the id attribute' do
|
|
50
|
+
expect(browser.strong(index: 0).id).to eq 'descartes'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "raises UnknownObjectException if the element doesn't exist" do
|
|
54
|
+
expect { browser.strong(id: 'no_such_id').id }.to raise_unknown_object_exception
|
|
55
|
+
expect { browser.strong(index: 1337).id }.to raise_unknown_object_exception
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe '#text' do
|
|
60
|
+
it 'returns the text of the element' do
|
|
61
|
+
expect(browser.strong(index: 0).text).to eq 'Dubito, ergo cogito, ergo sum.'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "raises UnknownObjectException if the element doesn't exist" do
|
|
65
|
+
expect { browser.strong(id: 'no_such_id').text }.to raise_unknown_object_exception
|
|
66
|
+
expect { browser.strong(xpath: "//strong[@id='no_such_id']").text }.to raise_unknown_object_exception
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#respond_to?' do
|
|
71
|
+
it 'returns true for all attribute methods' do
|
|
72
|
+
expect(browser.strong(index: 0)).to respond_to(:class_name)
|
|
73
|
+
expect(browser.strong(index: 0)).to respond_to(:id)
|
|
74
|
+
expect(browser.strong(index: 0)).to respond_to(:text)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe 'Strongs' do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.strongs(class: 'descartes').to_a).to eq [browser.strong(class: 'descartes')]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the number of divs' do
|
|
19
|
+
expect(browser.strongs.length).to eq 2
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#[]' do
|
|
24
|
+
it 'returns the div at the given index' do
|
|
25
|
+
expect(browser.strongs[0].id).to eq 'descartes'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#each' do
|
|
30
|
+
it 'iterates through divs correctly' do
|
|
31
|
+
count = 0
|
|
32
|
+
|
|
33
|
+
browser.strongs.each_with_index do |s, index|
|
|
34
|
+
strong = browser.strong(index: index)
|
|
35
|
+
expect(s.id).to eq strong.id
|
|
36
|
+
expect(s.class_name).to eq strong.class_name
|
|
37
|
+
|
|
38
|
+
count += 1
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
expect(count).to be > 0
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe Table do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('tables.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Exists
|
|
12
|
+
describe '#exists?' do
|
|
13
|
+
it 'returns true if the table exists' do
|
|
14
|
+
expect(browser.table(id: 'axis_example')).to exist
|
|
15
|
+
expect(browser.table(id: /axis_example/)).to exist
|
|
16
|
+
expect(browser.table(index: 0)).to exist
|
|
17
|
+
expect(browser.table(xpath: "//table[@id='axis_example']")).to exist
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'returns the first table if given no args' do
|
|
21
|
+
expect(browser.table).to exist
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'returns false if the table does not exist' do
|
|
25
|
+
expect(browser.table(id: 'no_such_id')).not_to exist
|
|
26
|
+
expect(browser.table(id: /no_such_id/)).not_to exist
|
|
27
|
+
expect(browser.table(index: 1337)).not_to exist
|
|
28
|
+
expect(browser.table(xpath: "//table[@id='no_such_id']")).not_to exist
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'checks the tag name when locating by xpath' do
|
|
32
|
+
expect(browser.table(xpath: '//table//td')).not_to exist
|
|
33
|
+
expect(browser.table(xpath: '//table')).to exist
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
37
|
+
expect { browser.table(id: 3.14).exists? }.to raise_error(TypeError)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Other
|
|
42
|
+
describe '#strings', except: {browser: :safari, reason: 'Safari does not strip text'} do
|
|
43
|
+
it 'returns a two-dimensional array representation of the table' do
|
|
44
|
+
expect(browser.table(id: 'inner').strings).to eq [
|
|
45
|
+
['Table 2, Row 1, Cell 1',
|
|
46
|
+
'Table 2, Row 1, Cell 2']
|
|
47
|
+
]
|
|
48
|
+
expect(browser.table(id: 'outer').strings).to eq [
|
|
49
|
+
['Table 1, Row 1, Cell 1', 'Table 1, Row 1, Cell 2'],
|
|
50
|
+
['Table 1, Row 2, Cell 1',
|
|
51
|
+
"Table 1, Row 2, Cell 2\nTable 2, Row 1, Cell 1 Table 2, Row 1, Cell 2"],
|
|
52
|
+
['Table 1, Row 3, Cell 1', 'Table 1, Row 3, Cell 2']
|
|
53
|
+
]
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe '#headers' do
|
|
58
|
+
it 'returns the first row of a table as the header row' do
|
|
59
|
+
headers = browser.table(id: 'axis_example').headers
|
|
60
|
+
expect(headers).to be_a Watir::TableHeaderCellCollection
|
|
61
|
+
expect(headers.size).to eq 4
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe '#hashes' do
|
|
66
|
+
it 'returns an Array of Hashes for the common table usage' do
|
|
67
|
+
array = [
|
|
68
|
+
{'' => 'March 2008', 'Before income tax' => '', 'Income tax' => '', 'After income tax' => ''},
|
|
69
|
+
{'' => 'Gregory House', 'Before income tax' => '5 934', 'Income tax' => '1 347',
|
|
70
|
+
'After income tax' => '4 587'},
|
|
71
|
+
{'' => 'Hugh Laurie', 'Before income tax' => '6 300', 'Income tax' => '1 479', 'After income tax' => '4 821'},
|
|
72
|
+
{'' => 'April 2008', 'Before income tax' => '', 'Income tax' => '', 'After income tax' => ''},
|
|
73
|
+
{'' => 'Gregory House', 'Before income tax' => '5 863', 'Income tax' => '1 331',
|
|
74
|
+
'After income tax' => '4 532'},
|
|
75
|
+
{'' => 'Hugh Laurie', 'Before income tax' => '6 252', 'Income tax' => '1 420', 'After income tax' => '4 832'},
|
|
76
|
+
{'' => 'Sum', 'Before income tax' => '24 349', 'Income tax' => '5 577', 'After income tax' => '18 722'}
|
|
77
|
+
]
|
|
78
|
+
expect(browser.table(id: 'axis_example').hashes).to eq array
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'raises an error if the table could not be parsed' do
|
|
82
|
+
browser.goto(WatirSpec.url_for('uneven_table.html'))
|
|
83
|
+
|
|
84
|
+
expect {
|
|
85
|
+
browser.table.hashes
|
|
86
|
+
}.to raise_error('row at index 0 has 2 cells, while header row has 3')
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe '#click' do
|
|
91
|
+
it "fires the table's onclick event" do
|
|
92
|
+
browser.table(id: 'inner').click
|
|
93
|
+
expect(messages).to include('table')
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe '#[]' do
|
|
98
|
+
it 'returns the nth child row' do
|
|
99
|
+
expect(browser.table(id: 'outer')[0].id).to eq 'outer_first'
|
|
100
|
+
expect(browser.table(id: 'inner')[0].id).to eq 'inner_first'
|
|
101
|
+
expect(browser.table(id: 'outer')[2].id).to eq 'outer_last'
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe '#row' do
|
|
106
|
+
let(:table) { browser.table(id: 'outer') }
|
|
107
|
+
|
|
108
|
+
it 'finds rows belonging to this table' do
|
|
109
|
+
expect(table.row(id: 'outer_last')).to exist
|
|
110
|
+
expect(table.row(text: /Table 1, Row 1, Cell 1/)).to exist
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'does not find rows from a nested table' do
|
|
114
|
+
expect(table.row(id: 'inner_first')).not_to exist
|
|
115
|
+
expect(table.row(text: /\ATable 2, Row 1, Cell 1 Table 2, Row 1, Cell 2\z/)).not_to exist
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
describe '#rows' do
|
|
120
|
+
it 'finds the correct number of rows (excluding nested tables)' do
|
|
121
|
+
expect(browser.table(id: 'inner').rows.length).to eq 1
|
|
122
|
+
expect(browser.table(id: 'outer').rows.length).to eq 3
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'finds rows matching the selector' do
|
|
126
|
+
rows = browser.table(id: 'outer').rows(id: /first|last/)
|
|
127
|
+
|
|
128
|
+
expect(rows.first.id).to eq 'outer_first'
|
|
129
|
+
expect(rows.last.id).to eq 'outer_last'
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'does not find rows from a nested table' do
|
|
133
|
+
expect(browser.table(id: 'outer').rows(id: 't2_r1_c1').size).to eq 0
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
describe '#tbody' do
|
|
138
|
+
it 'returns the correct instance of TableSection' do
|
|
139
|
+
body = browser.table(index: 0).tbody(id: 'first')
|
|
140
|
+
expect(body).to be_instance_of(Watir::TableSection)
|
|
141
|
+
expect(body[0][0].text).to eq 'March 2008'
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
describe '#tbodys' do
|
|
146
|
+
it 'returns the correct instance of TableSection' do
|
|
147
|
+
bodies = browser.table(index: 0).tbodys
|
|
148
|
+
|
|
149
|
+
expect(bodies).to be_instance_of(Watir::TableSectionCollection)
|
|
150
|
+
|
|
151
|
+
expect(bodies[0].id).to eq 'first'
|
|
152
|
+
expect(bodies[1].id).to eq 'second'
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
describe '#each' do
|
|
157
|
+
it 'allows iterating over the rows in a table' do
|
|
158
|
+
expect(browser.table(id: 'inner').to_a).to all be_a Watir::Row
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
context 'when nested' do
|
|
163
|
+
before do
|
|
164
|
+
browser.goto(WatirSpec.url_for('nested_tables.html'))
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it 'returns the correct number of rows under a table element' do
|
|
168
|
+
tables = browser.div(id: 'table-rows-test').tables(id: /^tbl/)
|
|
169
|
+
expect(tables.length).to be > 0
|
|
170
|
+
|
|
171
|
+
tables.each do |table|
|
|
172
|
+
expected = Integer(table.data_row_count)
|
|
173
|
+
actual = table.rows.length
|
|
174
|
+
browser_count = Integer(table.data_browser_count)
|
|
175
|
+
|
|
176
|
+
msg = "expected #{expected} rows, got #{actual} for table id=#{table.id}, browser reported: #{browser_count}"
|
|
177
|
+
expect(actual).to eql(expected), msg
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it 'returns the correct number of cells under a row' do
|
|
182
|
+
rows = browser.div(id: 'row-cells-test').trs(id: /^row/)
|
|
183
|
+
expect(rows.length).to be > 0
|
|
184
|
+
|
|
185
|
+
rows.each do |row|
|
|
186
|
+
expected = Integer(row.data_cell_count)
|
|
187
|
+
actual = row.cells.length
|
|
188
|
+
browser_count = Integer(row.data_browser_count)
|
|
189
|
+
|
|
190
|
+
msg = "expected #{expected} cells, got #{actual} for row id=#{row.id}, browser reported: #{browser_count}"
|
|
191
|
+
expect(actual).to eql(expected), msg
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it 'returns the correct number of rows under a table section' do
|
|
196
|
+
tbodies = browser.table(id: 'tbody-rows-test').tbodys(id: /^body/)
|
|
197
|
+
expect(tbodies.length).to be > 0
|
|
198
|
+
|
|
199
|
+
tbodies.each do |tbody|
|
|
200
|
+
expected = Integer(tbody.data_rows_count)
|
|
201
|
+
actual = tbody.rows.count
|
|
202
|
+
browser_count = Integer(tbody.data_browser_count)
|
|
203
|
+
|
|
204
|
+
msg = "expected #{expected} rows, got #{actual} for tbody id=#{tbody.id}, browser reported: #{browser_count}"
|
|
205
|
+
expect(actual).to eql(expected), msg
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe TableCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('tables.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.tables(rules: 'groups').to_a).to eq [browser.table(rules: 'groups')]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the number of tables' do
|
|
19
|
+
expect(browser.tables.length).to eq 4
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#[]' do
|
|
24
|
+
it 'returns the p at the given index' do
|
|
25
|
+
expect(browser.tables[0].id).to eq 'axis_example'
|
|
26
|
+
expect(browser.tables[1].id).to eq 'outer'
|
|
27
|
+
expect(browser.tables[2].id).to eq 'inner'
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#each' do
|
|
32
|
+
it 'iterates through tables correctly' do
|
|
33
|
+
count = 0
|
|
34
|
+
|
|
35
|
+
browser.tables.each_with_index do |t, index|
|
|
36
|
+
expect(t.id).to eq browser.table(index: index).id
|
|
37
|
+
count += 1
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
expect(count).to be > 0
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe 'TableBody' do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('tables.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe '#exists?' do
|
|
12
|
+
it 'returns true if the table body exists (page context)' do
|
|
13
|
+
expect(browser.tbody(id: 'first')).to exist
|
|
14
|
+
expect(browser.tbody(id: /first/)).to exist
|
|
15
|
+
expect(browser.tbody(index: 0)).to exist
|
|
16
|
+
expect(browser.tbody(xpath: "//tbody[@id='first']")).to exist
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'returns true if the table body exists (table context)' do
|
|
20
|
+
expect(browser.table(index: 0).tbody(id: 'first')).to exist
|
|
21
|
+
expect(browser.table(index: 0).tbody(id: /first/)).to exist
|
|
22
|
+
expect(browser.table(index: 0).tbody(index: 1)).to exist
|
|
23
|
+
expect(browser.table(index: 0).tbody(xpath: "//tbody[@id='first']")).to exist
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'returns the first table body if given no args' do
|
|
27
|
+
expect(browser.table.tbody).to exist
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "returns false if the table body doesn't exist (page context)" do
|
|
31
|
+
expect(browser.tbody(id: 'no_such_id')).not_to exist
|
|
32
|
+
expect(browser.tbody(id: /no_such_id/)).not_to exist
|
|
33
|
+
expect(browser.tbody(index: 1337)).not_to exist
|
|
34
|
+
expect(browser.tbody(xpath: "//tbody[@id='no_such_id']")).not_to exist
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "returns false if the table body doesn't exist (table context)" do
|
|
38
|
+
expect(browser.table(index: 0).tbody(id: 'no_such_id')).not_to exist
|
|
39
|
+
expect(browser.table(index: 0).tbody(id: /no_such_id/)).not_to exist
|
|
40
|
+
expect(browser.table(index: 0).tbody(index: 1337)).not_to exist
|
|
41
|
+
expect(browser.table(index: 0).tbody(xpath: "//tbody[@id='no_such_id']")).not_to exist
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
45
|
+
expect { browser.tbody(id: 3.14).exists? }.to raise_error(TypeError)
|
|
46
|
+
expect { browser.table(index: 0).tbody(id: 3.14).exists? }.to raise_error(TypeError)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '#[]', except: {browser: :safari, reason: 'Safari does not strip text'} do
|
|
51
|
+
it 'returns the row at the given index (page context)' do
|
|
52
|
+
expect(browser.tbody(id: 'first')[0].text).to eq 'March 2008'
|
|
53
|
+
expect(browser.tbody(id: 'first')[1][0].text).to eq 'Gregory House'
|
|
54
|
+
expect(browser.tbody(id: 'first')[2][0].text).to eq 'Hugh Laurie'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'returns the row at the given index (table context)' do
|
|
58
|
+
expect(browser.table(index: 0).tbody(id: 'first')[0].text).to eq 'March 2008'
|
|
59
|
+
expect(browser.table(index: 0).tbody(id: 'first')[1][0].text).to eq 'Gregory House'
|
|
60
|
+
expect(browser.table(index: 0).tbody(id: 'first')[2][0].text).to eq 'Hugh Laurie'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe '#row' do
|
|
65
|
+
it 'finds the first row matching the selector' do
|
|
66
|
+
row = browser.tbody(id: 'first').row(id: 'gregory')
|
|
67
|
+
|
|
68
|
+
expect(row.tag_name).to eq 'tr'
|
|
69
|
+
expect(row.id).to eq 'gregory'
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe '#rows' do
|
|
74
|
+
it 'finds rows matching the selector' do
|
|
75
|
+
rows = browser.tbody(id: 'first').rows(id: /h$/)
|
|
76
|
+
|
|
77
|
+
expect(rows.size).to eq 2
|
|
78
|
+
|
|
79
|
+
expect(rows.first.id).to eq 'march'
|
|
80
|
+
expect(rows.last.id).to eq 'hugh'
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe '#strings' do
|
|
85
|
+
it 'returns the text of child cells' do
|
|
86
|
+
expect(browser.tbody(id: 'first').strings).to eq [
|
|
87
|
+
['March 2008', '', '', ''],
|
|
88
|
+
['Gregory House', '5 934', '1 347', '4 587'],
|
|
89
|
+
['Hugh Laurie', '6 300', '1 479', '4 821']
|
|
90
|
+
]
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|