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,97 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Watir
|
|
4
|
+
#
|
|
5
|
+
# @private
|
|
6
|
+
#
|
|
7
|
+
# Extended by Element, provides methods for defining attributes on the element classes.
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
module AttributeHelper
|
|
11
|
+
class << self
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def extended(klass)
|
|
15
|
+
klass.class_eval do
|
|
16
|
+
# undefine deprecated methods to use them for Element attributes
|
|
17
|
+
%i[id type].each { |m| undef_method m if method_defined? m }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def inherit_attributes_from(kls)
|
|
23
|
+
kls.typed_attributes.each do |type, attrs|
|
|
24
|
+
attrs.each { |method, attr| attribute type, method, attr }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def typed_attributes
|
|
29
|
+
@typed_attributes ||= Hash.new { |hash, type| hash[type] = [] }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def attribute_list
|
|
33
|
+
@attribute_list ||= (typed_attributes.values.flatten +
|
|
34
|
+
ancestors[1..].filter_map { |e|
|
|
35
|
+
e.attribute_list if e.respond_to?(:attribute_list)
|
|
36
|
+
}.flatten
|
|
37
|
+
).uniq
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
alias attributes attribute_list
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# YARD macro to generated friendly
|
|
44
|
+
# documentation for attributes.
|
|
45
|
+
#
|
|
46
|
+
# @macro [attach] attribute
|
|
47
|
+
# @method $2
|
|
48
|
+
# @return [$1] value of $3 property
|
|
49
|
+
#
|
|
50
|
+
def attribute(type, method, attr)
|
|
51
|
+
return if method_defined?(method)
|
|
52
|
+
|
|
53
|
+
typed_attributes[type] << [method, attr]
|
|
54
|
+
define_attribute(type, method, attr)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def define_attribute(type, name, attr)
|
|
58
|
+
case type.to_s
|
|
59
|
+
when 'Boolean'
|
|
60
|
+
define_boolean_attribute(name, attr)
|
|
61
|
+
when 'Integer'
|
|
62
|
+
define_int_attribute(name, attr)
|
|
63
|
+
when 'Float'
|
|
64
|
+
define_float_attribute(name, attr)
|
|
65
|
+
else
|
|
66
|
+
define_string_attribute(name, attr)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def define_string_attribute(mname, aname)
|
|
71
|
+
define_method mname do
|
|
72
|
+
attribute_value(aname).to_s
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def define_boolean_attribute(mname, aname)
|
|
77
|
+
define_method mname do
|
|
78
|
+
attribute_value(aname) == 'true'
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def define_int_attribute(mname, aname)
|
|
83
|
+
define_method mname do
|
|
84
|
+
value = attribute_value(aname)
|
|
85
|
+
value && Integer(value)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def define_float_attribute(mname, aname)
|
|
90
|
+
define_method mname do
|
|
91
|
+
value = attribute_value(aname)
|
|
92
|
+
value = nil if value == 'NaN'
|
|
93
|
+
value && Float(value)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end # AttributeHelper
|
|
97
|
+
end # Watir
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Watir
|
|
4
|
+
#
|
|
5
|
+
# The main class through which you control the browser.
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
class Browser
|
|
9
|
+
include Container
|
|
10
|
+
include HasWindow
|
|
11
|
+
include Waitable
|
|
12
|
+
include Navigation
|
|
13
|
+
include Exception
|
|
14
|
+
include Scrolling
|
|
15
|
+
|
|
16
|
+
attr_writer :default_context, :original_window, :locator_namespace, :timer
|
|
17
|
+
attr_reader :driver, :after_hooks, :capabilities
|
|
18
|
+
alias wd driver # ensures duck typing with Watir::Element
|
|
19
|
+
|
|
20
|
+
class << self
|
|
21
|
+
#
|
|
22
|
+
# Creates a Watir::Browser instance and goes to URL.
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
# browser = Watir::Browser.start "www.google.com", :chrome
|
|
26
|
+
# #=> #<Watir::Browser:0x..fa45a499cb41e1752 url="http://www.google.com" title="Google">
|
|
27
|
+
#
|
|
28
|
+
# @param [String] url
|
|
29
|
+
# @param [Symbol, Selenium::WebDriver] browser :firefox, :ie, :chrome, :remote or Selenium::WebDriver instance
|
|
30
|
+
# @return [Watir::Browser]
|
|
31
|
+
#
|
|
32
|
+
def start(url, browser = :chrome, *args)
|
|
33
|
+
new(browser, *args).tap { |b| b.goto url }
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
#
|
|
38
|
+
# Creates a Watir::Browser instance.
|
|
39
|
+
#
|
|
40
|
+
# @param [Symbol, Selenium::WebDriver] browser :firefox, :ie, :chrome, :remote or Selenium::WebDriver instance
|
|
41
|
+
# @param args Passed to the underlying driver
|
|
42
|
+
#
|
|
43
|
+
|
|
44
|
+
def initialize(browser = :chrome, *args)
|
|
45
|
+
@capabilities = browser.is_a?(Capabilities) ? browser : Capabilities.new(browser, *args)
|
|
46
|
+
@driver = browser.is_a?(Selenium::WebDriver::Driver) ? browser : Selenium::WebDriver.for(*@capabilities.to_args)
|
|
47
|
+
|
|
48
|
+
@after_hooks = AfterHooks.new(self)
|
|
49
|
+
@closed = false
|
|
50
|
+
@default_context = true
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# rubocop:disable Metrics/AbcSize
|
|
54
|
+
def inspect
|
|
55
|
+
if alert.exists?
|
|
56
|
+
format('#<%<class>s:0x%<hash>x alert=true>', class: self.class, hash: hash * 2)
|
|
57
|
+
else
|
|
58
|
+
format('#<%<class>s:0x%<hash>x url=%<url>s title=%<title>s>',
|
|
59
|
+
class: self.class, hash: hash * 2, url: url.inspect, title: title.inspect)
|
|
60
|
+
end
|
|
61
|
+
rescue Selenium::WebDriver::Error::NoSuchWindowError
|
|
62
|
+
format('#<%<class>s:0x%<hash>x closed=%<closed>s>',
|
|
63
|
+
class: self.class, hash: hash * 2, closed: closed?)
|
|
64
|
+
rescue Errno::ECONNREFUSED
|
|
65
|
+
format('#<%<class>s:0x%<hash>x closed=true>', class: self.class, hash: hash * 2)
|
|
66
|
+
end
|
|
67
|
+
alias selector_string inspect
|
|
68
|
+
# rubocop:enable Metrics/AbcSize
|
|
69
|
+
|
|
70
|
+
#
|
|
71
|
+
# Returns URL of current page.
|
|
72
|
+
#
|
|
73
|
+
# @example
|
|
74
|
+
# browser.goto "watir.com"
|
|
75
|
+
# browser.url
|
|
76
|
+
# #=> "http://watir.com/"
|
|
77
|
+
#
|
|
78
|
+
# @return [String]
|
|
79
|
+
#
|
|
80
|
+
|
|
81
|
+
def url
|
|
82
|
+
@driver.current_url
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
#
|
|
86
|
+
# Returns title of current page.
|
|
87
|
+
#
|
|
88
|
+
# @example
|
|
89
|
+
# browser.goto "watir.github.io"
|
|
90
|
+
# browser.title
|
|
91
|
+
# #=> "Watir Project"
|
|
92
|
+
#
|
|
93
|
+
# @return [String]
|
|
94
|
+
#
|
|
95
|
+
|
|
96
|
+
def title
|
|
97
|
+
@driver.title
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
#
|
|
101
|
+
# Closes browser.
|
|
102
|
+
#
|
|
103
|
+
|
|
104
|
+
def close
|
|
105
|
+
return if closed?
|
|
106
|
+
|
|
107
|
+
@driver.quit
|
|
108
|
+
@closed = true
|
|
109
|
+
end
|
|
110
|
+
alias quit close
|
|
111
|
+
|
|
112
|
+
#
|
|
113
|
+
# Returns true if browser is closed and false otherwise.
|
|
114
|
+
#
|
|
115
|
+
# @return [Boolean]
|
|
116
|
+
#
|
|
117
|
+
|
|
118
|
+
def closed?
|
|
119
|
+
@closed
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
#
|
|
123
|
+
# Handles cookies.
|
|
124
|
+
#
|
|
125
|
+
# @return [Watir::Cookies]
|
|
126
|
+
#
|
|
127
|
+
|
|
128
|
+
def cookies
|
|
129
|
+
@cookies ||= Cookies.new driver.manage
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
#
|
|
133
|
+
# Returns browser name.
|
|
134
|
+
#
|
|
135
|
+
# @example
|
|
136
|
+
# browser = Watir::Browser.new :chrome
|
|
137
|
+
# browser.name
|
|
138
|
+
# #=> :chrome
|
|
139
|
+
#
|
|
140
|
+
# @return [Symbol]
|
|
141
|
+
#
|
|
142
|
+
|
|
143
|
+
def name
|
|
144
|
+
@driver.browser
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
#
|
|
148
|
+
# Returns text of page body.
|
|
149
|
+
#
|
|
150
|
+
# @return [String]
|
|
151
|
+
#
|
|
152
|
+
|
|
153
|
+
def text
|
|
154
|
+
body.text
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
#
|
|
158
|
+
# Returns HTML code of current page.
|
|
159
|
+
#
|
|
160
|
+
# @return [String]
|
|
161
|
+
#
|
|
162
|
+
|
|
163
|
+
def html
|
|
164
|
+
@driver.page_source
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
#
|
|
168
|
+
# Handles JavaScript alerts, confirms and prompts.
|
|
169
|
+
#
|
|
170
|
+
# @return [Watir::Alert]
|
|
171
|
+
#
|
|
172
|
+
|
|
173
|
+
def alert
|
|
174
|
+
Alert.new(self)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
#
|
|
178
|
+
# Waits until readyState of document is complete.
|
|
179
|
+
#
|
|
180
|
+
# @example
|
|
181
|
+
# browser.wait
|
|
182
|
+
#
|
|
183
|
+
# @param [Integer] timeout
|
|
184
|
+
# @raise [Watir::Wait::TimeoutError] if timeout is exceeded
|
|
185
|
+
#
|
|
186
|
+
|
|
187
|
+
def wait(timeout = 5)
|
|
188
|
+
wait_until(timeout: timeout, message: "waiting for document.readyState == 'complete'") do
|
|
189
|
+
ready_state == 'complete'
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
#
|
|
194
|
+
# Returns readyState of document.
|
|
195
|
+
#
|
|
196
|
+
# @return [String]
|
|
197
|
+
#
|
|
198
|
+
|
|
199
|
+
def ready_state
|
|
200
|
+
execute_script 'return document.readyState'
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
#
|
|
204
|
+
# Returns the text of status bar.
|
|
205
|
+
#
|
|
206
|
+
# @return [String]
|
|
207
|
+
#
|
|
208
|
+
|
|
209
|
+
def status
|
|
210
|
+
execute_script 'return window.status;'
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
#
|
|
214
|
+
# Executes JavaScript snippet.
|
|
215
|
+
#
|
|
216
|
+
# If you are going to use the value snippet returns, make sure to use
|
|
217
|
+
# `return` explicitly.
|
|
218
|
+
#
|
|
219
|
+
# @example Check that Ajax requests are completed with jQuery
|
|
220
|
+
# browser.execute_script("return jQuery.active") == 0
|
|
221
|
+
# #=> true
|
|
222
|
+
#
|
|
223
|
+
# @param [String] script JavaScript snippet to execute
|
|
224
|
+
# @param args Arguments will be available in the given script in the 'arguments' pseudo-array
|
|
225
|
+
#
|
|
226
|
+
|
|
227
|
+
def execute_script(script, *args, function_name: nil)
|
|
228
|
+
args.map! do |e|
|
|
229
|
+
e.is_a?(Element) ? e.wait_until(&:exists?).wd : e
|
|
230
|
+
end
|
|
231
|
+
Watir.logger.info "Executing Script on Browser: #{function_name}" if function_name
|
|
232
|
+
wrap_elements_in(self, @driver.execute_script(script, *args))
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
#
|
|
236
|
+
# Sends sequence of keystrokes to currently active element.
|
|
237
|
+
#
|
|
238
|
+
# @example
|
|
239
|
+
# browser.goto "www.google.com"
|
|
240
|
+
# browser.send_keys "Watir", :return
|
|
241
|
+
#
|
|
242
|
+
# @param [String, Symbol] args
|
|
243
|
+
#
|
|
244
|
+
|
|
245
|
+
def send_keys(*args)
|
|
246
|
+
@driver.switch_to.active_element.send_keys(*args)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
#
|
|
250
|
+
# Handles screenshots of current pages.
|
|
251
|
+
#
|
|
252
|
+
# @return [Watir::Screenshot]
|
|
253
|
+
#
|
|
254
|
+
|
|
255
|
+
def screenshot
|
|
256
|
+
Screenshot.new self
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
#
|
|
260
|
+
# Returns true if browser is not closed and false otherwise.
|
|
261
|
+
#
|
|
262
|
+
# @return [Boolean]
|
|
263
|
+
#
|
|
264
|
+
|
|
265
|
+
def exist?
|
|
266
|
+
!closed? && window.present?
|
|
267
|
+
end
|
|
268
|
+
alias exists? exist?
|
|
269
|
+
|
|
270
|
+
def locate
|
|
271
|
+
raise Error, 'browser was closed' if closed?
|
|
272
|
+
|
|
273
|
+
ensure_context
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def ensure_context
|
|
277
|
+
return if @default_context
|
|
278
|
+
|
|
279
|
+
driver.switch_to.default_content
|
|
280
|
+
@default_context = true
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def browser
|
|
284
|
+
self
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
#
|
|
288
|
+
# Whether the locators should be used from a different namespace.
|
|
289
|
+
# Defaults to Watir::Locators.
|
|
290
|
+
#
|
|
291
|
+
|
|
292
|
+
def locator_namespace
|
|
293
|
+
@locator_namespace ||= Locators
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
#
|
|
297
|
+
# @api private
|
|
298
|
+
#
|
|
299
|
+
|
|
300
|
+
def wrap_elements_in(scope, obj)
|
|
301
|
+
case obj
|
|
302
|
+
when Selenium::WebDriver::Element
|
|
303
|
+
wrap_element(scope, obj)
|
|
304
|
+
when Array
|
|
305
|
+
obj.map { |e| wrap_elements_in(scope, e) }
|
|
306
|
+
when Hash
|
|
307
|
+
obj.each { |k, v| obj[k] = wrap_elements_in(scope, v) }
|
|
308
|
+
else
|
|
309
|
+
obj
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
def timer
|
|
314
|
+
@timer ||= Wait::Timer.new
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
private
|
|
318
|
+
|
|
319
|
+
def wrap_element(scope, element)
|
|
320
|
+
Watir.element_class_for(element.tag_name.downcase).new(scope, element: element)
|
|
321
|
+
end
|
|
322
|
+
end # Browser
|
|
323
|
+
end # Watir
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Watir
|
|
4
|
+
class Capabilities
|
|
5
|
+
attr_reader :options, :selenium_browser, :selenium_args
|
|
6
|
+
|
|
7
|
+
def initialize(browser = nil, options = {})
|
|
8
|
+
@options, @browser = case browser
|
|
9
|
+
when Selenium::WebDriver::Driver
|
|
10
|
+
return
|
|
11
|
+
when ::Symbol, String
|
|
12
|
+
[options.dup, browser&.to_sym]
|
|
13
|
+
when Hash
|
|
14
|
+
[browser.dup, infer_browser(browser)]
|
|
15
|
+
when nil
|
|
16
|
+
[{}, infer_browser]
|
|
17
|
+
else
|
|
18
|
+
raise ArgumentError,
|
|
19
|
+
"expected Driver, String, Symbol or Hash, but received: #{browser.class}"
|
|
20
|
+
end
|
|
21
|
+
validate_options
|
|
22
|
+
|
|
23
|
+
@selenium_browser = @options.key?(:url) ? :remote : @browser
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def to_args
|
|
27
|
+
Watir.logger.info "Creating Browser instance of #{@browser} with user provided options: #{@options.inspect}"
|
|
28
|
+
@selenium_args = process_arguments
|
|
29
|
+
raise ArgumentError, "#{@options} are unrecognized arguments for Browser constructor" unless @options.empty?
|
|
30
|
+
|
|
31
|
+
Watir.logger.info "Selenium options generated by Watir: #{@selenium_args.inspect}"
|
|
32
|
+
[@selenium_browser, @selenium_args]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def process_arguments
|
|
38
|
+
selenium_opts = {}
|
|
39
|
+
selenium_opts[:listener] = @options.delete(:listener) if @options.key?(:listener)
|
|
40
|
+
|
|
41
|
+
if @options.key?(:url)
|
|
42
|
+
selenium_opts[:url] = @options.delete(:url)
|
|
43
|
+
else
|
|
44
|
+
service = process_service
|
|
45
|
+
selenium_opts[:service] = service if service
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
selenium_opts[:http_client] = process_http_client
|
|
49
|
+
if @options.key?(:capabilities)
|
|
50
|
+
Watir.logger.deprecate(':capabilities argument in Browser constructor',
|
|
51
|
+
':options argument with Selenium Options instance or Hash',
|
|
52
|
+
id: :capabilities)
|
|
53
|
+
selenium_opts[:capabilities] = @options.delete(:capabilities)
|
|
54
|
+
else
|
|
55
|
+
selenium_opts[:options] = process_browser_options
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
selenium_opts
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def process_http_client
|
|
62
|
+
http_client = @options.delete(:http_client) || Watir::HttpClient.new
|
|
63
|
+
|
|
64
|
+
case http_client
|
|
65
|
+
when Hash
|
|
66
|
+
Watir::HttpClient.new(**http_client)
|
|
67
|
+
when Watir::HttpClient
|
|
68
|
+
http_client
|
|
69
|
+
when Selenium::WebDriver::Remote::Http::Common
|
|
70
|
+
Watir.logger.warn 'Check out the new Watir::HttpClient and let us know if there are missing features you need',
|
|
71
|
+
id: [:watir_client]
|
|
72
|
+
http_client
|
|
73
|
+
else
|
|
74
|
+
raise TypeError, ':http_client must be a Hash or a Selenium HTTP Client instance'
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def process_browser_options
|
|
79
|
+
browser_options = @options.delete(:options).dup || {}
|
|
80
|
+
|
|
81
|
+
options = if browser_options.is_a? Selenium::WebDriver::Options
|
|
82
|
+
browser_options
|
|
83
|
+
else
|
|
84
|
+
convert_timeouts(browser_options)
|
|
85
|
+
Selenium::WebDriver::Options.send(@browser, **browser_options)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
options.unhandled_prompt_behavior ||= :ignore
|
|
89
|
+
process_proxy_options(options)
|
|
90
|
+
browser_specific_options(options)
|
|
91
|
+
|
|
92
|
+
options
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def process_proxy_options(options)
|
|
96
|
+
proxy = @options.delete(:proxy)
|
|
97
|
+
return if proxy.nil?
|
|
98
|
+
|
|
99
|
+
proxy &&= Selenium::WebDriver::Proxy.new(proxy) if proxy.is_a?(Hash)
|
|
100
|
+
|
|
101
|
+
unless proxy.is_a?(Selenium::WebDriver::Proxy)
|
|
102
|
+
raise TypeError, "#{proxy} needs to be Selenium Proxy or Hash instance"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
options.proxy = proxy
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def convert_timeouts(browser_options)
|
|
109
|
+
browser_options[:timeouts] ||= {}
|
|
110
|
+
browser_options[:timeouts].each_key do |key|
|
|
111
|
+
raise(ArgumentError, 'do not set implicit wait, Watir handles waiting automatically') if key.to_s == 'implicit'
|
|
112
|
+
|
|
113
|
+
Watir.logger.deprecate('using timeouts directly in options',
|
|
114
|
+
":#{key}_timeout",
|
|
115
|
+
id: :timeouts)
|
|
116
|
+
end
|
|
117
|
+
if browser_options.key?(:page_load_timeout)
|
|
118
|
+
browser_options[:timeouts][:page_load] = browser_options.delete(:page_load_timeout) * 1000
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
return unless browser_options.key?(:script_timeout)
|
|
122
|
+
|
|
123
|
+
browser_options[:timeouts][:script] = browser_options.delete(:script_timeout) * 1000
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def browser_specific_options(options)
|
|
127
|
+
case @browser
|
|
128
|
+
when :chrome, :edge, :microsoftedge
|
|
129
|
+
if @options.delete(:headless)
|
|
130
|
+
options.args << '--headless'
|
|
131
|
+
options.args << '--disable-gpu'
|
|
132
|
+
options.args << '--no-sandbox'
|
|
133
|
+
end
|
|
134
|
+
when :firefox
|
|
135
|
+
options.args << '-headless' if @options.delete(:headless)
|
|
136
|
+
when :safari
|
|
137
|
+
Selenium::WebDriver::Safari.technology_preview! if @options.delete(:technology_preview)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def process_service
|
|
142
|
+
service = @options.delete(:service)
|
|
143
|
+
|
|
144
|
+
case service
|
|
145
|
+
when nil
|
|
146
|
+
nil
|
|
147
|
+
when Hash
|
|
148
|
+
return if service.empty?
|
|
149
|
+
|
|
150
|
+
Selenium::WebDriver::Service.send(@browser, **service)
|
|
151
|
+
when Selenium::WebDriver::Service
|
|
152
|
+
service
|
|
153
|
+
else
|
|
154
|
+
raise TypeError, "#{service} needs to be Selenium Service or Hash instance"
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def infer_browser(options = nil)
|
|
159
|
+
options ||= {}
|
|
160
|
+
inferred = if options.key?(:capabilities)
|
|
161
|
+
options[:capabilities].browser_name.tr(' ', '_').downcase.to_sym
|
|
162
|
+
elsif options[:options].is_a?(Selenium::WebDriver::Options)
|
|
163
|
+
options[:options].class.to_s.split('::')[-2].downcase.to_sym
|
|
164
|
+
elsif options.key?(:options)
|
|
165
|
+
options.dig(:options, :browser_name).tr(' ', '_').downcase.to_sym
|
|
166
|
+
else
|
|
167
|
+
:chrome
|
|
168
|
+
end
|
|
169
|
+
%i[msedge microsoftedge].include?(inferred) ? :edge : inferred
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def validate_options
|
|
173
|
+
if @options.key?(:capabilities) && @options.key?(:options)
|
|
174
|
+
raise(ArgumentError, ':capabilities and :options are not both allowed')
|
|
175
|
+
end
|
|
176
|
+
raise(ArgumentError, ':url and :service are not both allowed') if @options.key?(:service) && @options.key?(:url)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Watir
|
|
4
|
+
module CellContainer
|
|
5
|
+
#
|
|
6
|
+
# Returns table cell.
|
|
7
|
+
#
|
|
8
|
+
# @return [Cell]
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
def cell(opts = {})
|
|
12
|
+
Cell.new(self, opts)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
#
|
|
16
|
+
# Returns table cells collection.
|
|
17
|
+
#
|
|
18
|
+
# @return [Cell]
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
def cells(opts = {})
|
|
22
|
+
CellCollection.new(self, opts)
|
|
23
|
+
end
|
|
24
|
+
end # CellContainer
|
|
25
|
+
end # Watir
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Watir
|
|
4
|
+
module Container
|
|
5
|
+
include JSSnippets
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Returns element.
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# browser.element(data_bind: 'func')
|
|
12
|
+
#
|
|
13
|
+
# @return [HTMLElement]
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
def element(opts = {})
|
|
17
|
+
HTMLElement.new(self, opts)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
#
|
|
21
|
+
# Returns element collection.
|
|
22
|
+
#
|
|
23
|
+
# @example
|
|
24
|
+
# browser.elements(data_bind: 'func')
|
|
25
|
+
#
|
|
26
|
+
# @return [HTMLElementCollection]
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
def elements(opts = {})
|
|
30
|
+
HTMLElementCollection.new(self, opts)
|
|
31
|
+
end
|
|
32
|
+
end # Container
|
|
33
|
+
end # Watir
|