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
data/Gemfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
|
+
|
|
5
|
+
gem 'webidl', path: File.expand_path('../webidl') if ENV['LOCAL_WEBIDL']
|
|
6
|
+
|
|
7
|
+
if ENV['LOCAL_SELENIUM']
|
|
8
|
+
ENV['RUBYOPT'] = '-I../selenium/bazel-bin/rb'
|
|
9
|
+
gem 'selenium-webdriver', path: File.expand_path('../selenium/rb')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
gem 'ffi' if Gem.win_platform? # For selenium-webdriver on Windows
|
|
13
|
+
|
|
14
|
+
# Specify your gem's dependencies in watir.gemspec
|
|
15
|
+
gemspec
|
data/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
(the MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2009-2015 Jari Bakken
|
|
4
|
+
Copyright (c) 2015-2023 Alex Rodionov, Titus Fortner
|
|
5
|
+
Copyright (c) 2018-2023 Justin Ko
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
8
|
+
a copy of this software and associated documentation files (the
|
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
13
|
+
the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be
|
|
16
|
+
included in all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# watir
|
|
2
|
+
|
|
3
|
+
Watir Powered By Selenium!
|
|
4
|
+
|
|
5
|
+
[](http://badge.fury.io/rb/watir)
|
|
6
|
+
[](https://github.com/watir/watir/actions/workflows/chrome.yml)
|
|
7
|
+
[](https://github.com/watir/watir/actions/workflows/edge.yml)
|
|
8
|
+
[](https://github.com/watir/watir/actions/workflows/firefox.yml)
|
|
9
|
+
[](https://github.com/watir/watir/actions/workflows/ie.yml)
|
|
10
|
+
[](https://github.com/watir/watir/actions/workflows/safari.yml)
|
|
11
|
+
[](https://github.com/watir/watir/actions/workflows/unit.yml)
|
|
12
|
+
|
|
13
|
+
## Using Watir
|
|
14
|
+
|
|
15
|
+
This README is for people interested in writing code for Watir or gems in the Watir ecosystem
|
|
16
|
+
that leverage private-api Watir code.
|
|
17
|
+
|
|
18
|
+
For our users, everything you'll need is on the [Watir website](http://watir.com):
|
|
19
|
+
examples, news, guides, additional resources, support information and more.
|
|
20
|
+
|
|
21
|
+
## Procedure for Patches/Pull Requests
|
|
22
|
+
|
|
23
|
+
* Fork the project.
|
|
24
|
+
* Clone onto your local machine.
|
|
25
|
+
* Create a new feature branch (bonus points for good names).
|
|
26
|
+
* Make your feature addition or bug fix.
|
|
27
|
+
* Add tests for it. This is important so we don't unintentionally break it in a future version.
|
|
28
|
+
* Commit, do not change Rakefile, gemspec, or CHANGES files, we'll take care of that on release.
|
|
29
|
+
* Make sure it is passing doctests.
|
|
30
|
+
* Make sure it is passing rubocop.
|
|
31
|
+
* Push to your forked repository.
|
|
32
|
+
* Send a pull request.
|
|
33
|
+
|
|
34
|
+
## Developing Extensions
|
|
35
|
+
|
|
36
|
+
When developing a gem intended to be used with Watir, you can run your code with WatirSpec
|
|
37
|
+
to make sure that requiring your code does not break something else in Watir.
|
|
38
|
+
|
|
39
|
+
First, add WatirSpec Rake tasks to your gem:
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
# Rakefile
|
|
43
|
+
require 'watirspec/rake_tasks'
|
|
44
|
+
WatirSpec::RakeTasks.new
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Second, initialize WatirSpec for your gem:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
$ bundle exec rake watirspec:init
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This command will walk you through how to customize your code.
|
|
54
|
+
|
|
55
|
+
## Automatic Element Generation
|
|
56
|
+
|
|
57
|
+
The majority of element methods Watir provides is autogenerated from specifications.
|
|
58
|
+
This is done by extracting the IDL parts from the spec and processing them with the
|
|
59
|
+
[WebIDL gem](https://github.com/jarib/webidl).
|
|
60
|
+
|
|
61
|
+
Generated elements are currently based on the following specifications:
|
|
62
|
+
|
|
63
|
+
* [HTML](https://www.w3.org/TR/2017/REC-html52-20171214/) (`lib/watir/elements/html_elements.rb`)
|
|
64
|
+
* [SVG](https://www.w3.org/TR/2018/CR-SVG2-20180807/) (`lib/watir/elements/svg_elements.rb`)
|
|
65
|
+
|
|
66
|
+
To run:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
$ bundle exec rake html:update
|
|
70
|
+
$ bundle exec rake svg:update
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Specs
|
|
74
|
+
|
|
75
|
+
#### Github Actions
|
|
76
|
+
|
|
77
|
+
Watir specs are run with [Github Actions](https://github.com/watir/watir/tree/main/.github/workflows).
|
|
78
|
+
|
|
79
|
+
Watir code is tested on Linux with latest versions of supported browsers and all active Ruby versions.
|
|
80
|
+
|
|
81
|
+
#### Doctests
|
|
82
|
+
|
|
83
|
+
Watir uses [yard-doctest](https://github.com/p0deje/yard-doctest) to directly test
|
|
84
|
+
our documentation examples.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
mkdir ~/.yard
|
|
88
|
+
bundle exec yard config -a autoload_plugins yard-doctest
|
|
89
|
+
rake yard:doctest
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Coveralls
|
|
93
|
+
|
|
94
|
+
Watir code is run through [Coveralls](https://coveralls.io/github/watir/watir) to encourage PRs
|
|
95
|
+
to ensure all paths in their code have tests associated with them.
|
|
96
|
+
|
|
97
|
+
#### Rubocop
|
|
98
|
+
|
|
99
|
+
Watir is using [Rubocop](https://github.com/rubocop/rubocop) to ensure a consistent style across the
|
|
100
|
+
code base. It is run with our minimum supported Ruby version (2.3)
|
|
101
|
+
We have some established exceptions at `.rubocop.yml`
|
|
102
|
+
that might need to be tweaked for new code submissions. This can be addressed in the PR as necessary.
|
|
103
|
+
|
|
104
|
+
#### Statistics
|
|
105
|
+
|
|
106
|
+
Element specs are run with
|
|
107
|
+
[Selenium Statistics gem](https://github.com/titusfortner/selenium_statistics)
|
|
108
|
+
to verify that changes to the code do not dramatically decrease the performance based
|
|
109
|
+
on wire calls.
|
|
110
|
+
|
|
111
|
+
## Copyright
|
|
112
|
+
|
|
113
|
+
See LICENSE for details
|
data/Rakefile
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
|
4
|
+
|
|
5
|
+
require 'bundler'
|
|
6
|
+
Bundler::GemHelper.install_tasks
|
|
7
|
+
|
|
8
|
+
require 'rspec/core/rake_task'
|
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
10
|
+
spec.rspec_opts = %w[--color --format doc]
|
|
11
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
12
|
+
spec.exclude_pattern = 'spec/unit/**/*_spec.rb'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
require 'rubocop/rake_task'
|
|
16
|
+
|
|
17
|
+
RuboCop::RakeTask.new(:rubocop) do |t|
|
|
18
|
+
t.options = ['--display-cop-names']
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
{
|
|
22
|
+
html: 'https://www.w3.org/TR/html52/single-page.html',
|
|
23
|
+
svg: 'https://www.w3.org/TR/2018/CR-SVG2-20180807/single-page.html'
|
|
24
|
+
}.each do |type, spec_uri|
|
|
25
|
+
namespace type do
|
|
26
|
+
spec_path = "support/#{type}.html"
|
|
27
|
+
|
|
28
|
+
desc 'require generator'
|
|
29
|
+
task generator_lib: :lib do
|
|
30
|
+
require 'watir/generator'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
desc "Download #{type.upcase} spec from #{spec_uri}"
|
|
34
|
+
task :download do
|
|
35
|
+
require 'open-uri'
|
|
36
|
+
mv spec_path, "#{spec_path}.old" if File.exist?(spec_path)
|
|
37
|
+
downloaded_bytes = 0
|
|
38
|
+
|
|
39
|
+
File.open(spec_path, 'w') do |io|
|
|
40
|
+
io << "<!-- downloaded from #{spec_uri} on #{Time.now} -->\n"
|
|
41
|
+
io << data = URI.parse(spec_uri).read
|
|
42
|
+
downloaded_bytes = data.bytesize
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
puts "#{spec_uri} => #{spec_path} (#{downloaded_bytes} bytes)"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
desc "Print IDL parts from #{spec_uri}"
|
|
49
|
+
task print: :generator_lib do
|
|
50
|
+
extractor = Watir::Generator.const_get("#{type.upcase}::SpecExtractor").new(spec_path)
|
|
51
|
+
|
|
52
|
+
extractor.process.each do |tag_name, interface_definitions|
|
|
53
|
+
puts "#{tag_name.ljust(10)} => #{interface_definitions.map(&:name)}"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
extractor.print_hierarchy
|
|
57
|
+
|
|
58
|
+
if extractor.errors.any?
|
|
59
|
+
puts "\n\n<======================= ERRORS =======================>\n\n"
|
|
60
|
+
puts extractor.errors.join("\n#{'=' * 80}\n")
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
desc 'Re-generate the base Watir element classes from the spec'
|
|
65
|
+
task generate: :generator_lib do
|
|
66
|
+
old_file = "lib/watir/elements/#{type}_elements.rb"
|
|
67
|
+
generator = Watir::Generator.const_get(type.upcase).new
|
|
68
|
+
|
|
69
|
+
File.open("#{old_file}.new", 'w') do |file|
|
|
70
|
+
generator.generate(spec_path, file)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
system "diff -Naut #{old_file} #{old_file}.new" if File.exist?(old_file)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
desc "Move #{type}.rb.new to #{type}.rb"
|
|
77
|
+
task :overwrite do
|
|
78
|
+
file = "lib/watir/elements/#{type}_elements.rb"
|
|
79
|
+
mv "#{file}.new", file
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
desc "download spec -> generate -> #{type}.rb"
|
|
83
|
+
task update: %i[download generate overwrite]
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
require 'yard'
|
|
88
|
+
YARD::Rake::YardocTask.new do |task|
|
|
89
|
+
task.options = %w[--debug] # this is pretty slow, so nice with some output
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
require 'yard/doctest/rake'
|
|
93
|
+
YARD::Doctest::RakeTask.new do |task|
|
|
94
|
+
task.doctest_opts = ['-v']
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
namespace :changes do
|
|
98
|
+
desc 'Show how versions differ'
|
|
99
|
+
task :differ do
|
|
100
|
+
require './support/version_differ'
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
desc 'Update CHANGES.md'
|
|
104
|
+
task update: :differ do
|
|
105
|
+
VersionDiffer.new.update('CHANGES.md')
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
desc 'Generate CHANGES.md from scratch'
|
|
109
|
+
task generate: :differ do
|
|
110
|
+
VersionDiffer.new.generate('CHANGES.md')
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
desc 'Print latest diff'
|
|
114
|
+
task print: :differ do
|
|
115
|
+
VersionDiffer.new.print_latest($stdout)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
task default: [:spec, 'yard:doctest']
|
|
120
|
+
|
|
121
|
+
namespace :spec do
|
|
122
|
+
RSpec::Core::RakeTask.new(:html) do |spec|
|
|
123
|
+
spec.rspec_opts = "--format html --out #{ENV['SPEC_REPORT'] || 'specs.html'}"
|
|
124
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
require 'selenium-webdriver'
|
|
128
|
+
|
|
129
|
+
desc 'Run specs in all browsers'
|
|
130
|
+
task all_browsers: %i[browsers remote_browsers]
|
|
131
|
+
|
|
132
|
+
desc 'Run specs locally for all browsers'
|
|
133
|
+
task browsers: [:chrome,
|
|
134
|
+
:firefox,
|
|
135
|
+
(:safari if Selenium::WebDriver::Platform.mac?),
|
|
136
|
+
(:ie if Selenium::WebDriver::Platform.windows?),
|
|
137
|
+
(:edge if Selenium::WebDriver::Platform.windows?)].compact
|
|
138
|
+
|
|
139
|
+
desc 'Run specs remotely for all browsers'
|
|
140
|
+
task remote_browsers: [:remote_chrome,
|
|
141
|
+
:remote_firefox,
|
|
142
|
+
(:remote_safari if Selenium::WebDriver::Platform.mac?),
|
|
143
|
+
(:remote_ie if Selenium::WebDriver::Platform.windows?),
|
|
144
|
+
(:remote_edge if Selenium::WebDriver::Platform.windows?)].compact
|
|
145
|
+
|
|
146
|
+
%w[firefox chrome safari ie edge].each do |browser|
|
|
147
|
+
desc "Run specs in #{browser}"
|
|
148
|
+
task browser do
|
|
149
|
+
ENV['WATIR_BROWSER'] = browser
|
|
150
|
+
Rake::Task[:spec].execute
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
desc "Run specs in Remote #{browser}"
|
|
154
|
+
task "remote_#{browser}" do
|
|
155
|
+
ENV['WATIR_BROWSER'] = browser
|
|
156
|
+
ENV['USE_REMOTE'] = 'true'
|
|
157
|
+
Rake::Task[:spec].execute
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
desc 'Run the Unit tests'
|
|
162
|
+
RSpec::Core::RakeTask.new(:unit) do |spec|
|
|
163
|
+
spec.pattern = 'spec/unit/**/**_spec.rb'
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
desc 'Run element location specs and report wire calls'
|
|
167
|
+
RSpec::Core::RakeTask.new(:stats) do |spec|
|
|
168
|
+
ENV['SELENIUM_STATS'] = 'true'
|
|
169
|
+
spec.pattern = 'spec/**/**_spec.rb'
|
|
170
|
+
spec.exclude_pattern = '**/window_switching_spec.rb, **/browser_spec.rb, **/after_hooks_spec.rb, ' \
|
|
171
|
+
'**/alert_spec.rb, **/wait_spec.rb, **/screenshot_spec.rb'
|
|
172
|
+
end
|
|
173
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Watir
|
|
4
|
+
module Adjacent
|
|
5
|
+
#
|
|
6
|
+
# Returns parent element of current element.
|
|
7
|
+
#
|
|
8
|
+
# @example
|
|
9
|
+
# browser.text_field(name: "new_user_first_name").parent == browser.fieldset
|
|
10
|
+
# #=> true
|
|
11
|
+
#
|
|
12
|
+
|
|
13
|
+
def parent(opt = {})
|
|
14
|
+
xpath_adjacent(opt.merge(adjacent: :ancestor, plural: false))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#
|
|
18
|
+
# Returns preceding sibling element of current element.
|
|
19
|
+
#
|
|
20
|
+
# @example
|
|
21
|
+
# browser.text_field(name: "new_user_first_name").preceding_sibling(index: 1) == browser.legend
|
|
22
|
+
# #=> true
|
|
23
|
+
#
|
|
24
|
+
|
|
25
|
+
def preceding_sibling(opt = {})
|
|
26
|
+
xpath_adjacent(opt.merge(adjacent: :preceding, plural: false))
|
|
27
|
+
end
|
|
28
|
+
alias previous_sibling preceding_sibling
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# Returns collection of preceding sibling elements of current element.
|
|
32
|
+
#
|
|
33
|
+
# @example
|
|
34
|
+
# browser.text_field(name: "new_user_first_name").preceding_siblings.size
|
|
35
|
+
# #=> 3
|
|
36
|
+
#
|
|
37
|
+
|
|
38
|
+
def preceding_siblings(opt = {})
|
|
39
|
+
raise ArgumentError, '#previous_siblings can not take an index value' if opt[:index]
|
|
40
|
+
|
|
41
|
+
xpath_adjacent(opt.merge(adjacent: :preceding, plural: true))
|
|
42
|
+
end
|
|
43
|
+
alias previous_siblings preceding_siblings
|
|
44
|
+
|
|
45
|
+
#
|
|
46
|
+
# Returns following sibling element of current element.
|
|
47
|
+
#
|
|
48
|
+
# @example
|
|
49
|
+
# following_sibling = browser.text_field(name: "new_user_first_name").following_sibling(index: 2)
|
|
50
|
+
# following_sibling == browser.text_field(id: "new_user_last_name")
|
|
51
|
+
# #=> true
|
|
52
|
+
#
|
|
53
|
+
|
|
54
|
+
def following_sibling(opt = {})
|
|
55
|
+
xpath_adjacent(opt.merge(adjacent: :following, plural: false))
|
|
56
|
+
end
|
|
57
|
+
alias next_sibling following_sibling
|
|
58
|
+
|
|
59
|
+
#
|
|
60
|
+
# Returns collection of following sibling elements of current element.
|
|
61
|
+
#
|
|
62
|
+
# @example
|
|
63
|
+
# browser.text_field(name: "new_user_first_name").following_siblings.size
|
|
64
|
+
# #=> 55
|
|
65
|
+
#
|
|
66
|
+
|
|
67
|
+
def following_siblings(opt = {})
|
|
68
|
+
raise ArgumentError, '#next_siblings can not take an index value' if opt[:index]
|
|
69
|
+
|
|
70
|
+
xpath_adjacent(opt.merge(adjacent: :following, plural: true))
|
|
71
|
+
end
|
|
72
|
+
alias next_siblings following_siblings
|
|
73
|
+
|
|
74
|
+
#
|
|
75
|
+
# Returns collection of siblings of current element, including current element.
|
|
76
|
+
#
|
|
77
|
+
# @example
|
|
78
|
+
# browser.text_field(name: "new_user_first_name").siblings.size
|
|
79
|
+
# #=> 59
|
|
80
|
+
#
|
|
81
|
+
|
|
82
|
+
def siblings(opt = {})
|
|
83
|
+
parent.children(opt)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
#
|
|
87
|
+
# Returns element of direct child of current element.
|
|
88
|
+
#
|
|
89
|
+
# @example
|
|
90
|
+
# browser.form(id: "new_user").child == browser.fieldset
|
|
91
|
+
# #=> true
|
|
92
|
+
#
|
|
93
|
+
|
|
94
|
+
def child(opt = {})
|
|
95
|
+
xpath_adjacent(opt.merge(adjacent: :child, plural: false))
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
#
|
|
99
|
+
# Returns collection of elements of direct children of current element.
|
|
100
|
+
#
|
|
101
|
+
# @example
|
|
102
|
+
# children = browser.select_list(id: "new_user_languages").children
|
|
103
|
+
# children == browser.select_list(id: "new_user_languages").options.to_a
|
|
104
|
+
# #=> true
|
|
105
|
+
#
|
|
106
|
+
|
|
107
|
+
def children(opt = {})
|
|
108
|
+
raise ArgumentError, '#children can not take an index value' if opt[:index]
|
|
109
|
+
|
|
110
|
+
xpath_adjacent(opt.merge(adjacent: :child, plural: true))
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
private
|
|
114
|
+
|
|
115
|
+
def xpath_adjacent(opt = {})
|
|
116
|
+
plural = opt.delete(:plural)
|
|
117
|
+
opt[:index] ||= 0 unless plural || opt.values.any?(Regexp)
|
|
118
|
+
if !plural
|
|
119
|
+
el = Watir.element_class_for(opt[:tag_name] || '').new(self, opt)
|
|
120
|
+
el.is_a?(Input) ? el.to_subtype : el
|
|
121
|
+
elsif opt[:tag_name]
|
|
122
|
+
Watir.const_get("#{Watir.element_class_for(opt[:tag_name])}Collection").new(self, opt)
|
|
123
|
+
else
|
|
124
|
+
HTMLElementCollection.new(self, opt)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end # Adjacent
|
|
128
|
+
end # Watir
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Watir
|
|
4
|
+
#
|
|
5
|
+
# After hooks are blocks that run after certain browser events.
|
|
6
|
+
# They are generally used to ensure application under test does not encounter
|
|
7
|
+
# any error and are automatically executed after following events:
|
|
8
|
+
# 1. Open URL.
|
|
9
|
+
# 2. Refresh page.
|
|
10
|
+
# 3. Click, double-click or right-click on element.
|
|
11
|
+
# 4. Alert closing.
|
|
12
|
+
#
|
|
13
|
+
|
|
14
|
+
class AfterHooks
|
|
15
|
+
include Enumerable
|
|
16
|
+
|
|
17
|
+
def initialize(browser)
|
|
18
|
+
@browser = browser
|
|
19
|
+
@after_hooks = []
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#
|
|
23
|
+
# Adds new after hook.
|
|
24
|
+
#
|
|
25
|
+
# @example
|
|
26
|
+
# browser.after_hooks.add do |browser|
|
|
27
|
+
# browser.text.include?("Server Error") and puts "Application exception or 500 error!"
|
|
28
|
+
# end
|
|
29
|
+
# browser.goto "watir.com/404"
|
|
30
|
+
# "Application exception or 500 error!"
|
|
31
|
+
#
|
|
32
|
+
# @param [#call] after_hook Object responding to call
|
|
33
|
+
# @yield after_hook block
|
|
34
|
+
# @yieldparam [Watir::Browser]
|
|
35
|
+
#
|
|
36
|
+
|
|
37
|
+
def add(after_hook = nil, &block)
|
|
38
|
+
if block
|
|
39
|
+
@after_hooks << block
|
|
40
|
+
elsif after_hook.respond_to? :call
|
|
41
|
+
@after_hooks << after_hook
|
|
42
|
+
else
|
|
43
|
+
raise ArgumentError, 'expected block or object responding to #call'
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
alias << add
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# Deletes after hook.
|
|
50
|
+
#
|
|
51
|
+
# @example
|
|
52
|
+
# browser.after_hooks.add do |browser|
|
|
53
|
+
# browser.text.include?("Server Error") and puts "Application exception or 500 error!"
|
|
54
|
+
# end
|
|
55
|
+
# browser.goto "watir.com/404"
|
|
56
|
+
# "Application exception or 500 error!"
|
|
57
|
+
# browser.after_hooks.delete browser.after_hooks[0]
|
|
58
|
+
# browser.refresh
|
|
59
|
+
#
|
|
60
|
+
|
|
61
|
+
def delete(after_hook)
|
|
62
|
+
@after_hooks.delete(after_hook)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
#
|
|
66
|
+
# Runs after hooks.
|
|
67
|
+
#
|
|
68
|
+
|
|
69
|
+
def run
|
|
70
|
+
# We can't just rescue exception because Firefox automatically closes alert when exception raised
|
|
71
|
+
return unless @after_hooks.any? && !@browser.alert.exists?
|
|
72
|
+
|
|
73
|
+
each { |after_hook| after_hook.call(@browser) }
|
|
74
|
+
rescue Selenium::WebDriver::Error::NoSuchWindowError => e
|
|
75
|
+
Watir.logger.info "Could not execute After Hooks because browser window was closed #{e}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# Executes a block without running error after hooks.
|
|
80
|
+
#
|
|
81
|
+
# @example
|
|
82
|
+
# browser.after_hooks.without do |browser|
|
|
83
|
+
# browser.element(name: "new_user_button").click
|
|
84
|
+
# end
|
|
85
|
+
#
|
|
86
|
+
# @yield Block that is executed without after hooks being run
|
|
87
|
+
# @yieldparam [Watir::Browser]
|
|
88
|
+
#
|
|
89
|
+
|
|
90
|
+
def without
|
|
91
|
+
current_after_hooks = @after_hooks
|
|
92
|
+
@after_hooks = []
|
|
93
|
+
yield(@browser)
|
|
94
|
+
ensure
|
|
95
|
+
@after_hooks = current_after_hooks
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
#
|
|
99
|
+
# Yields each after hook.
|
|
100
|
+
#
|
|
101
|
+
# @yieldparam [#call] after_hook Object responding to call
|
|
102
|
+
#
|
|
103
|
+
|
|
104
|
+
def each(&block)
|
|
105
|
+
@after_hooks.each(&block)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
#
|
|
109
|
+
# Returns number of after hooks.
|
|
110
|
+
#
|
|
111
|
+
# @example
|
|
112
|
+
# browser.after_hooks.add { puts 'Some after_hook.' }
|
|
113
|
+
# browser.after_hooks.length
|
|
114
|
+
# #=> 1
|
|
115
|
+
#
|
|
116
|
+
# @return [Integer]
|
|
117
|
+
#
|
|
118
|
+
|
|
119
|
+
def length
|
|
120
|
+
@after_hooks.length
|
|
121
|
+
end
|
|
122
|
+
alias size length
|
|
123
|
+
|
|
124
|
+
#
|
|
125
|
+
# Gets the after hook at the given index.
|
|
126
|
+
#
|
|
127
|
+
# @param [Integer] index
|
|
128
|
+
# @return [#call]
|
|
129
|
+
#
|
|
130
|
+
|
|
131
|
+
def [](index)
|
|
132
|
+
@after_hooks[index]
|
|
133
|
+
end
|
|
134
|
+
end # AfterHooks
|
|
135
|
+
end # Watir
|
data/lib/watir/alert.rb
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Watir
|
|
4
|
+
class Alert
|
|
5
|
+
include Waitable
|
|
6
|
+
include Exception
|
|
7
|
+
|
|
8
|
+
def initialize(browser)
|
|
9
|
+
@browser = browser
|
|
10
|
+
@alert = nil
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
#
|
|
14
|
+
# Returns text of alert.
|
|
15
|
+
#
|
|
16
|
+
# @example
|
|
17
|
+
# browser.alert.text
|
|
18
|
+
# #=> "ok"
|
|
19
|
+
#
|
|
20
|
+
# @return [String]
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
def text
|
|
24
|
+
wait_for_exists
|
|
25
|
+
@alert.text
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
#
|
|
29
|
+
# Closes alert or accepts prompts/confirms.
|
|
30
|
+
#
|
|
31
|
+
# @example
|
|
32
|
+
# browser.alert.ok
|
|
33
|
+
# browser.alert.exists?
|
|
34
|
+
# #=> false
|
|
35
|
+
#
|
|
36
|
+
|
|
37
|
+
def ok
|
|
38
|
+
wait_for_exists
|
|
39
|
+
@alert.accept
|
|
40
|
+
@browser.after_hooks.run
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Closes alert or cancels prompts/confirms.
|
|
45
|
+
#
|
|
46
|
+
# @example
|
|
47
|
+
# browser.alert.close
|
|
48
|
+
# browser.alert.exists?
|
|
49
|
+
# #=> false
|
|
50
|
+
#
|
|
51
|
+
|
|
52
|
+
def close
|
|
53
|
+
wait_for_exists
|
|
54
|
+
@alert.dismiss
|
|
55
|
+
@browser.after_hooks.run
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
#
|
|
59
|
+
# Enters text to prompt.
|
|
60
|
+
#
|
|
61
|
+
# @example
|
|
62
|
+
# browser.alert.set "Text for prompt"
|
|
63
|
+
# browser.alert.ok
|
|
64
|
+
#
|
|
65
|
+
# @param [String] value
|
|
66
|
+
#
|
|
67
|
+
|
|
68
|
+
def set(value)
|
|
69
|
+
wait_for_exists
|
|
70
|
+
@alert.send_keys(value)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# Returns true if alert, confirm or prompt is present and false otherwise.
|
|
75
|
+
#
|
|
76
|
+
# @example
|
|
77
|
+
# browser.alert.exists?
|
|
78
|
+
# #=> true
|
|
79
|
+
#
|
|
80
|
+
|
|
81
|
+
def exists?
|
|
82
|
+
assert_exists
|
|
83
|
+
true
|
|
84
|
+
rescue UnknownObjectException
|
|
85
|
+
false
|
|
86
|
+
end
|
|
87
|
+
alias present? exists?
|
|
88
|
+
alias exist? exists?
|
|
89
|
+
|
|
90
|
+
#
|
|
91
|
+
# @api private
|
|
92
|
+
# @see Watir::Wait
|
|
93
|
+
#
|
|
94
|
+
|
|
95
|
+
def selector_string
|
|
96
|
+
'alert'
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
private
|
|
100
|
+
|
|
101
|
+
def assert_exists
|
|
102
|
+
@alert = @browser.driver.switch_to.alert
|
|
103
|
+
rescue Selenium::WebDriver::Error::NoSuchAlertError
|
|
104
|
+
raise UnknownObjectException, 'unable to locate alert'
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def wait_for_exists
|
|
108
|
+
wait_until(message: 'waiting for alert', &:exists?)
|
|
109
|
+
rescue Wait::TimeoutError
|
|
110
|
+
raise UnknownObjectException, 'unable to locate alert'
|
|
111
|
+
end
|
|
112
|
+
end # Alert
|
|
113
|
+
end # Watir
|