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,208 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe Scrolling do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('scroll.html'))
|
|
9
|
+
pause
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def top_centered_viewport
|
|
13
|
+
browser.execute_script('return (window.innerHeight - document.body.scrollHeight)/2;')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def current_top
|
|
17
|
+
browser.execute_script('return document.body.getBoundingClientRect().top;')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'when scrolling Browser' do
|
|
21
|
+
describe '#to' do
|
|
22
|
+
it 'scrolls to the top of the page' do
|
|
23
|
+
browser.scroll.to :bottom
|
|
24
|
+
expect(browser.div(id: 'top')).not_to be_in_viewport
|
|
25
|
+
browser.scroll.to :top
|
|
26
|
+
expect(browser.div(id: 'top')).to be_in_viewport
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'scrolls to the center of the page' do
|
|
30
|
+
browser.scroll.to :center
|
|
31
|
+
viewport_top = browser.execute_script('return document.body.getBoundingClientRect().top;')
|
|
32
|
+
|
|
33
|
+
expect(viewport_top).to be_within(1).of(top_centered_viewport)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'scrolls to the bottom of the page' do
|
|
37
|
+
expect(browser.div(id: 'bottom')).not_to be_in_viewport
|
|
38
|
+
browser.scroll.to :bottom
|
|
39
|
+
expect(browser.div(id: 'bottom')).to be_in_viewport
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'scrolls to coordinates' do
|
|
43
|
+
element = browser.div(id: 'center')
|
|
44
|
+
location = element.location
|
|
45
|
+
browser.scroll.to [location.x, location.y]
|
|
46
|
+
expect(element).to be_in_viewport
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'raises error when scroll point is not valid' do
|
|
50
|
+
expect { browser.scroll.to(:blah) }.to raise_error(ArgumentError)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe '#by' do
|
|
55
|
+
before do
|
|
56
|
+
browser.scroll.to :top
|
|
57
|
+
pause
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'offset from top' do
|
|
61
|
+
initial_top = current_top
|
|
62
|
+
scroll_by = top_centered_viewport.round
|
|
63
|
+
browser.scroll.by(0, -scroll_by)
|
|
64
|
+
pause
|
|
65
|
+
puts "scroll by #{scroll_by}"
|
|
66
|
+
puts "initial top #{initial_top}"
|
|
67
|
+
puts "current top #{current_top}"
|
|
68
|
+
expect(current_top).to be_within(1).of(scroll_by + initial_top)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'offset from bottom' do
|
|
72
|
+
initial_top = current_top
|
|
73
|
+
browser.scroll.to :bottom
|
|
74
|
+
scroll_by = top_centered_viewport
|
|
75
|
+
browser.scroll.by(0, scroll_by)
|
|
76
|
+
pause
|
|
77
|
+
expect(current_top).to be_within(1).of(scroll_by + initial_top)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe '#from' do
|
|
82
|
+
it 'scrolls by given amount with offset', except: {browser: :ie, reason: 'Not implemented'} do
|
|
83
|
+
browser.goto(WatirSpec.url_for('scroll_nested.html'))
|
|
84
|
+
|
|
85
|
+
browser.scroll.from(10, 10).by(0, 225)
|
|
86
|
+
|
|
87
|
+
expect(in_viewport?(browser.iframe.checkbox(name: 'scroll_checkbox'))).to be true
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context 'when scrolling Element' do
|
|
93
|
+
describe '#to' do
|
|
94
|
+
it 'scrolls element into view (viewport)',
|
|
95
|
+
except: [{browser: %i[firefox safari], reason: 'incorrect MoveTargetOutOfBoundsError'},
|
|
96
|
+
{browser: :ie, reason: 'Not implemented'}] do
|
|
97
|
+
browser.goto(WatirSpec.url_for('scroll_nested_offscreen.html'))
|
|
98
|
+
iframe = browser.iframe
|
|
99
|
+
|
|
100
|
+
expect(in_viewport?(iframe)).to be false
|
|
101
|
+
|
|
102
|
+
iframe.scroll.to(:viewport)
|
|
103
|
+
|
|
104
|
+
expect(in_viewport?(iframe)).to be true
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'scrolls to element (top) by default' do
|
|
108
|
+
element = browser.div(id: 'center')
|
|
109
|
+
element.scroll.to
|
|
110
|
+
|
|
111
|
+
element_top = browser.execute_script('return arguments[0].getBoundingClientRect().top', element)
|
|
112
|
+
expect(element_top).to be_within(1).of(0)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it 'scrolls to element (center)' do
|
|
116
|
+
element = browser.div(id: 'center')
|
|
117
|
+
element.scroll.to :center
|
|
118
|
+
|
|
119
|
+
element_rect = browser.execute_script('return arguments[0].getBoundingClientRect()', element)
|
|
120
|
+
|
|
121
|
+
expect(element_rect['top']).to eq(element_rect['bottom'] - element_rect['height'])
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'scrolls to element (bottom)' do
|
|
125
|
+
element = browser.div(id: 'center')
|
|
126
|
+
element.scroll.to :bottom
|
|
127
|
+
|
|
128
|
+
element_bottom = browser.execute_script('return arguments[0].getBoundingClientRect().bottom', element)
|
|
129
|
+
window_height = browser.execute_script('return window.innerHeight')
|
|
130
|
+
|
|
131
|
+
expect(element_bottom).to be_within(1).of(window_height)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'scrolls to element multiple times' do
|
|
135
|
+
2.times do
|
|
136
|
+
element = browser.div(id: 'center')
|
|
137
|
+
element.scroll.to(:center)
|
|
138
|
+
|
|
139
|
+
element_rect = browser.execute_script('return arguments[0].getBoundingClientRect()', element)
|
|
140
|
+
|
|
141
|
+
expect(element_rect['top']).to eq(element_rect['bottom'] - element_rect['height'])
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it 'raises error when scroll param is not valid' do
|
|
146
|
+
expect { browser.div(id: 'top').scroll.to(:blah) }.to raise_error(ArgumentError)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe '#by' do
|
|
151
|
+
it 'offset' do
|
|
152
|
+
browser.scroll.to :top
|
|
153
|
+
pause
|
|
154
|
+
initial_top = current_top
|
|
155
|
+
browser.scroll.to :bottom
|
|
156
|
+
pause
|
|
157
|
+
scroll_by = top_centered_viewport
|
|
158
|
+
|
|
159
|
+
element = browser.div(id: 'bottom')
|
|
160
|
+
element.scroll.by(0, scroll_by)
|
|
161
|
+
pause
|
|
162
|
+
expect(current_top).to be_within(1).of(scroll_by + initial_top)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
describe '#from',
|
|
167
|
+
except: [{browser: %i[firefox safari], reason: 'incorrect MoveTargetOutOfBoundsError'},
|
|
168
|
+
{browser: :ie, reason: 'Not implemented'}] do
|
|
169
|
+
it 'scrolls from element by given amount' do
|
|
170
|
+
browser.goto(WatirSpec.url_for('scroll_nested_offscreen.html'))
|
|
171
|
+
iframe = browser.iframe
|
|
172
|
+
|
|
173
|
+
iframe.scroll.from.by(0, 200)
|
|
174
|
+
|
|
175
|
+
checkbox = iframe.checkbox(name: 'scroll_checkbox')
|
|
176
|
+
expect(in_viewport?(checkbox)).to be true
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it 'scrolls from an element with an offset' do
|
|
180
|
+
browser.goto(WatirSpec.url_for('scroll_nested_offscreen.html'))
|
|
181
|
+
|
|
182
|
+
move_left = browser.execute_script('return arguments[0].getBoundingClientRect().width/2', browser.footer) -
|
|
183
|
+
browser.execute_script('return arguments[0].getBoundingClientRect().right/2', browser.iframe.we)
|
|
184
|
+
|
|
185
|
+
browser.footer.scroll.from(-move_left.round, -50).by(0, 200)
|
|
186
|
+
|
|
187
|
+
checkbox = browser.iframe.checkbox(name: 'scroll_checkbox')
|
|
188
|
+
expect(in_viewport?(checkbox)).to be true
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def in_viewport?(element)
|
|
194
|
+
in_viewport = <<~IN_VIEWPORT
|
|
195
|
+
for(var e=arguments[0],f=e.offsetTop,t=e.offsetLeft,o=e.offsetWidth,n=e.offsetHeight;
|
|
196
|
+
e.offsetParent;)f+=(e=e.offsetParent).offsetTop,t+=e.offsetLeft;
|
|
197
|
+
return f<window.pageYOffset+window.innerHeight&&t<window.pageXOffset+window.innerWidth&&f+n>
|
|
198
|
+
window.pageYOffset&&t+o>window.pageXOffset
|
|
199
|
+
IN_VIEWPORT
|
|
200
|
+
|
|
201
|
+
element.browser.execute_script(in_viewport, element.we)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def pause
|
|
205
|
+
sleep 0.2
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe ShadowRoot do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('shadow_dom.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
context 'with errors' do
|
|
12
|
+
it 'returns false when element does not exist' do
|
|
13
|
+
missing_shadow_root = browser.div(id: 'does_not_exist').shadow_root
|
|
14
|
+
expect(missing_shadow_root).not_to exist
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'raises ArgumentError when using :xpath to locate elements directly from the shadow root' do
|
|
18
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
19
|
+
expect { shadow_root.element(xpath: './/span').exists? }.to raise_exception(ArgumentError)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'returns false when locating element in shadow root that does not exist',
|
|
23
|
+
except: {browser: %i[ie safari], reason: 'shadow endpoint not recognized'} do
|
|
24
|
+
missing_shadow_root = browser.div(id: 'non_host').shadow_root
|
|
25
|
+
expect(missing_shadow_root.element).not_to exist
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context 'without errors', only: {browser: %i[firefox chrome edge]} do
|
|
30
|
+
describe '#exists?' do
|
|
31
|
+
it 'returns true when element has a shadow DOM' do
|
|
32
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
33
|
+
expect(shadow_root).to exist
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'returns false when element does not have a shadow DOM' do
|
|
37
|
+
missing_shadow_root = browser.div(id: 'non_host').shadow_root
|
|
38
|
+
expect(missing_shadow_root).not_to exist
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe 'locating' do
|
|
43
|
+
it 'locates a nested element' do
|
|
44
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
45
|
+
expect(shadow_root.element.id).to eq('shadow_content')
|
|
46
|
+
expect(shadow_root.element(id: 'nested_shadow_host').id).to eq('nested_shadow_host')
|
|
47
|
+
expect(shadow_root.element(id: /nested_shadow_.+/).id).to eq('nested_shadow_host')
|
|
48
|
+
expect(shadow_root.element(css: 'div').id).to eq('nested_shadow_host')
|
|
49
|
+
expect(shadow_root.div.id).to eq('nested_shadow_host')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'locates a collection of nested elements' do
|
|
53
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
54
|
+
expect(shadow_root.elements.count).to eq(8)
|
|
55
|
+
expect(shadow_root.elements(id: 'nested_shadow_host').map(&:id)).to eq(['nested_shadow_host'])
|
|
56
|
+
expect(shadow_root.elements(id: /nested_shadow_.+/).map(&:id)).to eq(['nested_shadow_host'])
|
|
57
|
+
expect(shadow_root.elements(css: 'div').map(&:id)).to eq(%w[nested_shadow_host chrome_workaround])
|
|
58
|
+
expect(shadow_root.divs.map(&:id)).to eq(%w[nested_shadow_host chrome_workaround])
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it 'locates a nested element within a nested shadow DOM' do
|
|
62
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
63
|
+
nested_shadow_root = shadow_root.element(id: 'nested_shadow_host').shadow_root
|
|
64
|
+
expect(nested_shadow_root.element.id).to eq('nested_shadow_content')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'locates a collection of nested elements within a nested shadow DOM' do
|
|
68
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
69
|
+
nested_shadow_root = shadow_root.element(id: 'nested_shadow_host').shadow_root
|
|
70
|
+
expect(nested_shadow_root.elements.count).to eq(2)
|
|
71
|
+
expect(nested_shadow_root.elements.map(&:id)).to include('nested_shadow_content')
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'allows using :xpath to locate elements with an element of a shadow root' do
|
|
75
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
76
|
+
expect(shadow_root.span.element(xpath: './/span')).to exist
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'click elements within the shadow dom' do
|
|
80
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
81
|
+
shadow_root.link.click
|
|
82
|
+
expect(browser.url).to include('scroll.html')
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'click! elements within the shadow dom' do
|
|
86
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
87
|
+
shadow_root.link.click!
|
|
88
|
+
|
|
89
|
+
browser.wait_while(url: /shadow_dom|blank/)
|
|
90
|
+
expect(browser.url).to include('scroll.html')
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'inputs form elements within the shadow dom' do
|
|
94
|
+
shadow_root = browser.div(id: 'shadow_host').shadow_root
|
|
95
|
+
|
|
96
|
+
shadow_root.text_field.set('abc')
|
|
97
|
+
expect(shadow_root.text_field.value).to eq('abc')
|
|
98
|
+
|
|
99
|
+
shadow_root.checkbox.set
|
|
100
|
+
expect(shadow_root.checkbox.set?).to be(true)
|
|
101
|
+
|
|
102
|
+
shadow_root.file_field.set(File.expand_path(__FILE__))
|
|
103
|
+
expect(shadow_root.file_field.value).to include('shadow_root_spec.rb')
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
if defined?(RSpec)
|
|
4
|
+
LEVELS = %w[warning info deprecated].freeze
|
|
5
|
+
|
|
6
|
+
LEVELS.each do |level|
|
|
7
|
+
RSpec::Matchers.define "have_#{level}" do |entry|
|
|
8
|
+
match do |actual|
|
|
9
|
+
# Suppresses logging output to stdout while ensuring that it is still happening
|
|
10
|
+
default_output = Watir.logger.io
|
|
11
|
+
io = StringIO.new
|
|
12
|
+
Watir.logger.output = io
|
|
13
|
+
|
|
14
|
+
begin
|
|
15
|
+
actual.call
|
|
16
|
+
rescue StandardError => e
|
|
17
|
+
raise e, 'Can not evaluate output when statement raises an exception'
|
|
18
|
+
ensure
|
|
19
|
+
Watir.logger.output = default_output
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@entries_found = (io.rewind && io.read).scan(/\[:([^\]]*)\]/).flatten.map(&:to_sym)
|
|
23
|
+
expect(Array(entry).sort).to eq(@entries_found.sort)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
failure_message do
|
|
27
|
+
but_message = if @entries_found.nil? || @entries_found.empty?
|
|
28
|
+
"no #{entry} entries were reported"
|
|
29
|
+
else
|
|
30
|
+
"instead these entries were found: [#{@entries_found.join(', ')}]"
|
|
31
|
+
end
|
|
32
|
+
"expected :#{entry} to have been logged, but #{but_message}"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
failure_message_when_negated do
|
|
36
|
+
but_message = "it was found among these entries: [#{@entries_found.join(', ')}]"
|
|
37
|
+
"expected :#{entry} not to have been logged, but #{but_message}"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def supports_block_expectations?
|
|
41
|
+
true
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
TIMING_EXCEPTIONS = {
|
|
47
|
+
unknown_object: Watir::Exception::UnknownObjectException,
|
|
48
|
+
no_matching_window: Watir::Exception::NoMatchingWindowFoundException,
|
|
49
|
+
unknown_frame: Watir::Exception::UnknownFrameException,
|
|
50
|
+
object_disabled: Watir::Exception::ObjectDisabledException,
|
|
51
|
+
object_read_only: Watir::Exception::ObjectReadOnlyException,
|
|
52
|
+
no_value_found: Watir::Exception::NoValueFoundException,
|
|
53
|
+
timeout: Watir::Wait::TimeoutError
|
|
54
|
+
}.freeze
|
|
55
|
+
|
|
56
|
+
TIMING_EXCEPTIONS.each do |matcher, exception|
|
|
57
|
+
RSpec::Matchers.define "raise_#{matcher}_exception" do |message|
|
|
58
|
+
match do |actual|
|
|
59
|
+
original_timeout = Watir.default_timeout
|
|
60
|
+
Watir.default_timeout = 0
|
|
61
|
+
begin
|
|
62
|
+
actual.call
|
|
63
|
+
false
|
|
64
|
+
rescue exception => e
|
|
65
|
+
return true if message.nil? || e.message.match(message)
|
|
66
|
+
|
|
67
|
+
raise exception, "expected '#{message}' to be included in: '#{e.message}'"
|
|
68
|
+
ensure
|
|
69
|
+
Watir.default_timeout = original_timeout
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
failure_message do |_actual|
|
|
74
|
+
"expected #{exception} but nothing was raised"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def supports_block_expectations?
|
|
78
|
+
true
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
RSpec::Matchers.define "wait_and_raise_#{matcher}_exception" do |message = nil, timeout: 2|
|
|
83
|
+
match do |actual|
|
|
84
|
+
original_timeout = Watir.default_timeout
|
|
85
|
+
Watir.default_timeout = timeout
|
|
86
|
+
begin
|
|
87
|
+
start_time = Time.now
|
|
88
|
+
actual.call
|
|
89
|
+
false
|
|
90
|
+
rescue exception => e
|
|
91
|
+
finish_time = Time.now
|
|
92
|
+
unless message.nil? || e.message.match(message)
|
|
93
|
+
raise exception, "expected '#{message}' to be included in: '#{e.message}'"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
@time_difference = finish_time - start_time
|
|
97
|
+
@time_difference > timeout
|
|
98
|
+
ensure
|
|
99
|
+
Watir.default_timeout = original_timeout
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
failure_message do
|
|
104
|
+
if @time_difference
|
|
105
|
+
"expected action to take more than provided timeout (#{timeout} seconds), " \
|
|
106
|
+
"instead it took #{@time_difference} seconds"
|
|
107
|
+
else
|
|
108
|
+
"expected #{exception} but nothing was raised"
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def supports_block_expectations?
|
|
113
|
+
true
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
RSpec::Matchers.define :execute_when_satisfied do |min: 0, max: nil|
|
|
119
|
+
max ||= min + 1
|
|
120
|
+
match do |actual|
|
|
121
|
+
original_timeout = Watir.default_timeout
|
|
122
|
+
Watir.default_timeout = max
|
|
123
|
+
begin
|
|
124
|
+
start_time = Time.now
|
|
125
|
+
actual.call
|
|
126
|
+
@time_difference = Time.now - start_time
|
|
127
|
+
@time_difference > min && @time_difference < max
|
|
128
|
+
ensure
|
|
129
|
+
Watir.default_timeout = original_timeout
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
failure_message_when_negated do
|
|
134
|
+
"expected action to take less than #{min} seconds or more than #{max} seconds, " \
|
|
135
|
+
"instead it took #{@time_difference} seconds"
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
failure_message do
|
|
139
|
+
"expected action to take more than #{min} seconds and less than #{max} seconds, " \
|
|
140
|
+
"instead it took #{@time_difference} seconds"
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def supports_block_expectations?
|
|
144
|
+
true
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
RSpec::Matchers.define :exist do |*args|
|
|
149
|
+
match do |actual|
|
|
150
|
+
actual.exist?(*args)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
failure_message do |obj|
|
|
154
|
+
"expected #{obj.inspect} to exist"
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
failure_message_when_negated do |obj|
|
|
158
|
+
"expected #{obj.inspect} to not exist"
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe UserEditable do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe '#append' do
|
|
12
|
+
it 'appends the text to the text field', except: {browser: :safari, reason: 'incorrectly clears first'} do
|
|
13
|
+
browser.text_field(name: 'new_user_occupation').append(' Append This')
|
|
14
|
+
expect(browser.text_field(name: 'new_user_occupation').value).to eq 'Developer Append This'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'appends multi-byte characters', except: {browser: :safari, reason: 'incorrectly clears first'} do
|
|
18
|
+
browser.text_field(name: 'new_user_occupation').append(' ijij')
|
|
19
|
+
expect(browser.text_field(name: 'new_user_occupation').value).to eq 'Developer ijij'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'raises NotImplementedError if the object is content editable element' do
|
|
23
|
+
msg = '#append method is not supported with contenteditable element'
|
|
24
|
+
expect { browser.div(id: 'contenteditable').append('bar') }.to raise_exception(NotImplementedError, msg)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'raises ObjectReadOnlyException if the object is read only' do
|
|
28
|
+
expect { browser.text_field(id: 'new_user_code').append('Append This') }.to raise_object_read_only_exception
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'raises ObjectDisabledException if the object is disabled' do
|
|
32
|
+
expect { browser.text_field(name: 'new_user_species').append('Append This') }.to raise_object_disabled_exception
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "raises UnknownObjectException if the object doesn't exist" do
|
|
36
|
+
expect { browser.text_field(name: 'no_such_name').append('Append This') }.to raise_unknown_object_exception
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '#clear' do
|
|
41
|
+
it 'removes all text from the text field' do
|
|
42
|
+
browser.text_field(name: 'new_user_occupation').clear
|
|
43
|
+
expect(browser.text_field(name: 'new_user_occupation').value).to be_empty
|
|
44
|
+
browser.textarea(id: 'delete_user_comment').clear
|
|
45
|
+
expect(browser.textarea(id: 'delete_user_comment').value).to be_empty
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'removes all text from the content editable element' do
|
|
49
|
+
browser.div(id: 'contenteditable').clear
|
|
50
|
+
expect(browser.div(id: 'contenteditable').text).to eq ''
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
|
54
|
+
expect { browser.text_field(id: 'no_such_id').clear }.to raise_unknown_object_exception
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'raises ObjectReadOnlyException if the object is read only' do
|
|
58
|
+
expect { browser.text_field(id: 'new_user_code').clear }.to raise_object_read_only_exception
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe '#value=' do
|
|
63
|
+
it 'sets the value of the element' do
|
|
64
|
+
browser.text_field(id: 'new_user_email').value = 'Hello Cruel World'
|
|
65
|
+
expect(browser.text_field(id: 'new_user_email').value).to eq 'Hello Cruel World'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'is able to set multi-byte characters' do
|
|
69
|
+
browser.text_field(name: 'new_user_occupation').value = 'ijij'
|
|
70
|
+
expect(browser.text_field(name: 'new_user_occupation').value).to eq 'ijij'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'sets the value of a textarea element' do
|
|
74
|
+
browser.textarea(id: 'delete_user_comment').value = 'Hello Cruel World'
|
|
75
|
+
expect(browser.textarea(id: 'delete_user_comment').value).to eq 'Hello Cruel World'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
|
79
|
+
expect { browser.text_field(name: 'no_such_name').value = 'yo' }.to raise_unknown_object_exception
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe '#set' do
|
|
84
|
+
it 'sets the value of the element' do
|
|
85
|
+
browser.text_field(id: 'new_user_email').set('Bye Cruel World')
|
|
86
|
+
expect(browser.text_field(id: 'new_user_email').value).to eq 'Bye Cruel World'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'sets the value of a textarea element' do
|
|
90
|
+
browser.textarea(id: 'delete_user_comment').set('Hello Cruel World')
|
|
91
|
+
expect(browser.textarea(id: 'delete_user_comment').value).to eq 'Hello Cruel World'
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'sets the value of a content editable element' do
|
|
95
|
+
browser.div(id: 'contenteditable').set('Bar')
|
|
96
|
+
expect(browser.div(id: 'contenteditable').text).to eq 'Bar'
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'fires events' do
|
|
100
|
+
browser.text_field(id: 'new_user_username').set('Hello World')
|
|
101
|
+
expect(browser.span(id: 'current_length').text).to eq '11'
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'sets the value of a password field' do
|
|
105
|
+
browser.text_field(name: 'new_user_password').set('secret')
|
|
106
|
+
expect(browser.text_field(name: 'new_user_password').value).to eq 'secret'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'sets the value when accessed through the enclosing Form' do
|
|
110
|
+
browser.form(id: 'new_user').text_field(name: 'new_user_password').set('secret')
|
|
111
|
+
expect(browser.form(id: 'new_user').text_field(name: 'new_user_password').value).to eq 'secret'
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it 'is able to set multi-byte characters' do
|
|
115
|
+
browser.text_field(name: 'new_user_occupation').set('ijij')
|
|
116
|
+
expect(browser.text_field(name: 'new_user_occupation').value).to eq 'ijij'
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it 'sets the value to a concatenation of multiple arguments' do
|
|
120
|
+
browser.text_field(id: 'new_user_email').set('Bye', 'Cruel', 'World')
|
|
121
|
+
expect(browser.text_field(id: 'new_user_email').value).to eq 'ByeCruelWorld'
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'sets the value to blank when no arguments are provided' do
|
|
125
|
+
browser.text_field(id: 'new_user_email').set
|
|
126
|
+
expect(browser.text_field(id: 'new_user_email').value).to eq ''
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
|
130
|
+
expect { browser.text_field(id: 'no_such_id').set('secret') }.to raise_unknown_object_exception
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it 'raises ObjectReadOnlyException if the object is read only' do
|
|
134
|
+
expect { browser.text_field(id: 'new_user_code').set('Foo') }.to raise_object_read_only_exception
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
describe '#set!' do
|
|
139
|
+
it 'sets the value of the element' do
|
|
140
|
+
browser.text_field(id: 'new_user_email').set!('Bye Cruel World')
|
|
141
|
+
expect(browser.text_field(id: 'new_user_email').value).to eq 'Bye Cruel World'
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it 'sets the value of a textarea element' do
|
|
145
|
+
browser.textarea(id: 'delete_user_comment').set!('Hello Cruel World')
|
|
146
|
+
expect(browser.textarea(id: 'delete_user_comment').value).to eq 'Hello Cruel World'
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it 'sets the value of a content editable element' do
|
|
150
|
+
browser.div(id: 'contenteditable').set!('foo')
|
|
151
|
+
expect(browser.div(id: 'contenteditable').text).to eq 'foo'
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it 'fires events' do
|
|
155
|
+
browser.text_field(id: 'new_user_username').set!('Hello World')
|
|
156
|
+
expect(browser.span(id: 'current_length').text).to eq '11'
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'sets the value of a password field' do
|
|
160
|
+
browser.text_field(name: 'new_user_password').set!('secret')
|
|
161
|
+
expect(browser.text_field(name: 'new_user_password').value).to eq 'secret'
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it 'sets the value when accessed through the enclosing Form' do
|
|
165
|
+
browser.form(id: 'new_user').text_field(name: 'new_user_password').set!('secret')
|
|
166
|
+
expect(browser.form(id: 'new_user').text_field(name: 'new_user_password').value).to eq 'secret'
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it 'is able to set multi-byte characters' do
|
|
170
|
+
browser.text_field(name: 'new_user_occupation').set!('ijij')
|
|
171
|
+
expect(browser.text_field(name: 'new_user_occupation').value).to eq 'ijij'
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it 'sets the value to a concatenation of multiple arguments' do
|
|
175
|
+
browser.text_field(id: 'new_user_email').set!('Bye', 'Cruel', 'World')
|
|
176
|
+
expect(browser.text_field(id: 'new_user_email').value).to eq 'ByeCruelWorld'
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it 'sets the value to blank when no arguments are provided' do
|
|
180
|
+
browser.text_field(id: 'new_user_email').set!
|
|
181
|
+
expect(browser.text_field(id: 'new_user_email').value).to eq ''
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it 'raises ArgumentError for special keys' do
|
|
185
|
+
expect { browser.text_field(id: 'new_user_email').set!('a', :tab) }.to raise_error(ArgumentError)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
|
189
|
+
expect { browser.text_field(id: 'no_such_id').set!('secret') }.to raise_unknown_object_exception
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it "raises Exception if the value of text field doesn't match" do
|
|
193
|
+
element = browser.text_field(id: 'new_user_password')
|
|
194
|
+
allow(element).to receive(:value).and_return('wrong')
|
|
195
|
+
msg = "#set! value: 'wrong' does not match expected input: 'secret'"
|
|
196
|
+
expect { element.set!('secret') }.to raise_exception(Watir::Exception::Error, msg)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "raises Exception if the text of content editable element doesn't match" do
|
|
200
|
+
element = browser.div(id: 'contenteditable')
|
|
201
|
+
allow(element).to receive(:text).and_return('wrong')
|
|
202
|
+
msg = "#set! text: 'wrong' does not match expected input: 'secret'"
|
|
203
|
+
expect { element.set!('secret') }.to raise_exception(Watir::Exception::Error, msg)
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
end
|