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,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe ElementCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe '#[]' do
|
|
12
|
+
context 'when elements do not exist' do
|
|
13
|
+
it 'returns not existing element' do
|
|
14
|
+
expect(browser.elements(id: 'non-existing')[0]).not_to exist
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#eq and #eql?' do
|
|
20
|
+
before { browser.goto WatirSpec.url_for('forms_with_input_elements.html') }
|
|
21
|
+
|
|
22
|
+
it 'returns true if the two collections have the same Watir Elements' do
|
|
23
|
+
a = browser.select_list(name: 'new_user_languages').options
|
|
24
|
+
b = browser.select_list(id: 'new_user_languages').options
|
|
25
|
+
|
|
26
|
+
expect(a).to eq b
|
|
27
|
+
expect(a).to eql(b)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'returns false if the two collections are not the same' do
|
|
31
|
+
a = browser.select_list(name: 'new_user_languages').options
|
|
32
|
+
b = browser.select_list(id: 'new_user_role').options
|
|
33
|
+
|
|
34
|
+
expect(a).not_to eq b
|
|
35
|
+
expect(a).not_to eql(b)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe 'visible text' do
|
|
40
|
+
it 'finds elements by visible text' do
|
|
41
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
|
42
|
+
container = browser.div(id: 'visible_text')
|
|
43
|
+
|
|
44
|
+
expect(container.elements(visible_text: 'all visible').count).to eq(1)
|
|
45
|
+
expect(container.elements(visible_text: /all visible/).count).to eq(1)
|
|
46
|
+
expect(container.elements(visible_text: /some visible/).count).to eq(1)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'finds elements in spite of hidden text',
|
|
50
|
+
except: {browser: :safari, reason: 'Safari is not filtering out hidden text'} do
|
|
51
|
+
browser.goto WatirSpec.url_for('non_control_elements.html')
|
|
52
|
+
container = browser.div(id: 'visible_text')
|
|
53
|
+
|
|
54
|
+
expect(container.elements(visible_text: 'some visible').count).to eq(1)
|
|
55
|
+
expect(container.elements(visible_text: 'none visible').count).to eq(0)
|
|
56
|
+
expect(container.elements(visible_text: /none visible/).count).to eq(0)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe 'Em' do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Exists method
|
|
12
|
+
describe '#exists?' do
|
|
13
|
+
it 'returns true if the element exists' do
|
|
14
|
+
expect(browser.em(id: 'important-id')).to exist
|
|
15
|
+
expect(browser.em(class: 'important-class')).to exist
|
|
16
|
+
expect(browser.em(xpath: "//em[@id='important-id']")).to exist
|
|
17
|
+
expect(browser.em(index: 0)).to exist
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'returns the first em if given no args' do
|
|
21
|
+
expect(browser.em).to exist
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'returns false if the element does not exist' do
|
|
25
|
+
expect(browser.em(id: 'no_such_id')).not_to exist
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
29
|
+
expect { browser.em(id: 3.14).exists? }.to raise_error(TypeError)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Attribute methods
|
|
34
|
+
describe '#id' do
|
|
35
|
+
it 'returns the id attribute if the element exists' do
|
|
36
|
+
expect(browser.em(class: 'important-class').id).to eq 'important-id'
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
|
40
|
+
expect { browser.em(id: 'no_such_id').id }.to raise_unknown_object_exception
|
|
41
|
+
expect { browser.em(title: 'no_such_id').id }.to raise_unknown_object_exception
|
|
42
|
+
expect { browser.em(index: 1337).id }.to raise_unknown_object_exception
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#title' do
|
|
47
|
+
it 'returns the title of the element' do
|
|
48
|
+
expect(browser.em(class: 'important-class').title).to eq 'ergo cogito'
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '#text' do
|
|
53
|
+
it 'returns the text of the element' do
|
|
54
|
+
expect(browser.em(id: 'important-id').text).to eq 'ergo cogito'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
|
58
|
+
expect { browser.em(id: 'no_such_id').text }.to raise_unknown_object_exception
|
|
59
|
+
expect { browser.em(title: 'no_such_title').text }.to raise_unknown_object_exception
|
|
60
|
+
expect { browser.em(index: 1337).text }.to raise_unknown_object_exception
|
|
61
|
+
expect { browser.em(xpath: "//em[@id='no_such_id']").text }.to raise_unknown_object_exception
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe '#respond_to?' do
|
|
66
|
+
it 'returns true for all attribute methods' do
|
|
67
|
+
expect(browser.em(index: 0)).to respond_to(:id)
|
|
68
|
+
expect(browser.em(index: 0)).to respond_to(:class_name)
|
|
69
|
+
expect(browser.em(index: 0)).to respond_to(:style)
|
|
70
|
+
expect(browser.em(index: 0)).to respond_to(:text)
|
|
71
|
+
expect(browser.em(index: 0)).to respond_to(:title)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Manipulation methods
|
|
76
|
+
describe '#click' do
|
|
77
|
+
it 'raises UnknownObjectException if the element does not exist' do
|
|
78
|
+
expect { browser.em(id: 'no_such_id').click }.to raise_unknown_object_exception
|
|
79
|
+
expect { browser.em(title: 'no_such_title').click }.to raise_unknown_object_exception
|
|
80
|
+
expect { browser.em(index: 1337).click }.to raise_unknown_object_exception
|
|
81
|
+
expect { browser.em(xpath: "//em[@id='no_such_id']").click }.to raise_unknown_object_exception
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe 'Ems' do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.ems(class: 'important-class').to_a).to eq [browser.em(class: 'important-class')]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the number of ems' do
|
|
19
|
+
expect(browser.ems.length).to eq 1
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#[]' do
|
|
24
|
+
it 'returns the em at the given index' do
|
|
25
|
+
expect(browser.ems[0].id).to eq 'important-id'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#each' do
|
|
30
|
+
it 'iterates through ems correctly' do
|
|
31
|
+
count = 0
|
|
32
|
+
|
|
33
|
+
browser.ems.each_with_index do |e, index|
|
|
34
|
+
expect(e.text).to eq browser.em(index: index).text
|
|
35
|
+
expect(e.id).to eq browser.em(index: index).id
|
|
36
|
+
expect(e.class_name).to eq browser.em(index: index).class_name
|
|
37
|
+
|
|
38
|
+
count += 1
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
expect(count).to be > 0
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe FileField do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe '#exist?' do
|
|
12
|
+
it 'returns true if the file field exists' do
|
|
13
|
+
expect(browser.file_field(id: 'new_user_portrait')).to exist
|
|
14
|
+
expect(browser.file_field(id: /new_user_portrait/)).to exist
|
|
15
|
+
expect(browser.file_field(name: 'new_user_portrait')).to exist
|
|
16
|
+
expect(browser.file_field(name: /new_user_portrait/)).to exist
|
|
17
|
+
expect(browser.file_field(class: 'portrait')).to exist
|
|
18
|
+
expect(browser.file_field(class: /portrait/)).to exist
|
|
19
|
+
expect(browser.file_field(index: 0)).to exist
|
|
20
|
+
expect(browser.file_field(xpath: "//input[@id='new_user_portrait']")).to exist
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'returns the first file field if given no args' do
|
|
24
|
+
expect(browser.file_field).to exist
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'returns true for element with upper case type' do
|
|
28
|
+
expect(browser.file_field(id: 'new_user_resume')).to exist
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "returns false if the file field doesn't exist" do
|
|
32
|
+
expect(browser.file_field(id: 'no_such_id')).not_to exist
|
|
33
|
+
expect(browser.file_field(id: /no_such_id/)).not_to exist
|
|
34
|
+
expect(browser.file_field(name: 'no_such_name')).not_to exist
|
|
35
|
+
expect(browser.file_field(name: /no_such_name/)).not_to exist
|
|
36
|
+
expect(browser.file_field(class: 'no_such_class')).not_to exist
|
|
37
|
+
expect(browser.file_field(class: /no_such_class/)).not_to exist
|
|
38
|
+
expect(browser.file_field(index: 1337)).not_to exist
|
|
39
|
+
expect(browser.file_field(xpath: "//input[@id='no_such_id']")).not_to exist
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
43
|
+
expect { browser.file_field(id: 3.14).exists? }.to raise_error(TypeError)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Attribute methods
|
|
48
|
+
describe '#id' do
|
|
49
|
+
it 'returns the id attribute if the text field exists' do
|
|
50
|
+
expect(browser.file_field(index: 0).id).to eq 'new_user_portrait'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
|
54
|
+
expect { browser.file_field(index: 1337).id }.to raise_unknown_object_exception
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe '#name' do
|
|
59
|
+
it 'returns the name attribute if the text field exists' do
|
|
60
|
+
expect(browser.file_field(index: 0).name).to eq 'new_user_portrait'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
|
64
|
+
expect { browser.file_field(index: 1337).name }.to raise_unknown_object_exception
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#title' do
|
|
69
|
+
it 'returns the title attribute if the text field exists' do
|
|
70
|
+
expect(browser.file_field(id: 'new_user_portrait').title).to eq 'Smile!'
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe '#type' do
|
|
75
|
+
it 'returns the type attribute if the text field exists' do
|
|
76
|
+
expect(browser.file_field(index: 0).type).to eq 'file'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "raises UnknownObjectException if the text field doesn't exist" do
|
|
80
|
+
expect { browser.file_field(index: 1337).type }.to raise_unknown_object_exception
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe '#respond_to?' do
|
|
85
|
+
it 'returns true for all attribute methods' do
|
|
86
|
+
expect(browser.file_field(index: 0)).to respond_to(:class_name)
|
|
87
|
+
expect(browser.file_field(index: 0)).to respond_to(:id)
|
|
88
|
+
expect(browser.file_field(index: 0)).to respond_to(:name)
|
|
89
|
+
expect(browser.file_field(index: 0)).to respond_to(:title)
|
|
90
|
+
expect(browser.file_field(index: 0)).to respond_to(:type)
|
|
91
|
+
expect(browser.file_field(index: 0)).to respond_to(:value)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Manipulation methods
|
|
96
|
+
|
|
97
|
+
describe '#set' do
|
|
98
|
+
it 'is able to set a file path in the field and click the upload button and fire the onchange event' do
|
|
99
|
+
browser.goto WatirSpec.url_for('forms_with_input_elements.html')
|
|
100
|
+
|
|
101
|
+
element = browser.file_field(name: 'new_user_portrait')
|
|
102
|
+
element.upload __FILE__
|
|
103
|
+
|
|
104
|
+
expect(element.value).to include(File.basename(__FILE__)) # only some browser will return the full path
|
|
105
|
+
expect(messages.first).to include(File.basename(__FILE__))
|
|
106
|
+
|
|
107
|
+
browser.button(name: 'new_user_submit').click
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'raises an error if the file does not exist' do
|
|
111
|
+
expect {
|
|
112
|
+
browser.file_field.set(File.join(Dir.tmpdir, 'unlikely-to-exist'))
|
|
113
|
+
}.to raise_error(Errno::ENOENT)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
describe '#value=', exclude: {browser: :ie} do
|
|
118
|
+
it 'is able to set a file path in the field and click the upload button and fire the onchange event' do
|
|
119
|
+
browser.goto WatirSpec.url_for('forms_with_input_elements.html')
|
|
120
|
+
|
|
121
|
+
path = File.expand_path(__FILE__)
|
|
122
|
+
element = browser.file_field(name: 'new_user_portrait')
|
|
123
|
+
|
|
124
|
+
element.value = path
|
|
125
|
+
expect(element.value).to include(File.basename(path)) # only some browser will return the full path
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it 'does not alter its argument' do
|
|
129
|
+
value = File.expand_path '.rubocop.yml'
|
|
130
|
+
browser.file_field.value = value
|
|
131
|
+
expect(value).to match(/\.rubocop\.yml$/)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe FileFieldCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.file_fields(class: 'portrait').to_a).to eq [browser.file_field(class: 'portrait')]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the correct number of file fields' do
|
|
19
|
+
expect(browser.file_fields.length).to eq 3
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#[]' do
|
|
24
|
+
it 'returns the file field at the given index' do
|
|
25
|
+
expect(browser.file_fields[0].id).to eq 'new_user_portrait'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#each' do
|
|
30
|
+
it 'iterates through file fields correctly' do
|
|
31
|
+
count = 0
|
|
32
|
+
|
|
33
|
+
browser.file_fields.each_with_index do |f, index|
|
|
34
|
+
expect(f.name).to eq browser.file_field(index: index).name
|
|
35
|
+
expect(f.id).to eq browser.file_field(index: index).id
|
|
36
|
+
expect(f.value).to eq browser.file_field(index: index).value
|
|
37
|
+
|
|
38
|
+
count += 1
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
expect(count).to be > 0
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe Font do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('font.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'finds the font element' do
|
|
12
|
+
expect(browser.font(index: 0)).to exist
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'knows about the color attribute' do
|
|
16
|
+
expect(browser.font(index: 0).color).to eq '#ff00ff'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'knows about the face attribute' do
|
|
20
|
+
expect(browser.font(index: 0).face).to eq 'Helvetica'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'knows about the size attribute' do
|
|
24
|
+
expect(browser.font(index: 0).size).to eq '12'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'finds all font elements' do
|
|
28
|
+
expect(browser.fonts.size).to eq 1
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe Form do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe '#exists?' do
|
|
12
|
+
it 'returns true if the form exists' do
|
|
13
|
+
expect(browser.form(id: 'new_user')).to exist
|
|
14
|
+
expect(browser.form(id: /new_user/)).to exist
|
|
15
|
+
|
|
16
|
+
expect(browser.form(class: 'user')).to exist
|
|
17
|
+
expect(browser.form(class: /user/)).to exist
|
|
18
|
+
|
|
19
|
+
expect(browser.form(method: 'post')).to exist
|
|
20
|
+
expect(browser.form(method: /post/)).to exist
|
|
21
|
+
expect(browser.form(action: /to_me/)).to exist
|
|
22
|
+
expect(browser.form(index: 0)).to exist
|
|
23
|
+
expect(browser.form(xpath: "//form[@id='new_user']")).to exist
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'returns the first form if given no args' do
|
|
27
|
+
expect(browser.form).to exist
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "returns false if the form doesn't exist" do
|
|
31
|
+
expect(browser.form(id: 'no_such_id')).not_to exist
|
|
32
|
+
expect(browser.form(id: /no_such_id/)).not_to exist
|
|
33
|
+
|
|
34
|
+
expect(browser.form(class: 'no_such_class')).not_to exist
|
|
35
|
+
expect(browser.form(class: /no_such_class/)).not_to exist
|
|
36
|
+
|
|
37
|
+
expect(browser.form(method: 'no_such_method')).not_to exist
|
|
38
|
+
expect(browser.form(method: /no_such_method/)).not_to exist
|
|
39
|
+
expect(browser.form(action: 'no_such_action')).not_to exist
|
|
40
|
+
expect(browser.form(action: /no_such_action/)).not_to exist
|
|
41
|
+
expect(browser.form(index: 1337)).not_to exist
|
|
42
|
+
expect(browser.form(xpath: "//form[@id='no_such_id']")).not_to exist
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
46
|
+
expect { browser.form(id: 3.14).exists? }.to raise_error(TypeError)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '#submit' do
|
|
51
|
+
it 'submits the form' do
|
|
52
|
+
browser.form(id: 'delete_user').submit
|
|
53
|
+
browser.wait_while(url: /forms_with_input_elements\.html$/)
|
|
54
|
+
expect(browser.text).to include('Semantic table')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'triggers onsubmit event and takes its result into account' do
|
|
58
|
+
form = browser.form(name: 'user_new')
|
|
59
|
+
form.submit
|
|
60
|
+
expect(form).to exist
|
|
61
|
+
expect(messages.size).to eq 1
|
|
62
|
+
expect(messages[0]).to eq 'submit'
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'times out when submitting an element that is not displayed' do
|
|
66
|
+
expect { browser.form(name: 'no').submit }.to raise_unknown_object_exception
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe FormCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.forms(method: 'post').to_a).to eq [browser.form(method: 'post')]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the number of forms in the container' do
|
|
19
|
+
expect(browser.forms.length).to eq 2
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#[]n' do
|
|
24
|
+
it 'provides access to the nth form' do
|
|
25
|
+
expect(browser.forms[0].action).to match(/post_to_me$/) # varies between browsers
|
|
26
|
+
expect(browser.forms[0].attribute_value('method')).to eq 'post'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '#each' do
|
|
31
|
+
it 'iterates through forms correctly' do
|
|
32
|
+
count = 0
|
|
33
|
+
|
|
34
|
+
browser.forms.each_with_index do |f, index|
|
|
35
|
+
expect(f.name).to eq browser.form(index: index).name
|
|
36
|
+
expect(f.id).to eq browser.form(index: index).id
|
|
37
|
+
expect(f.class_name).to eq browser.form(index: index).class_name
|
|
38
|
+
|
|
39
|
+
count += 1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
expect(count).to be > 0
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# TODO: fix duplication with iframe_spec
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
module Watir
|
|
10
|
+
describe Frame do
|
|
11
|
+
before do
|
|
12
|
+
browser.goto(WatirSpec.url_for('frames.html'))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'handles crossframe javascript' do
|
|
16
|
+
expect(browser.frame(id: 'frame_1').text_field(name: 'senderElement').value).to eq 'send_this_value'
|
|
17
|
+
expect(browser.frame(id: 'frame_2').text_field(name: 'recieverElement').value).to eq 'old_value'
|
|
18
|
+
browser.frame(id: 'frame_1').button(id: 'send').click
|
|
19
|
+
expect(browser.frame(id: 'frame_2').text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '#exist?' do
|
|
23
|
+
it 'returns true if the frame exists' do
|
|
24
|
+
expect(browser.frame(id: 'frame_1')).to exist
|
|
25
|
+
expect(browser.frame(name: 'frame1')).to exist
|
|
26
|
+
expect(browser.frame(index: 0)).to exist
|
|
27
|
+
expect(browser.frame(class: 'half')).to exist
|
|
28
|
+
expect(browser.frame(xpath: "//frame[@id='frame_1']")).to exist
|
|
29
|
+
expect(browser.frame(src: 'frame_1.html')).to exist
|
|
30
|
+
expect(browser.frame(id: /frame/)).to exist
|
|
31
|
+
expect(browser.frame(name: /frame/)).to exist
|
|
32
|
+
expect(browser.frame(src: /frame_1/)).to exist
|
|
33
|
+
expect(browser.frame(class: /half/)).to exist
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'returns the first frame if given no args' do
|
|
37
|
+
expect(browser.frame).to exist
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "returns false if the frame doesn't exist" do
|
|
41
|
+
expect(browser.frame(id: 'no_such_id')).not_to exist
|
|
42
|
+
expect(browser.frame(name: 'no_such_text')).not_to exist
|
|
43
|
+
expect(browser.frame(index: 1337)).not_to exist
|
|
44
|
+
expect(browser.frame(src: 'no_such_src')).not_to exist
|
|
45
|
+
expect(browser.frame(class: 'no_such_class')).not_to exist
|
|
46
|
+
expect(browser.frame(id: /no_such_id/)).not_to exist
|
|
47
|
+
expect(browser.frame(name: /no_such_text/)).not_to exist
|
|
48
|
+
expect(browser.frame(src: /no_such_src/)).not_to exist
|
|
49
|
+
expect(browser.frame(class: /no_such_class/)).not_to exist
|
|
50
|
+
expect(browser.frame(xpath: "//frame[@id='no_such_id']")).not_to exist
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'handles nested frames' do
|
|
54
|
+
browser.goto(WatirSpec.url_for('nested_frames.html'))
|
|
55
|
+
|
|
56
|
+
browser.frame(id: 'two').frame(id: 'three').link(id: 'four').click
|
|
57
|
+
|
|
58
|
+
browser.wait_until(title: 'definition_lists')
|
|
59
|
+
expect { browser.goto(WatirSpec.url_for('nested_frames.html')) }.not_to raise_exception
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "raises TypeError when 'what' argument is invalid" do
|
|
63
|
+
expect { browser.frame(id: 3.14).exists? }.to raise_error(TypeError)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'raises UnknownFrameException when accessing elements inside non-existing frame' do
|
|
68
|
+
expect { browser.frame(name: 'no_such_name').p(index: 0).id }.to raise_unknown_frame_exception
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'raises UnknownFrameException when accessing a non-existing frame' do
|
|
72
|
+
expect { browser.frame(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'raises UnknownFrameException when accessing a non-existing subframe' do
|
|
76
|
+
expect { browser.frame(name: 'frame1').frame(name: 'no_such_name').id }.to raise_unknown_frame_exception
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'raises UnknownObjectException when accessing a non-existing element inside an existing frame' do
|
|
80
|
+
expect { browser.frame(index: 0).p(index: 1337).id }.to raise_unknown_object_exception
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "raises NoMethodError when trying to access attributes it doesn't have" do
|
|
84
|
+
expect { browser.frame(index: 0).foo }.to raise_error(NoMethodError)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'is able to set a field' do
|
|
88
|
+
browser.frame(index: 0).text_field(name: 'senderElement').set('new value')
|
|
89
|
+
expect(browser.frame(index: 0).text_field(name: 'senderElement').value).to eq 'new value'
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "can access the frame's parent element after use" do
|
|
93
|
+
el = browser.frameset
|
|
94
|
+
el.frame.text_field.value
|
|
95
|
+
expect(el.attribute_value('cols')).to be_a(String)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe '#execute_script' do
|
|
99
|
+
it 'executes the given javascript in the specified frame',
|
|
100
|
+
except: {browser: :safari, reason: 'Safari does not strip text'} do
|
|
101
|
+
frame = browser.frame(index: 0)
|
|
102
|
+
expect(frame.div(id: 'set_by_js').text).to eq ''
|
|
103
|
+
inner_html = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
|
104
|
+
frame.execute_script(%{document.getElementById('set_by_js').innerHTML = '#{inner_html}'})
|
|
105
|
+
text = 'Art consists of limitation. The most beautiful part of every picture is the frame.'
|
|
106
|
+
expect(frame.div(id: 'set_by_js').text).to eq text
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe '#html' do
|
|
111
|
+
it 'returns the full HTML source of the frame' do
|
|
112
|
+
browser.goto WatirSpec.url_for('frames.html')
|
|
113
|
+
expect(browser.frame.html.downcase).to include('<title>frame 1</title>')
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'watirspec_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe FrameCollection do
|
|
7
|
+
before do
|
|
8
|
+
browser.goto(WatirSpec.url_for('frames.html'))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe 'with selectors' do
|
|
12
|
+
it 'returns the matching elements' do
|
|
13
|
+
expect(browser.frames(name: 'frame2').to_a).to eq [browser.frame(name: 'frame2')]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#length' do
|
|
18
|
+
it 'returns the correct number of frames' do
|
|
19
|
+
expect(browser.frames.length).to eq 2
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#[]' do
|
|
24
|
+
it 'returns the frame at the given index' do
|
|
25
|
+
expect(browser.frames[0].id).to eq 'frame_1'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#each' do
|
|
30
|
+
it 'iterates through frames correctly' do
|
|
31
|
+
count = 0
|
|
32
|
+
|
|
33
|
+
browser.frames.each_with_index do |f, index|
|
|
34
|
+
expect(f.name).to eq browser.frame(index: index).name
|
|
35
|
+
expect(f.id).to eq browser.frame(index: index).id
|
|
36
|
+
count += 1
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
expect(count).to be > 0
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|