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,670 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'unit_helper'
|
|
4
|
+
|
|
5
|
+
module Watir
|
|
6
|
+
describe Capabilities do
|
|
7
|
+
before(:all) { Watir.logger.ignore(:watir_client) }
|
|
8
|
+
|
|
9
|
+
def expected_browser(browser)
|
|
10
|
+
case browser
|
|
11
|
+
when :ie
|
|
12
|
+
'internet explorer'
|
|
13
|
+
when :edge
|
|
14
|
+
'MicrosoftEdge'
|
|
15
|
+
else
|
|
16
|
+
browser.to_s
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def service_class(browser)
|
|
21
|
+
Selenium.const_get("Selenium::WebDriver::#{expected_browser_class(browser)}::Service")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def options_class(browser)
|
|
25
|
+
Selenium.const_get("Selenium::WebDriver::#{expected_browser_class(browser)}::Options")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def expected_browser_class(browser)
|
|
29
|
+
browser == :ie ? 'IE' : browser.capitalize
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def halt_service(browser)
|
|
33
|
+
allow(Selenium::WebDriver::Platform).to receive(:find_binary).and_return(true)
|
|
34
|
+
allow(File).to receive_messages(file?: true, executable?: true)
|
|
35
|
+
service_class(browser).driver_path = nil
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
supported_browsers = %i[chrome edge firefox ie safari]
|
|
39
|
+
|
|
40
|
+
# Options:
|
|
41
|
+
# :listener
|
|
42
|
+
# :service (Built from Hash)
|
|
43
|
+
# :http_client (Generated or Built from Hash)
|
|
44
|
+
# :proxy (Built from Hash and added to :options)
|
|
45
|
+
# :options (Generated or Built from Hash)
|
|
46
|
+
# :capabilities (incompatible with options)
|
|
47
|
+
|
|
48
|
+
supported_browsers.each do |browser_symbol|
|
|
49
|
+
it 'just browser has client & options not service' do
|
|
50
|
+
capabilities = described_class.new(browser_symbol)
|
|
51
|
+
|
|
52
|
+
args = capabilities.to_args
|
|
53
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
54
|
+
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
|
55
|
+
expect(args.last).not_to include(:service)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'errors with url and service' do
|
|
59
|
+
expect {
|
|
60
|
+
described_class.new(browser_symbol,
|
|
61
|
+
service: instance_double(Selenium::WebDriver::Service),
|
|
62
|
+
url: 'https://example.com/wd/hub/')
|
|
63
|
+
}.to raise_exception(ArgumentError, ':url and :service are not both allowed')
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'just options has client & options but not capabilities or service' do
|
|
67
|
+
capabilities = described_class.new(options: options_class(browser_symbol).new)
|
|
68
|
+
|
|
69
|
+
args = capabilities.to_args
|
|
70
|
+
|
|
71
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
72
|
+
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
|
73
|
+
expect(args.last).not_to include(:service)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'just capabilities has client & capabilities but not service' do
|
|
77
|
+
caps = Selenium::WebDriver::Remote::Capabilities.new(browser_name: expected_browser(browser_symbol))
|
|
78
|
+
capabilities = described_class.new(capabilities: caps)
|
|
79
|
+
args = []
|
|
80
|
+
expect {
|
|
81
|
+
args = capabilities.to_args
|
|
82
|
+
}.to have_deprecated(:capabilities)
|
|
83
|
+
|
|
84
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
85
|
+
expect(args.last[:capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
86
|
+
expect(args.last[:capabilities].browser_name).to eq expected_browser(browser_symbol)
|
|
87
|
+
expect(args.last).not_to include(:service)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe 'service' do
|
|
91
|
+
it 'uses provided service' do
|
|
92
|
+
halt_service(browser_symbol)
|
|
93
|
+
|
|
94
|
+
service = service_class(browser_symbol).new(port: 1234)
|
|
95
|
+
capabilities = described_class.new(browser_symbol, service: service)
|
|
96
|
+
args = capabilities.to_args
|
|
97
|
+
expect(args.first).to eq browser_symbol
|
|
98
|
+
actual_service = args.last[:service]
|
|
99
|
+
expect(actual_service.instance_variable_get(:@port)).to eq 1234
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'builds service from a Hash' do
|
|
103
|
+
halt_service(browser_symbol)
|
|
104
|
+
|
|
105
|
+
service = {port: 1234, path: '/path/to/driver', args: %w[--foo --bar]}
|
|
106
|
+
capabilities = described_class.new(browser_symbol, service: service)
|
|
107
|
+
args = capabilities.to_args
|
|
108
|
+
expect(args.first).to eq browser_symbol
|
|
109
|
+
actual_service = args.last[:service]
|
|
110
|
+
expect(actual_service.instance_variable_get(:@port)).to eq 1234
|
|
111
|
+
expect(actual_service.instance_variable_get(:@executable_path)).to eq '/path/to/driver'
|
|
112
|
+
expect(actual_service.instance_variable_get(:@args)).to include '--foo', '--bar'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it 'is a bad argument to service' do
|
|
116
|
+
capabilities = described_class.new(browser_symbol, service: 7)
|
|
117
|
+
|
|
118
|
+
expect { capabilities.to_args }.to raise_exception(TypeError)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe 'http_client' do
|
|
123
|
+
it 'uses default HTTP Client' do
|
|
124
|
+
capabilities = described_class.new(browser_symbol)
|
|
125
|
+
args = capabilities.to_args
|
|
126
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'accepts an HTTP Client object' do
|
|
130
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
|
131
|
+
capabilities = described_class.new(browser_symbol, http_client: client)
|
|
132
|
+
args = capabilities.to_args
|
|
133
|
+
expect(args.last[:http_client]).to eq client
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it 'builds an HTTP Client from Hash' do
|
|
137
|
+
client_opts = {open_timeout: 10, read_timeout: 10}
|
|
138
|
+
capabilities = described_class.new(browser_symbol, http_client: client_opts)
|
|
139
|
+
args = capabilities.to_args
|
|
140
|
+
actual_client = args.last[:http_client]
|
|
141
|
+
expect(actual_client).to be_a HttpClient
|
|
142
|
+
expect(actual_client.instance_variable_get(:@read_timeout)).to eq 10
|
|
143
|
+
expect(actual_client.instance_variable_get(:@open_timeout)).to eq 10
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it 'raises an exception if :client receives something other than Hash or Client object' do
|
|
147
|
+
expect {
|
|
148
|
+
described_class.new(browser_symbol, http_client: 7).to_args
|
|
149
|
+
}.to raise_exception(TypeError, ':http_client must be a Hash or a Selenium HTTP Client instance')
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it 'uses a listener' do
|
|
154
|
+
listener = Selenium::WebDriver::Support::AbstractEventListener.new
|
|
155
|
+
capabilities = described_class.new(browser_symbol, listener: listener)
|
|
156
|
+
args = capabilities.to_args
|
|
157
|
+
expect(args.last[:listener]).to eq listener
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it 'accepts both capabilities and Options' do
|
|
161
|
+
caps = Selenium::WebDriver::Remote::Capabilities.new(browser_name: expected_browser(browser_symbol))
|
|
162
|
+
opts = options_class(browser_symbol).new
|
|
163
|
+
|
|
164
|
+
expect {
|
|
165
|
+
described_class.new(browser_symbol, capabilities: caps, options: opts)
|
|
166
|
+
}.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
describe 'timeout options' do
|
|
170
|
+
it 'accepts page load and script timeouts in seconds' do
|
|
171
|
+
options = {page_load_timeout: 11,
|
|
172
|
+
script_timeout: 12}
|
|
173
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
174
|
+
args = capabilities.to_args
|
|
175
|
+
actual_options = args.last[:options]
|
|
176
|
+
expect(actual_options.timeouts[:page_load]).to eq 11_000
|
|
177
|
+
expect(actual_options.timeouts[:script]).to eq 12_000
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it 'has deprecated timeouts key with page load warning' do
|
|
181
|
+
options = {timeouts: {page_load: 11}}
|
|
182
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
183
|
+
expect {
|
|
184
|
+
capabilities.to_args
|
|
185
|
+
}.to have_deprecated(:timeouts)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it 'has deprecated timeouts key with script warning' do
|
|
189
|
+
options = {timeouts: {script: 11}}
|
|
190
|
+
expect {
|
|
191
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
192
|
+
capabilities.to_args
|
|
193
|
+
}.to have_deprecated(:timeouts)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it 'does not allow implicit wait timeout in timeouts hash' do
|
|
197
|
+
options = {timeouts: {implicit: 1}}
|
|
198
|
+
capabilities = described_class.new(browser_symbol, options: options)
|
|
199
|
+
expect {
|
|
200
|
+
capabilities.to_args
|
|
201
|
+
}.to raise_exception(ArgumentError, 'do not set implicit wait, Watir handles waiting automatically')
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it 'unhandled prompt behavior defaults to ignore' do
|
|
206
|
+
capabilities = described_class.new(browser_symbol)
|
|
207
|
+
args = capabilities.to_args
|
|
208
|
+
actual_options = args.last[:options]
|
|
209
|
+
expect(actual_options.unhandled_prompt_behavior).to eq :ignore
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it 'unhandled prompt behavior can be overridden' do
|
|
213
|
+
capabilities = described_class.new(browser_symbol, options: {unhandled_prompt_behavior: :accept_and_notify})
|
|
214
|
+
args = capabilities.to_args
|
|
215
|
+
actual_options = args.last[:options]
|
|
216
|
+
expect(actual_options.unhandled_prompt_behavior).to eq :accept_and_notify
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
describe 'proxy' do
|
|
220
|
+
it 'adds Selenium Proxy to empty Options' do
|
|
221
|
+
proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
|
|
222
|
+
capabilities = described_class.new(browser_symbol, proxy: proxy)
|
|
223
|
+
args = capabilities.to_args
|
|
224
|
+
proxy = args.last[:options].proxy
|
|
225
|
+
|
|
226
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
227
|
+
expect(proxy.type).to eq(:manual)
|
|
228
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
229
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it 'builds a Proxy from Hash for Options' do
|
|
233
|
+
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
234
|
+
capabilities = described_class.new(browser_symbol, proxy: proxy)
|
|
235
|
+
args = capabilities.to_args
|
|
236
|
+
proxy = args.last[:options].proxy
|
|
237
|
+
|
|
238
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
239
|
+
expect(proxy.type).to eq(:manual)
|
|
240
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
241
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
it 'builds a Proxy from Hash and adds to Options' do
|
|
245
|
+
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
246
|
+
options = {unhandled_prompt_behavior: :accept,
|
|
247
|
+
page_load_strategy: :eager}
|
|
248
|
+
|
|
249
|
+
capabilities = described_class.new(browser_symbol, options: options, proxy: proxy)
|
|
250
|
+
args = capabilities.to_args
|
|
251
|
+
actual_options = args.last[:options]
|
|
252
|
+
|
|
253
|
+
expect(actual_options.proxy).to be_a Selenium::WebDriver::Proxy
|
|
254
|
+
expect(actual_options.proxy.type).to eq(:manual)
|
|
255
|
+
expect(actual_options.proxy.http).to eq('127.0.0.1:8080')
|
|
256
|
+
expect(actual_options.proxy.ssl).to eq('127.0.0.1:443')
|
|
257
|
+
expect(actual_options.unhandled_prompt_behavior).to eq :accept
|
|
258
|
+
expect(actual_options.page_load_strategy).to eq :eager
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
it 'errors on bad proxy key' do
|
|
263
|
+
proxy = {bad_key: 'foo'}
|
|
264
|
+
capabilities = described_class.new(browser_symbol, proxy: proxy)
|
|
265
|
+
|
|
266
|
+
expect { capabilities.to_args }.to raise_error(ArgumentError, /unknown option/)
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
it 'errors on bad proxy object' do
|
|
270
|
+
capabilities = described_class.new(browser_symbol, proxy: 7)
|
|
271
|
+
expect {
|
|
272
|
+
capabilities.to_args
|
|
273
|
+
}.to raise_exception(TypeError, '7 needs to be Selenium Proxy or Hash instance')
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# Options:
|
|
278
|
+
# :url (Required)
|
|
279
|
+
# :service (Errors)
|
|
280
|
+
# :listener
|
|
281
|
+
# :http_client (Generated or Built from Hash)
|
|
282
|
+
# :proxy (Built from Hash and added to :options)
|
|
283
|
+
# :options (Generated or Built from Hash)
|
|
284
|
+
# :capabilities (incompatible with options)
|
|
285
|
+
|
|
286
|
+
describe 'Remote execution' do
|
|
287
|
+
it 'with just url' do
|
|
288
|
+
capabilities = described_class.new(url: 'http://example.com')
|
|
289
|
+
args = capabilities.to_args
|
|
290
|
+
expect(args.first).to eq :remote
|
|
291
|
+
actual_options = args.last[:options]
|
|
292
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
it 'just url & browser name has capabilities and client but not service' do
|
|
296
|
+
capabilities = described_class.new(:firefox,
|
|
297
|
+
url: 'https://example.com/wd/hub/')
|
|
298
|
+
args = capabilities.to_args
|
|
299
|
+
expect(args.first).to eq :remote
|
|
300
|
+
expect(args.last[:url]).to eq 'https://example.com/wd/hub/'
|
|
301
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
302
|
+
|
|
303
|
+
expect(args.last[:options]).to be_a Selenium::WebDriver::Firefox::Options
|
|
304
|
+
expect(args.last).not_to include(:service)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
it 'accepts a listener' do
|
|
308
|
+
listener = Selenium::WebDriver::Support::AbstractEventListener.new
|
|
309
|
+
capabilities = described_class.new(:chrome,
|
|
310
|
+
url: 'http://example.com/wd/hub/',
|
|
311
|
+
listener: listener)
|
|
312
|
+
args = capabilities.to_args
|
|
313
|
+
expect(args.last[:listener]).to eq listener
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
it 'accepts http client object' do
|
|
317
|
+
client = HttpClient.new
|
|
318
|
+
capabilities = described_class.new(:chrome,
|
|
319
|
+
url: 'https://example.com/wd/hub',
|
|
320
|
+
http_client: client)
|
|
321
|
+
args = capabilities.to_args
|
|
322
|
+
expect(args.first).to eq :remote
|
|
323
|
+
expect(args.last[:http_client]).to eq client
|
|
324
|
+
actual_options = args.last[:options]
|
|
325
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
it 'accepts http client Hash' do
|
|
329
|
+
capabilities = described_class.new(:chrome,
|
|
330
|
+
url: 'https://example.com/wd/hub',
|
|
331
|
+
http_client: {read_timeout: 30})
|
|
332
|
+
args = capabilities.to_args
|
|
333
|
+
expect(args.first).to eq :remote
|
|
334
|
+
expect(args.last[:http_client].instance_variable_get(:@read_timeout)).to eq 30
|
|
335
|
+
actual_options = args.last[:options]
|
|
336
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
it 'accepts proxy object' do
|
|
340
|
+
proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
|
|
341
|
+
capabilities = described_class.new(:chrome,
|
|
342
|
+
url: 'https://example.com/wd/hub',
|
|
343
|
+
proxy: proxy)
|
|
344
|
+
args = capabilities.to_args
|
|
345
|
+
expect(args.first).to eq :remote
|
|
346
|
+
proxy = args.last[:options].proxy
|
|
347
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
348
|
+
expect(proxy.type).to eq(:manual)
|
|
349
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
350
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
it 'accepts proxy Hash' do
|
|
354
|
+
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
355
|
+
capabilities = described_class.new(:chrome,
|
|
356
|
+
url: 'https://example.com/wd/hub',
|
|
357
|
+
proxy: proxy)
|
|
358
|
+
args = capabilities.to_args
|
|
359
|
+
expect(args.first).to eq :remote
|
|
360
|
+
proxy = args.last[:options].proxy
|
|
361
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
362
|
+
expect(proxy.type).to eq(:manual)
|
|
363
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
364
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
it 'accepts options object' do
|
|
368
|
+
capabilities = described_class.new(:chrome,
|
|
369
|
+
url: 'https://example.com/wd/hub',
|
|
370
|
+
options: Selenium::WebDriver::Chrome::Options.new(args: ['--foo']))
|
|
371
|
+
args = capabilities.to_args
|
|
372
|
+
expect(args.first).to eq :remote
|
|
373
|
+
actual_options = args.last[:options]
|
|
374
|
+
expect(actual_options.browser_name).to eq 'chrome'
|
|
375
|
+
expect(actual_options.args).to include('--foo')
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
it 'accepts options hash' do
|
|
379
|
+
options = {prefs: {foo: 'bar'}}
|
|
380
|
+
capabilities = described_class.new(:chrome,
|
|
381
|
+
url: 'http://example.com',
|
|
382
|
+
options: options)
|
|
383
|
+
args = capabilities.to_args
|
|
384
|
+
expect(args.first).to eq :remote
|
|
385
|
+
expect(args.last[:url]).to eq 'http://example.com'
|
|
386
|
+
actual_options = args.last[:options]
|
|
387
|
+
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
388
|
+
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
it 'accepts capabilities object' do
|
|
392
|
+
caps = described_class.new(:chrome,
|
|
393
|
+
url: 'https://example.com/wd/hub',
|
|
394
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.new(browser_name: 'chrome'))
|
|
395
|
+
args = []
|
|
396
|
+
expect {
|
|
397
|
+
args = caps.to_args
|
|
398
|
+
}.to have_deprecated(:capabilities)
|
|
399
|
+
|
|
400
|
+
expect(args.first).to eq :remote
|
|
401
|
+
actual_capabilities = args.last[:capabilities]
|
|
402
|
+
expect(actual_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
403
|
+
expect(actual_capabilities.browser_name).to eq 'chrome'
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
it 'accepts http client & capabilities objects' do
|
|
407
|
+
client = HttpClient.new
|
|
408
|
+
caps = described_class.new(:chrome,
|
|
409
|
+
url: 'https://example.com/wd/hub',
|
|
410
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.new(browser_name: 'chrome'),
|
|
411
|
+
http_client: client)
|
|
412
|
+
args = []
|
|
413
|
+
expect {
|
|
414
|
+
args = caps.to_args
|
|
415
|
+
}.to have_deprecated(:capabilities)
|
|
416
|
+
|
|
417
|
+
expect(args.first).to eq :remote
|
|
418
|
+
expect(args.last[:http_client]).to eq client
|
|
419
|
+
actual_capabilities = args.last[:capabilities]
|
|
420
|
+
expect(actual_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
|
421
|
+
expect(actual_capabilities.browser_name).to eq 'chrome'
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
it 'accepts http client & proxy & options objects' do
|
|
425
|
+
client = HttpClient.new
|
|
426
|
+
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
|
427
|
+
options = Selenium::WebDriver::Chrome::Options.new(prefs: {foo: 'bar'})
|
|
428
|
+
caps = described_class.new(:chrome,
|
|
429
|
+
url: 'https://example.com/wd/hub',
|
|
430
|
+
proxy: proxy,
|
|
431
|
+
options: options,
|
|
432
|
+
http_client: client)
|
|
433
|
+
|
|
434
|
+
args = caps.to_args
|
|
435
|
+
expect(args.first).to eq :remote
|
|
436
|
+
expect(args.last[:http_client]).to eq client
|
|
437
|
+
actual_options = args.last[:options]
|
|
438
|
+
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
439
|
+
expect(actual_options.prefs).to eq(foo: 'bar')
|
|
440
|
+
proxy = args.last[:options].proxy
|
|
441
|
+
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
|
442
|
+
expect(proxy.type).to eq(:manual)
|
|
443
|
+
expect(proxy.http).to eq('127.0.0.1:8080')
|
|
444
|
+
expect(proxy.ssl).to eq('127.0.0.1:443')
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
it 'raises exception when both options & capabilities defined' do
|
|
448
|
+
options = {prefs: {foo: 'bar'}}
|
|
449
|
+
|
|
450
|
+
expect {
|
|
451
|
+
described_class.new(:chrome,
|
|
452
|
+
url: 'https://example.com/wd/hub',
|
|
453
|
+
capabilities: Selenium::WebDriver::Remote::Capabilities.new(browser_name: 'chrome'),
|
|
454
|
+
options: options)
|
|
455
|
+
}.to raise_exception(ArgumentError, ':capabilities and :options are not both allowed')
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
it 'allows headless to be set in chrome' do
|
|
459
|
+
capabilities = described_class.new(:chrome,
|
|
460
|
+
headless: true,
|
|
461
|
+
url: 'http://example.com')
|
|
462
|
+
args = capabilities.to_args
|
|
463
|
+
actual_options = args.last[:options]
|
|
464
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
it 'allows headless to be set in firefox' do
|
|
468
|
+
capabilities = described_class.new(:firefox,
|
|
469
|
+
headless: true,
|
|
470
|
+
url: 'http://example.com')
|
|
471
|
+
args = capabilities.to_args
|
|
472
|
+
|
|
473
|
+
expect(args.last[:options].args).to include '-headless'
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
it 'supports multiple vendor capabilities' do
|
|
477
|
+
sauce_options = {'sauce:options': {username: ENV.fetch('SAUCE_USERNAME', nil),
|
|
478
|
+
access_key: ENV.fetch('SAUCE_ACCESS_KEY', nil)}}
|
|
479
|
+
other_options = {'other:options': {foo: 'bar'}}
|
|
480
|
+
|
|
481
|
+
capabilities = described_class.new(:chrome,
|
|
482
|
+
options: sauce_options.merge(other_options),
|
|
483
|
+
url: 'https://ondemand.us-west-1.saucelabs.com')
|
|
484
|
+
|
|
485
|
+
generated_options = capabilities.to_args.last[:options]
|
|
486
|
+
expect(generated_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
|
487
|
+
expect(generated_options.unhandled_prompt_behavior).to eq :ignore
|
|
488
|
+
actual_options = generated_options.instance_variable_get(:@options)
|
|
489
|
+
expect(actual_options[:'sauce:options']).to eq sauce_options[:'sauce:options']
|
|
490
|
+
expect(actual_options[:'other:options']).to eq other_options[:'other:options']
|
|
491
|
+
end
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
describe 'chrome' do
|
|
495
|
+
it 'by default uses chrome, has client, options, but not capabilities' do
|
|
496
|
+
capabilities = described_class.new
|
|
497
|
+
args = capabilities.to_args
|
|
498
|
+
expect(args.last[:http_client]).to be_a HttpClient
|
|
499
|
+
expect(args.last[:options]).to be_a Selenium::WebDriver::Chrome::Options
|
|
500
|
+
expect(args.last).not_to include(:service)
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
it 'sets headless by creating options' do
|
|
504
|
+
capabilities = described_class.new(:chrome, headless: true)
|
|
505
|
+
args = capabilities.to_args
|
|
506
|
+
actual_options = args.last[:options]
|
|
507
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
it 'sets headless in existing options class' do
|
|
511
|
+
capabilities = described_class.new(:chrome,
|
|
512
|
+
options: Selenium::WebDriver::Chrome::Options.new,
|
|
513
|
+
headless: true)
|
|
514
|
+
args = capabilities.to_args
|
|
515
|
+
actual_options = args.last[:options]
|
|
516
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
it 'sets headless when existing options is a Hash' do
|
|
520
|
+
options = {args: ['--foo']}
|
|
521
|
+
capabilities = described_class.new(:chrome,
|
|
522
|
+
options: options,
|
|
523
|
+
headless: true)
|
|
524
|
+
args = capabilities.to_args
|
|
525
|
+
actual_options = args.last[:options]
|
|
526
|
+
expect(actual_options.args).to include '--headless', '--disable-gpu', '--foo'
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
it 'generates options from Hash' do
|
|
530
|
+
options = {args: %w[--foo --bar]}
|
|
531
|
+
capabilities = described_class.new(:chrome, options: options)
|
|
532
|
+
args = capabilities.to_args
|
|
533
|
+
actual_options = args.last[:options]
|
|
534
|
+
expect(actual_options).to be_a Selenium::WebDriver::Chrome::Options
|
|
535
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
539
|
+
opts = {page_load_strategy: 'eager',
|
|
540
|
+
args: %w[--foo --bar]}
|
|
541
|
+
capabilities = described_class.new(:chrome,
|
|
542
|
+
options: opts)
|
|
543
|
+
args = capabilities.to_args
|
|
544
|
+
actual_options = args.last[:options]
|
|
545
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
546
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
547
|
+
end
|
|
548
|
+
end
|
|
549
|
+
|
|
550
|
+
describe 'firefox' do
|
|
551
|
+
it 'puts Profile inside Options as Hash' do
|
|
552
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
553
|
+
options = {args: ['--foo'], profile: profile}
|
|
554
|
+
|
|
555
|
+
capabilities = described_class.new(:firefox, options: options)
|
|
556
|
+
|
|
557
|
+
actual_options = capabilities.to_args.last[:options]
|
|
558
|
+
expect(actual_options.args).to include '--foo'
|
|
559
|
+
expect(actual_options.profile).to eq profile
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
it 'sets headless by creating options' do
|
|
563
|
+
capabilities = described_class.new(:firefox, headless: true)
|
|
564
|
+
args = capabilities.to_args
|
|
565
|
+
actual_options = args.last[:options]
|
|
566
|
+
expect(actual_options.args).to include '-headless'
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
it 'sets headless in existing options class' do
|
|
570
|
+
capabilities = described_class.new(:firefox,
|
|
571
|
+
options: Selenium::WebDriver::Firefox::Options.new,
|
|
572
|
+
headless: true)
|
|
573
|
+
args = capabilities.to_args
|
|
574
|
+
actual_options = args.last[:options]
|
|
575
|
+
expect(actual_options.args).to include '-headless'
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
it 'sets headless when existing options is a Hash' do
|
|
579
|
+
options = {args: ['-foo']}
|
|
580
|
+
capabilities = described_class.new(:firefox,
|
|
581
|
+
options: options,
|
|
582
|
+
headless: true)
|
|
583
|
+
args = capabilities.to_args
|
|
584
|
+
actual_options = args.last[:options]
|
|
585
|
+
expect(actual_options.args).to include '-headless', '-foo'
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
it 'generates Options instance from Hash' do
|
|
589
|
+
options = {args: %w[--foo --bar]}
|
|
590
|
+
capabilities = described_class.new(:firefox, options: options)
|
|
591
|
+
args = capabilities.to_args
|
|
592
|
+
actual_options = args.last[:options]
|
|
593
|
+
expect(actual_options).to be_a Selenium::WebDriver::Firefox::Options
|
|
594
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
598
|
+
opts = {page_load_strategy: 'eager',
|
|
599
|
+
args: %w[--foo --bar]}
|
|
600
|
+
capabilities = described_class.new(:firefox,
|
|
601
|
+
options: opts)
|
|
602
|
+
args = capabilities.to_args
|
|
603
|
+
actual_options = args.last[:options]
|
|
604
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
605
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
606
|
+
end
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
describe 'safari' do
|
|
610
|
+
it 'sets Technology Preview' do
|
|
611
|
+
halt_service(:safari)
|
|
612
|
+
|
|
613
|
+
described_class.new(:safari, technology_preview: true).to_args
|
|
614
|
+
|
|
615
|
+
expect(Selenium::WebDriver::Safari.technology_preview?).to be true
|
|
616
|
+
end
|
|
617
|
+
|
|
618
|
+
it 'generates options from Hash' do
|
|
619
|
+
options = {automatic_inspection: true}
|
|
620
|
+
capabilities = described_class.new(:safari, options: options)
|
|
621
|
+
args = capabilities.to_args
|
|
622
|
+
actual_options = args.last[:options]
|
|
623
|
+
expect(actual_options).to be_a Selenium::WebDriver::Safari::Options
|
|
624
|
+
expect(actual_options.automatic_inspection).to be true
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
628
|
+
opts = {page_load_strategy: 'eager',
|
|
629
|
+
automatic_inspection: true}
|
|
630
|
+
capabilities = described_class.new(:safari,
|
|
631
|
+
options: opts)
|
|
632
|
+
args = capabilities.to_args
|
|
633
|
+
actual_options = args.last[:options]
|
|
634
|
+
expect(actual_options.automatic_inspection).to be true
|
|
635
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
636
|
+
end
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
describe 'ie' do
|
|
640
|
+
it 'generates Options instance from Hash with args' do
|
|
641
|
+
options = {args: %w[--foo --bar]}
|
|
642
|
+
capabilities = described_class.new(:ie, options: options)
|
|
643
|
+
args = capabilities.to_args
|
|
644
|
+
actual_options = args.last[:options]
|
|
645
|
+
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
|
646
|
+
expect(actual_options.args).to include '--foo', '--bar'
|
|
647
|
+
end
|
|
648
|
+
|
|
649
|
+
it 'generates Options instance from Hash with valid option' do
|
|
650
|
+
options = {browser_attach_timeout: true}
|
|
651
|
+
capabilities = described_class.new(:ie, options: options)
|
|
652
|
+
args = capabilities.to_args
|
|
653
|
+
actual_options = args.last[:options]
|
|
654
|
+
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
|
655
|
+
expect(actual_options.options[:browser_attach_timeout]).to be true
|
|
656
|
+
end
|
|
657
|
+
|
|
658
|
+
it 'accepts browser and w3c capabilities in options Hash' do
|
|
659
|
+
opts = {page_load_strategy: 'eager',
|
|
660
|
+
args: ['--foo']}
|
|
661
|
+
capabilities = described_class.new(:ie,
|
|
662
|
+
options: opts)
|
|
663
|
+
args = capabilities.to_args
|
|
664
|
+
actual_options = args.last[:options]
|
|
665
|
+
expect(actual_options.args).to include '--foo'
|
|
666
|
+
expect(actual_options.page_load_strategy).to eq 'eager'
|
|
667
|
+
end
|
|
668
|
+
end
|
|
669
|
+
end
|
|
670
|
+
end
|