selenium-webdriver 3.5.0 → 4.0.0-alpha.4
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.
- package/CHANGES.md +246 -0
- package/LICENSE +1 -1
- package/NOTICE +1 -1
- package/README.md +40 -40
- package/chrome.js +118 -134
- package/edge.js +43 -117
- package/example/chrome_android.js +8 -9
- package/example/chrome_mobile_emulation.js +8 -9
- package/example/firefox_channels.js +23 -19
- package/example/google_search.js +3 -3
- package/example/google_search_test.js +38 -27
- package/example/{chrome_headless.js → headless.js} +15 -7
- package/example/logging.js +40 -7
- package/firefox.js +789 -0
- package/http/index.js +62 -9
- package/http/util.js +11 -6
- package/ie.js +83 -97
- package/index.js +198 -114
- package/io/exec.js +29 -15
- package/io/index.js +1 -1
- package/io/zip.js +1 -1
- package/lib/actions.js +68 -63
- package/lib/atoms/get-attribute.js +86 -0
- package/lib/atoms/is-displayed.js +76 -76
- package/lib/by.js +7 -4
- package/lib/capabilities.js +310 -210
- package/lib/command.js +27 -51
- package/lib/error.js +100 -41
- package/lib/http.js +161 -120
- package/lib/input.js +1044 -8
- package/lib/logging.js +1 -5
- package/lib/promise.js +222 -3331
- package/lib/proxy.js +134 -39
- package/lib/session.js +2 -2
- package/lib/symbols.js +0 -0
- package/lib/until.js +1 -1
- package/lib/webdriver.js +717 -953
- package/net/index.js +21 -25
- package/net/portprober.js +51 -68
- package/package.json +17 -12
- package/proxy.js +0 -0
- package/remote/index.js +63 -44
- package/safari.js +41 -128
- package/testing/index.js +386 -315
- package/.npmignore +0 -2
- package/example/async_await_test.js +0 -68
- package/example/google_search_generator.js +0 -50
- package/example/parallel_flows.js +0 -54
- package/firefox/binary.js +0 -344
- package/firefox/extension.js +0 -224
- package/firefox/index.js +0 -626
- package/firefox/profile.js +0 -394
- package/lib/README +0 -5
- package/lib/atoms/getAttribute.js +0 -9
- package/lib/devmode.js +0 -34
- package/lib/events.js +0 -210
- package/lib/firefox/webdriver.json +0 -70
- package/lib/test/build.js +0 -151
- package/lib/test/data/ClickTest_testClicksASurroundingStrongTag.html +0 -11
- package/lib/test/data/Page.aspx +0 -17
- package/lib/test/data/Page.aspx.cs +0 -22
- package/lib/test/data/Redirect.aspx +0 -11
- package/lib/test/data/Redirect.aspx.cs +0 -9
- package/lib/test/data/Settings.StyleCop +0 -759
- package/lib/test/data/Web.Config +0 -59
- package/lib/test/data/actualXhtmlPage.xhtml +0 -14
- package/lib/test/data/ajaxy_page.html +0 -81
- package/lib/test/data/alerts.html +0 -85
- package/lib/test/data/banner.gif +0 -0
- package/lib/test/data/beach.jpg +0 -0
- package/lib/test/data/blank.html +0 -1
- package/lib/test/data/bodyTypingTest.html +0 -41
- package/lib/test/data/booleanAttributes.html +0 -19
- package/lib/test/data/child/childPage.html +0 -8
- package/lib/test/data/child/grandchild/grandchildPage.html +0 -8
- package/lib/test/data/clickEventPage.html +0 -26
- package/lib/test/data/click_frames.html +0 -10
- package/lib/test/data/click_jacker.html +0 -38
- package/lib/test/data/click_out_of_bounds.html +0 -23
- package/lib/test/data/click_out_of_bounds_overflow.html +0 -85
- package/lib/test/data/click_rtl.html +0 -19
- package/lib/test/data/click_source.html +0 -18
- package/lib/test/data/click_tests/click_iframe.html +0 -6
- package/lib/test/data/click_tests/click_in_iframe.html +0 -8
- package/lib/test/data/click_tests/disabled_element.html +0 -12
- package/lib/test/data/click_tests/disappearing_element.html +0 -62
- package/lib/test/data/click_tests/google_map.html +0 -15
- package/lib/test/data/click_tests/google_map.png +0 -0
- package/lib/test/data/click_tests/html5_submit_buttons.html +0 -16
- package/lib/test/data/click_tests/issue5237.html +0 -9
- package/lib/test/data/click_tests/issue5237_frame.html +0 -1
- package/lib/test/data/click_tests/issue5237_target.html +0 -10
- package/lib/test/data/click_tests/link_that_wraps.html +0 -11
- package/lib/test/data/click_tests/mapped_page1.html +0 -9
- package/lib/test/data/click_tests/mapped_page2.html +0 -9
- package/lib/test/data/click_tests/mapped_page3.html +0 -9
- package/lib/test/data/click_tests/overlapping_elements.html +0 -70
- package/lib/test/data/click_tests/partially_overlapping_elements.html +0 -124
- package/lib/test/data/click_tests/span_that_wraps.html +0 -11
- package/lib/test/data/click_tests/submitted_page.html +0 -9
- package/lib/test/data/click_tests/wrapped_overlapping_elements.html +0 -13
- package/lib/test/data/click_too_big.html +0 -10
- package/lib/test/data/click_too_big_in_frame.html +0 -11
- package/lib/test/data/clicks.html +0 -35
- package/lib/test/data/closeable_window.html +0 -8
- package/lib/test/data/cn-test.html +0 -156
- package/lib/test/data/colorPage.html +0 -20
- package/lib/test/data/cookies.html +0 -30
- package/lib/test/data/coordinates_tests/element_in_frame.html +0 -9
- package/lib/test/data/coordinates_tests/element_in_nested_frame.html +0 -9
- package/lib/test/data/coordinates_tests/page_with_element_out_of_view.html +0 -11
- package/lib/test/data/coordinates_tests/page_with_empty_element.html +0 -10
- package/lib/test/data/coordinates_tests/page_with_fixed_element.html +0 -12
- package/lib/test/data/coordinates_tests/page_with_hidden_element.html +0 -10
- package/lib/test/data/coordinates_tests/page_with_invisible_element.html +0 -10
- package/lib/test/data/coordinates_tests/page_with_transparent_element.html +0 -10
- package/lib/test/data/coordinates_tests/simple_page.html +0 -10
- package/lib/test/data/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
- package/lib/test/data/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
- package/lib/test/data/css/ui-lightness/jquery-ui-1.8.10.custom.css +0 -573
- package/lib/test/data/cssTransform.html +0 -61
- package/lib/test/data/cssTransform2.html +0 -20
- package/lib/test/data/document_write_in_onload.html +0 -13
- package/lib/test/data/dragAndDropInsideScrolledDiv.html +0 -67
- package/lib/test/data/dragAndDropTest.html +0 -102
- package/lib/test/data/dragDropOverflow.html +0 -104
- package/lib/test/data/draggableLists.html +0 -67
- package/lib/test/data/droppableItems.html +0 -65
- package/lib/test/data/dynamic.html +0 -39
- package/lib/test/data/dynamicallyModifiedPage.html +0 -42
- package/lib/test/data/errors.html +0 -15
- package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
- package/lib/test/data/firefox/sample.xpi +0 -0
- package/lib/test/data/firefox/webextension.xpi +0 -0
- package/lib/test/data/fixedFooterNoScroll.html +0 -13
- package/lib/test/data/fixedFooterNoScrollQuirksMode.html +0 -12
- package/lib/test/data/formPage.html +0 -175
- package/lib/test/data/formSelectionPage.html +0 -46
- package/lib/test/data/form_handling_js_submit.html +0 -30
- package/lib/test/data/framePage3.html +0 -7
- package/lib/test/data/frameScrollChild.html +0 -26
- package/lib/test/data/frameScrollPage.html +0 -14
- package/lib/test/data/frameScrollParent.html +0 -11
- package/lib/test/data/frameWithAnimals.html +0 -11
- package/lib/test/data/frame_switching_tests/bug4876.html +0 -9
- package/lib/test/data/frame_switching_tests/bug4876_iframe.html +0 -9
- package/lib/test/data/frame_switching_tests/deletingFrame.html +0 -29
- package/lib/test/data/frame_switching_tests/deletingFrame_iframe.html +0 -8
- package/lib/test/data/frame_switching_tests/deletingFrame_iframe2.html +0 -7
- package/lib/test/data/frameset.html +0 -14
- package/lib/test/data/framesetPage2.html +0 -7
- package/lib/test/data/framesetPage3.html +0 -4
- package/lib/test/data/globalscope.html +0 -15
- package/lib/test/data/hidden.html +0 -5
- package/lib/test/data/hidden_partially.html +0 -45
- package/lib/test/data/html5/blue.jpg +0 -0
- package/lib/test/data/html5/database.js +0 -84
- package/lib/test/data/html5/geolocation.js +0 -18
- package/lib/test/data/html5/green.jpg +0 -0
- package/lib/test/data/html5/red.jpg +0 -0
- package/lib/test/data/html5/status.html +0 -1
- package/lib/test/data/html5/test.appcache +0 -11
- package/lib/test/data/html5/yellow.jpg +0 -0
- package/lib/test/data/html5Page.html +0 -32
- package/lib/test/data/icon.gif +0 -0
- package/lib/test/data/idElements.html +0 -2
- package/lib/test/data/iframeAtBottom.html +0 -15
- package/lib/test/data/iframeWithAlert.html +0 -1
- package/lib/test/data/iframeWithIframe.html +0 -1
- package/lib/test/data/iframes.html +0 -11
- package/lib/test/data/injectableContent.html +0 -22
- package/lib/test/data/javascriptEnhancedForm.html +0 -30
- package/lib/test/data/javascriptPage.html +0 -285
- package/lib/test/data/jquery-1.3.2.js +0 -4376
- package/lib/test/data/js/jquery-1.4.4.min.js +0 -167
- package/lib/test/data/js/jquery-ui-1.8.10.custom.min.js +0 -782
- package/lib/test/data/js/skins/lightgray/content.inline.min.css +0 -1
- package/lib/test/data/js/skins/lightgray/content.min.css +0 -1
- package/lib/test/data/js/skins/lightgray/fonts/readme.md +0 -1
- package/lib/test/data/js/skins/lightgray/fonts/tinymce-small.dev.svg +0 -175
- package/lib/test/data/js/skins/lightgray/fonts/tinymce-small.eot +0 -0
- package/lib/test/data/js/skins/lightgray/fonts/tinymce-small.svg +0 -62
- package/lib/test/data/js/skins/lightgray/fonts/tinymce-small.ttf +0 -0
- package/lib/test/data/js/skins/lightgray/fonts/tinymce-small.woff +0 -0
- package/lib/test/data/js/skins/lightgray/fonts/tinymce.dev.svg +0 -153
- package/lib/test/data/js/skins/lightgray/fonts/tinymce.eot +0 -0
- package/lib/test/data/js/skins/lightgray/fonts/tinymce.svg +0 -63
- package/lib/test/data/js/skins/lightgray/fonts/tinymce.ttf +0 -0
- package/lib/test/data/js/skins/lightgray/fonts/tinymce.woff +0 -0
- package/lib/test/data/js/skins/lightgray/img/anchor.gif +0 -0
- package/lib/test/data/js/skins/lightgray/img/loader.gif +0 -0
- package/lib/test/data/js/skins/lightgray/img/object.gif +0 -0
- package/lib/test/data/js/skins/lightgray/img/trans.gif +0 -0
- package/lib/test/data/js/skins/lightgray/skin.ie7.min.css +0 -1
- package/lib/test/data/js/skins/lightgray/skin.min.css +0 -1
- package/lib/test/data/js/themes/modern/theme.min.js +0 -1
- package/lib/test/data/js/tinymce.min.js +0 -10
- package/lib/test/data/key_logger.html +0 -34
- package/lib/test/data/key_tests/remove_on_keypress.html +0 -36
- package/lib/test/data/keyboard_shortcut.html +0 -36
- package/lib/test/data/linked_image.html +0 -16
- package/lib/test/data/locators_tests/boolean_attribute_selected.html +0 -13
- package/lib/test/data/locators_tests/boolean_attribute_selected_html4.html +0 -13
- package/lib/test/data/longContentPage.html +0 -55
- package/lib/test/data/macbeth.html +0 -5255
- package/lib/test/data/map.png +0 -0
- package/lib/test/data/map_visibility.html +0 -8
- package/lib/test/data/markerTransparent.png +0 -0
- package/lib/test/data/messages.html +0 -15
- package/lib/test/data/meta-redirect.html +0 -11
- package/lib/test/data/missedJsReference.html +0 -11
- package/lib/test/data/modal_dialogs/modal_1.html +0 -21
- package/lib/test/data/modal_dialogs/modal_2.html +0 -21
- package/lib/test/data/modal_dialogs/modal_3.html +0 -15
- package/lib/test/data/modal_dialogs/modalindex.html +0 -21
- package/lib/test/data/mouseOver.html +0 -17
- package/lib/test/data/mousePositionTracker.html +0 -33
- package/lib/test/data/nestedElements.html +0 -164
- package/lib/test/data/overflow/x_auto_y_auto.html +0 -30
- package/lib/test/data/overflow/x_auto_y_hidden.html +0 -30
- package/lib/test/data/overflow/x_auto_y_scroll.html +0 -30
- package/lib/test/data/overflow/x_hidden_y_auto.html +0 -30
- package/lib/test/data/overflow/x_hidden_y_hidden.html +0 -30
- package/lib/test/data/overflow/x_hidden_y_scroll.html +0 -30
- package/lib/test/data/overflow/x_scroll_y_auto.html +0 -30
- package/lib/test/data/overflow/x_scroll_y_hidden.html +0 -30
- package/lib/test/data/overflow/x_scroll_y_scroll.html +0 -30
- package/lib/test/data/overflow-body.html +0 -15
- package/lib/test/data/pageWithOnBeforeUnloadMessage.html +0 -20
- package/lib/test/data/pageWithOnLoad.html +0 -6
- package/lib/test/data/pageWithOnUnload.html +0 -6
- package/lib/test/data/page_with_link_to_slow_loading_page.html +0 -6
- package/lib/test/data/plain.txt +0 -1
- package/lib/test/data/proxy/page1.html +0 -20
- package/lib/test/data/proxy/page2.html +0 -24
- package/lib/test/data/proxy/page3.html +0 -5
- package/lib/test/data/readOnlyPage.html +0 -24
- package/lib/test/data/rectangles.html +0 -40
- package/lib/test/data/resultPage.html +0 -25
- package/lib/test/data/rich_text.html +0 -161
- package/lib/test/data/safari/frames_benchmark.html +0 -31
- package/lib/test/data/screen/screen.css +0 -19
- package/lib/test/data/screen/screen.html +0 -72
- package/lib/test/data/screen/screen.js +0 -7
- package/lib/test/data/screen/screen_frame1.html +0 -72
- package/lib/test/data/screen/screen_frame2.html +0 -72
- package/lib/test/data/screen/screen_frames.html +0 -11
- package/lib/test/data/screen/screen_iframes.html +0 -12
- package/lib/test/data/screen/screen_too_long.html +0 -68
- package/lib/test/data/screen/screen_x_long.html +0 -72
- package/lib/test/data/screen/screen_x_too_long.html +0 -72
- package/lib/test/data/screen/screen_y_long.html +0 -72
- package/lib/test/data/screen/screen_y_too_long.html +0 -72
- package/lib/test/data/scroll.html +0 -27
- package/lib/test/data/scroll2.html +0 -21
- package/lib/test/data/scroll3.html +0 -8
- package/lib/test/data/scroll4.html +0 -7
- package/lib/test/data/scroll5.html +0 -18
- package/lib/test/data/scrolling_tests/frame_with_height_above_200.html +0 -26
- package/lib/test/data/scrolling_tests/frame_with_height_above_2000.html +0 -26
- package/lib/test/data/scrolling_tests/frame_with_nested_scrolling_frame.html +0 -11
- package/lib/test/data/scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html +0 -12
- package/lib/test/data/scrolling_tests/frame_with_small_height.html +0 -10
- package/lib/test/data/scrolling_tests/page_with_double_overflow_auto.html +0 -19
- package/lib/test/data/scrolling_tests/page_with_frame_out_of_view.html +0 -12
- package/lib/test/data/scrolling_tests/page_with_nested_scrolling_frames.html +0 -11
- package/lib/test/data/scrolling_tests/page_with_nested_scrolling_frames_out_of_view.html +0 -12
- package/lib/test/data/scrolling_tests/page_with_non_scrolling_frame.html +0 -11
- package/lib/test/data/scrolling_tests/page_with_scrolling_frame.html +0 -11
- package/lib/test/data/scrolling_tests/page_with_scrolling_frame_out_of_view.html +0 -12
- package/lib/test/data/scrolling_tests/page_with_tall_frame.html +0 -11
- package/lib/test/data/scrolling_tests/page_with_y_overflow_auto.html +0 -14
- package/lib/test/data/scrolling_tests/target_page.html +0 -9
- package/lib/test/data/selectPage.html +0 -58
- package/lib/test/data/selectableItems.html +0 -65
- package/lib/test/data/sessionCookie.html +0 -21
- package/lib/test/data/sessionCookieDest.html +0 -34
- package/lib/test/data/simple.xml +0 -5
- package/lib/test/data/simpleTest.html +0 -98
- package/lib/test/data/single_text_input.html +0 -12
- package/lib/test/data/slowLoadingAlert.html +0 -10
- package/lib/test/data/slowLoadingResourcePage.html +0 -12
- package/lib/test/data/slow_loading_iframes.html +0 -14
- package/lib/test/data/styledPage.html +0 -28
- package/lib/test/data/svgPiechart.xhtml +0 -81
- package/lib/test/data/svgTest.svg +0 -4
- package/lib/test/data/tables.html +0 -36
- package/lib/test/data/tinymce.html +0 -10
- package/lib/test/data/transformable.xml +0 -11
- package/lib/test/data/transformable.xsl +0 -37
- package/lib/test/data/transparentUpload.html +0 -70
- package/lib/test/data/underscore.html +0 -9
- package/lib/test/data/unicode_ltr.html +0 -8
- package/lib/test/data/upload.html +0 -45
- package/lib/test/data/userDefinedProperty.html +0 -8
- package/lib/test/data/veryLargeCanvas.html +0 -81
- package/lib/test/data/visibility-css.html +0 -21
- package/lib/test/data/win32frameset.html +0 -8
- package/lib/test/data/window_switching_tests/page_with_frame.html +0 -12
- package/lib/test/data/window_switching_tests/simple_page.html +0 -9
- package/lib/test/data/xhtmlFormPage.xhtml +0 -17
- package/lib/test/data/xhtmlTest.html +0 -76
- package/lib/test/fileserver.js +0 -321
- package/lib/test/httpserver.js +0 -120
- package/lib/test/index.js +0 -270
- package/lib/test/promise.js +0 -79
- package/lib/test/resources.js +0 -44
- package/opera.js +0 -405
- package/phantomjs.js +0 -282
- package/test/actions_test.js +0 -52
- package/test/chrome/options_test.js +0 -227
- package/test/chrome/service_test.js +0 -45
- package/test/cookie_test.js +0 -214
- package/test/element_finding_test.js +0 -426
- package/test/execute_script_test.js +0 -350
- package/test/fingerprint_test.js +0 -62
- package/test/firefox/extension_test.js +0 -120
- package/test/firefox/firefox_test.js +0 -261
- package/test/firefox/profile_test.js +0 -140
- package/test/http/http_test.js +0 -223
- package/test/http/util_test.js +0 -178
- package/test/io/io_test.js +0 -360
- package/test/io/zip_test.js +0 -128
- package/test/lib/by_test.js +0 -160
- package/test/lib/capabilities_test.js +0 -111
- package/test/lib/error_test.js +0 -305
- package/test/lib/events_test.js +0 -177
- package/test/lib/http_test.js +0 -696
- package/test/lib/logging_test.js +0 -272
- package/test/lib/promise_aplus_test.js +0 -78
- package/test/lib/promise_error_test.js +0 -884
- package/test/lib/promise_flow_test.js +0 -2288
- package/test/lib/promise_generator_test.js +0 -310
- package/test/lib/promise_test.js +0 -1109
- package/test/lib/testutil.js +0 -90
- package/test/lib/until_test.js +0 -478
- package/test/lib/webdriver_test.js +0 -2311
- package/test/logging_test.js +0 -167
- package/test/net/index_test.js +0 -60
- package/test/net/portprober_test.js +0 -128
- package/test/page_loading_test.js +0 -166
- package/test/phantomjs/execute_phantomjs_test.js +0 -59
- package/test/proxy_test.js +0 -180
- package/test/rect_test.js +0 -60
- package/test/remote_test.js +0 -117
- package/test/safari_test.js +0 -108
- package/test/session_test.js +0 -99
- package/test/stale_element_test.js +0 -63
- package/test/tag_name_test.js +0 -36
- package/test/testing/assert_test.js +0 -373
- package/test/testing/index_test.js +0 -224
- package/test/upload_test.js +0 -86
- package/test/window_test.js +0 -161
- package/testing/assert.js +0 -378
package/chrome.js
CHANGED
|
@@ -39,8 +39,7 @@
|
|
|
39
39
|
* __Headless Chrome__ <a id="headless"></a>
|
|
40
40
|
*
|
|
41
41
|
* To start Chrome in headless mode, simply call
|
|
42
|
-
* {@linkplain Options#headless Options.headless()}.
|
|
43
|
-
* mode currently also disables GPU acceleration.
|
|
42
|
+
* {@linkplain Options#headless Options.headless()}.
|
|
44
43
|
*
|
|
45
44
|
* let chrome = require('selenium-webdriver/chrome');
|
|
46
45
|
* let {Builder} = require('selenium-webdriver');
|
|
@@ -133,8 +132,9 @@ const util = require('util');
|
|
|
133
132
|
|
|
134
133
|
const http = require('./http');
|
|
135
134
|
const io = require('./io');
|
|
136
|
-
const {Capabilities, Capability} = require('./lib/capabilities');
|
|
135
|
+
const {Browser, Capabilities, Capability} = require('./lib/capabilities');
|
|
137
136
|
const command = require('./lib/command');
|
|
137
|
+
const error = require('./lib/error');
|
|
138
138
|
const logging = require('./lib/logging');
|
|
139
139
|
const promise = require('./lib/promise');
|
|
140
140
|
const Symbols = require('./lib/symbols');
|
|
@@ -159,7 +159,8 @@ const CHROMEDRIVER_EXE =
|
|
|
159
159
|
const Command = {
|
|
160
160
|
LAUNCH_APP: 'launchApp',
|
|
161
161
|
GET_NETWORK_CONDITIONS: 'getNetworkConditions',
|
|
162
|
-
SET_NETWORK_CONDITIONS: 'setNetworkConditions'
|
|
162
|
+
SET_NETWORK_CONDITIONS: 'setNetworkConditions',
|
|
163
|
+
SEND_DEVTOOLS_COMMAND: 'sendDevToolsCommand',
|
|
163
164
|
};
|
|
164
165
|
|
|
165
166
|
|
|
@@ -169,7 +170,8 @@ const Command = {
|
|
|
169
170
|
* @return {!command.Executor} The new command executor.
|
|
170
171
|
*/
|
|
171
172
|
function createExecutor(url) {
|
|
172
|
-
let
|
|
173
|
+
let agent = new http.Agent({ keepAlive: true });
|
|
174
|
+
let client = url.then(url => new http.HttpClient(url, agent));
|
|
173
175
|
let executor = new http.Executor(client);
|
|
174
176
|
configureExecutor(executor);
|
|
175
177
|
return executor;
|
|
@@ -193,6 +195,21 @@ function configureExecutor(executor) {
|
|
|
193
195
|
Command.SET_NETWORK_CONDITIONS,
|
|
194
196
|
'POST',
|
|
195
197
|
'/session/:sessionId/chromium/network_conditions');
|
|
198
|
+
executor.defineCommand(
|
|
199
|
+
Command.SEND_DEVTOOLS_COMMAND,
|
|
200
|
+
'POST',
|
|
201
|
+
'/session/:sessionId/chromium/send_command');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* _Synchronously_ attempts to locate the chromedriver executable on the current
|
|
207
|
+
* system.
|
|
208
|
+
*
|
|
209
|
+
* @return {?string} the located executable, or `null`.
|
|
210
|
+
*/
|
|
211
|
+
function locateSynchronously() {
|
|
212
|
+
return io.findInPath(CHROMEDRIVER_EXE, true);
|
|
196
213
|
}
|
|
197
214
|
|
|
198
215
|
|
|
@@ -210,7 +227,7 @@ class ServiceBuilder extends remote.DriverService.Builder {
|
|
|
210
227
|
* cannot be found on the PATH.
|
|
211
228
|
*/
|
|
212
229
|
constructor(opt_exe) {
|
|
213
|
-
let exe = opt_exe ||
|
|
230
|
+
let exe = opt_exe || locateSynchronously();
|
|
214
231
|
if (!exe) {
|
|
215
232
|
throw Error(
|
|
216
233
|
'The ChromeDriver could not be found on the current PATH. Please ' +
|
|
@@ -307,64 +324,25 @@ function getDefaultService() {
|
|
|
307
324
|
}
|
|
308
325
|
|
|
309
326
|
|
|
310
|
-
const OPTIONS_CAPABILITY_KEY = 'chromeOptions';
|
|
327
|
+
const OPTIONS_CAPABILITY_KEY = 'goog:chromeOptions';
|
|
311
328
|
|
|
312
329
|
|
|
313
330
|
/**
|
|
314
331
|
* Class for managing ChromeDriver specific options.
|
|
315
332
|
*/
|
|
316
|
-
class Options {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
/** @private {?logging.Preferences} */
|
|
325
|
-
this.logPrefs_ = null;
|
|
326
|
-
|
|
327
|
-
/** @private {?./lib/capabilities.ProxyConfig} */
|
|
328
|
-
this.proxy_ = null;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Extracts the ChromeDriver specific options from the given capabilities
|
|
333
|
-
* object.
|
|
334
|
-
* @param {!Capabilities} caps The capabilities object.
|
|
335
|
-
* @return {!Options} The ChromeDriver options.
|
|
336
|
-
*/
|
|
337
|
-
static fromCapabilities(caps) {
|
|
338
|
-
let options = new Options();
|
|
339
|
-
|
|
340
|
-
let o = caps.get(OPTIONS_CAPABILITY_KEY);
|
|
341
|
-
if (o instanceof Options) {
|
|
342
|
-
options = o;
|
|
343
|
-
} else if (o) {
|
|
344
|
-
options.
|
|
345
|
-
addArguments(o.args || []).
|
|
346
|
-
addExtensions(o.extensions || []).
|
|
347
|
-
detachDriver(o.detach).
|
|
348
|
-
excludeSwitches(o.excludeSwitches || []).
|
|
349
|
-
setChromeBinaryPath(o.binary).
|
|
350
|
-
setChromeLogFile(o.logPath).
|
|
351
|
-
setChromeMinidumpPath(o.minidumpPath).
|
|
352
|
-
setLocalState(o.localState).
|
|
353
|
-
setMobileEmulation(o.mobileEmulation).
|
|
354
|
-
setUserPreferences(o.prefs).
|
|
355
|
-
setPerfLoggingPrefs(o.perfLoggingPrefs);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (caps.has(Capability.PROXY)) {
|
|
359
|
-
options.setProxy(caps.get(Capability.PROXY));
|
|
360
|
-
}
|
|
333
|
+
class Options extends Capabilities {
|
|
334
|
+
/**
|
|
335
|
+
* @param {(Capabilities|Map<string, ?>|Object)=} other Another set of
|
|
336
|
+
* capabilities to initialize this instance from.
|
|
337
|
+
*/
|
|
338
|
+
constructor(other = undefined) {
|
|
339
|
+
super(other);
|
|
361
340
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
caps.get(Capability.LOGGING_PREFS));
|
|
365
|
-
}
|
|
341
|
+
/** @private {!Object} */
|
|
342
|
+
this.options_ = this.get(OPTIONS_CAPABILITY_KEY) || {};
|
|
366
343
|
|
|
367
|
-
|
|
344
|
+
this.setBrowserName(Browser.CHROME);
|
|
345
|
+
this.set(OPTIONS_CAPABILITY_KEY, this.options_);
|
|
368
346
|
}
|
|
369
347
|
|
|
370
348
|
/**
|
|
@@ -391,12 +369,16 @@ class Options {
|
|
|
391
369
|
* > in Chrome 60. Users are encouraged to set an initial window size with
|
|
392
370
|
* > the {@link #windowSize windowSize({width, height})} option.
|
|
393
371
|
*
|
|
372
|
+
* > __NOTE__: For security, Chrome disables downloads by default when
|
|
373
|
+
* > in headless mode (to prevent sites from silently downloading files to
|
|
374
|
+
* > your machine). After creating a session, you may call
|
|
375
|
+
* > {@link ./chrome.Driver#setDownloadPath setDownloadPath} to re-enable
|
|
376
|
+
* > downloads, saving files in the specified directory.
|
|
377
|
+
*
|
|
394
378
|
* @return {!Options} A self reference.
|
|
395
379
|
*/
|
|
396
380
|
headless() {
|
|
397
|
-
|
|
398
|
-
// that to be set.
|
|
399
|
-
return this.addArguments('headless', 'disable-gpu');
|
|
381
|
+
return this.addArguments('headless');
|
|
400
382
|
}
|
|
401
383
|
|
|
402
384
|
/**
|
|
@@ -442,7 +424,8 @@ class Options {
|
|
|
442
424
|
* @return {!Options} A self reference.
|
|
443
425
|
*/
|
|
444
426
|
addExtensions(...args) {
|
|
445
|
-
|
|
427
|
+
let current = this.options_.extensions || [];
|
|
428
|
+
this.options_.extensions = current.concat(...args);
|
|
446
429
|
return this;
|
|
447
430
|
}
|
|
448
431
|
|
|
@@ -486,16 +469,6 @@ class Options {
|
|
|
486
469
|
return this;
|
|
487
470
|
}
|
|
488
471
|
|
|
489
|
-
/**
|
|
490
|
-
* Sets the logging preferences for the new session.
|
|
491
|
-
* @param {!logging.Preferences} prefs The logging preferences.
|
|
492
|
-
* @return {!Options} A self reference.
|
|
493
|
-
*/
|
|
494
|
-
setLoggingPrefs(prefs) {
|
|
495
|
-
this.logPrefs_ = prefs;
|
|
496
|
-
return this;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
472
|
/**
|
|
500
473
|
* Sets the performance logging preferences. Options include:
|
|
501
474
|
*
|
|
@@ -673,54 +646,25 @@ class Options {
|
|
|
673
646
|
return this;
|
|
674
647
|
}
|
|
675
648
|
|
|
676
|
-
/**
|
|
677
|
-
* Sets the proxy settings for the new session.
|
|
678
|
-
* @param {./lib/capabilities.ProxyConfig} proxy The proxy configuration to
|
|
679
|
-
* use.
|
|
680
|
-
* @return {!Options} A self reference.
|
|
681
|
-
*/
|
|
682
|
-
setProxy(proxy) {
|
|
683
|
-
this.proxy_ = proxy;
|
|
684
|
-
return this;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* Converts this options instance to a {@link Capabilities} object.
|
|
689
|
-
* @param {Capabilities=} opt_capabilities The capabilities to merge
|
|
690
|
-
* these options into, if any.
|
|
691
|
-
* @return {!Capabilities} The capabilities.
|
|
692
|
-
*/
|
|
693
|
-
toCapabilities(opt_capabilities) {
|
|
694
|
-
let caps = opt_capabilities || Capabilities.chrome();
|
|
695
|
-
caps.
|
|
696
|
-
set(Capability.PROXY, this.proxy_).
|
|
697
|
-
set(Capability.LOGGING_PREFS, this.logPrefs_).
|
|
698
|
-
set(OPTIONS_CAPABILITY_KEY, this);
|
|
699
|
-
return caps;
|
|
700
|
-
}
|
|
701
|
-
|
|
702
649
|
/**
|
|
703
650
|
* Converts this instance to its JSON wire protocol representation. Note this
|
|
704
651
|
* function is an implementation not intended for general use.
|
|
652
|
+
*
|
|
705
653
|
* @return {!Object} The JSON wire protocol representation of this instance.
|
|
654
|
+
* @suppress {checkTypes} Suppress [] access on a struct.
|
|
706
655
|
*/
|
|
707
656
|
[Symbols.serialize]() {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
return extension.toString('base64');
|
|
718
|
-
}
|
|
719
|
-
return io.read(/** @type {string} */(extension))
|
|
720
|
-
.then(buffer => buffer.toString('base64'));
|
|
721
|
-
});
|
|
657
|
+
if (this.options_.extensions && this.options_.extensions.length) {
|
|
658
|
+
this.options_.extensions =
|
|
659
|
+
this.options_.extensions.map(function(extension) {
|
|
660
|
+
if (Buffer.isBuffer(extension)) {
|
|
661
|
+
return extension.toString('base64');
|
|
662
|
+
}
|
|
663
|
+
return io.read(/** @type {string} */(extension))
|
|
664
|
+
.then(buffer => buffer.toString('base64'));
|
|
665
|
+
});
|
|
722
666
|
}
|
|
723
|
-
return
|
|
667
|
+
return super[Symbols.serialize]();
|
|
724
668
|
}
|
|
725
669
|
}
|
|
726
670
|
|
|
@@ -739,11 +683,9 @@ class Driver extends webdriver.WebDriver {
|
|
|
739
683
|
* for an externally managed endpoint. If neither is provided, the
|
|
740
684
|
* {@linkplain ##getDefaultService default service} will be used by
|
|
741
685
|
* default.
|
|
742
|
-
* @param {promise.ControlFlow=} opt_flow The control flow to use, or `null`
|
|
743
|
-
* to use the currently active flow.
|
|
744
686
|
* @return {!Driver} A new driver instance.
|
|
745
687
|
*/
|
|
746
|
-
static createSession(opt_config, opt_serviceExecutor
|
|
688
|
+
static createSession(opt_config, opt_serviceExecutor) {
|
|
747
689
|
let executor;
|
|
748
690
|
if (opt_serviceExecutor instanceof http.Executor) {
|
|
749
691
|
executor = opt_serviceExecutor;
|
|
@@ -753,12 +695,19 @@ class Driver extends webdriver.WebDriver {
|
|
|
753
695
|
executor = createExecutor(service.start());
|
|
754
696
|
}
|
|
755
697
|
|
|
756
|
-
let caps =
|
|
757
|
-
|
|
758
|
-
|
|
698
|
+
let caps = opt_config || Capabilities.chrome();
|
|
699
|
+
|
|
700
|
+
// W3C spec requires noProxy value to be an array of strings, but Chrome
|
|
701
|
+
// expects a single host as a string.
|
|
702
|
+
let proxy = caps.get(Capability.PROXY);
|
|
703
|
+
if (proxy && Array.isArray(proxy.noProxy)) {
|
|
704
|
+
proxy.noProxy = proxy.noProxy[0];
|
|
705
|
+
if (!proxy.noProxy) {
|
|
706
|
+
proxy.noProxy = undefined;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
759
709
|
|
|
760
|
-
return /** @type {!Driver} */(
|
|
761
|
-
super.createSession(executor, caps, opt_flow));
|
|
710
|
+
return /** @type {!Driver} */(super.createSession(executor, caps));
|
|
762
711
|
}
|
|
763
712
|
|
|
764
713
|
/**
|
|
@@ -771,24 +720,21 @@ class Driver extends webdriver.WebDriver {
|
|
|
771
720
|
/**
|
|
772
721
|
* Schedules a command to launch Chrome App with given ID.
|
|
773
722
|
* @param {string} id ID of the App to launch.
|
|
774
|
-
* @return {!
|
|
723
|
+
* @return {!Promise<void>} A promise that will be resolved
|
|
775
724
|
* when app is launched.
|
|
776
725
|
*/
|
|
777
726
|
launchApp(id) {
|
|
778
|
-
return this.
|
|
779
|
-
new command.Command(Command.LAUNCH_APP).setParameter('id', id)
|
|
780
|
-
'Driver.launchApp()');
|
|
727
|
+
return this.execute(
|
|
728
|
+
new command.Command(Command.LAUNCH_APP).setParameter('id', id));
|
|
781
729
|
}
|
|
782
730
|
|
|
783
731
|
/**
|
|
784
732
|
* Schedules a command to get Chrome network emulation settings.
|
|
785
|
-
* @return {!
|
|
786
|
-
*
|
|
733
|
+
* @return {!Promise} A promise that will be resolved when network
|
|
734
|
+
* emulation settings are retrievied.
|
|
787
735
|
*/
|
|
788
736
|
getNetworkConditions() {
|
|
789
|
-
return this.
|
|
790
|
-
new command.Command(Command.GET_NETWORK_CONDITIONS),
|
|
791
|
-
'Driver.getNetworkConditions()');
|
|
737
|
+
return this.execute(new command.Command(Command.GET_NETWORK_CONDITIONS));
|
|
792
738
|
}
|
|
793
739
|
|
|
794
740
|
/**
|
|
@@ -804,17 +750,54 @@ class Driver extends webdriver.WebDriver {
|
|
|
804
750
|
* });
|
|
805
751
|
*
|
|
806
752
|
* @param {Object} spec Defines the network conditions to set
|
|
807
|
-
* @return {!
|
|
808
|
-
*
|
|
753
|
+
* @return {!Promise<void>} A promise that will be resolved when network
|
|
754
|
+
* emulation settings are set.
|
|
809
755
|
*/
|
|
810
756
|
setNetworkConditions(spec) {
|
|
811
757
|
if (!spec || typeof spec !== 'object') {
|
|
812
758
|
throw TypeError('setNetworkConditions called with non-network-conditions parameter');
|
|
813
759
|
}
|
|
760
|
+
return this.execute(
|
|
761
|
+
new command.Command(Command.SET_NETWORK_CONDITIONS)
|
|
762
|
+
.setParameter('network_conditions', spec));
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Sends an arbitrary devtools command to the browser.
|
|
767
|
+
*
|
|
768
|
+
* @param {string} cmd The name of the command to send.
|
|
769
|
+
* @param {Object=} params The command parameters.
|
|
770
|
+
* @return {!Promise<void>} A promise that will be resolved when the command
|
|
771
|
+
* has finished.
|
|
772
|
+
* @see <https://chromedevtools.github.io/devtools-protocol/>
|
|
773
|
+
*/
|
|
774
|
+
sendDevToolsCommand(cmd, params = {}) {
|
|
775
|
+
return this.execute(
|
|
776
|
+
new command.Command(Command.SEND_DEVTOOLS_COMMAND)
|
|
777
|
+
.setParameter('cmd', cmd)
|
|
778
|
+
.setParameter('params', params));
|
|
779
|
+
}
|
|
814
780
|
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
781
|
+
/**
|
|
782
|
+
* Sends a DevTools command to change Chrome's download directory.
|
|
783
|
+
*
|
|
784
|
+
* @param {string} path The desired download directory.
|
|
785
|
+
* @return {!Promise<void>} A promise that will be resolved when the command
|
|
786
|
+
* has finished.
|
|
787
|
+
* @see #sendDevToolsCommand
|
|
788
|
+
*/
|
|
789
|
+
async setDownloadPath(path) {
|
|
790
|
+
if (!path || typeof path !== 'string') {
|
|
791
|
+
throw new error.InvalidArgumentError('invalid download path');
|
|
792
|
+
}
|
|
793
|
+
const stat = await io.stat(path);
|
|
794
|
+
if (!stat.isDirectory()) {
|
|
795
|
+
throw new error.InvalidArgumentError('not a directory: ' + path);
|
|
796
|
+
}
|
|
797
|
+
return this.sendDevToolsCommand('Page.setDownloadBehavior', {
|
|
798
|
+
'behavior': 'allow',
|
|
799
|
+
'downloadPath': path
|
|
800
|
+
});
|
|
818
801
|
}
|
|
819
802
|
}
|
|
820
803
|
|
|
@@ -827,3 +810,4 @@ exports.Options = Options;
|
|
|
827
810
|
exports.ServiceBuilder = ServiceBuilder;
|
|
828
811
|
exports.getDefaultService = getDefaultService;
|
|
829
812
|
exports.setDefaultService = setDefaultService;
|
|
813
|
+
exports.locateSynchronously = locateSynchronously;
|
package/edge.js
CHANGED
|
@@ -70,121 +70,44 @@
|
|
|
70
70
|
|
|
71
71
|
'use strict';
|
|
72
72
|
|
|
73
|
-
const fs = require('fs')
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const http = require('./http')
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
const fs = require('fs');
|
|
74
|
+
const util = require('util');
|
|
75
|
+
|
|
76
|
+
const http = require('./http');
|
|
77
|
+
const io = require('./io');
|
|
78
|
+
const portprober = require('./net/portprober');
|
|
79
|
+
const promise = require('./lib/promise');
|
|
80
|
+
const remote = require('./remote');
|
|
81
|
+
const Symbols = require('./lib/symbols');
|
|
82
|
+
const webdriver = require('./lib/webdriver');
|
|
83
|
+
const {Browser, Capabilities} = require('./lib/capabilities');
|
|
84
84
|
|
|
85
85
|
const EDGEDRIVER_EXE = 'MicrosoftWebDriver.exe';
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
89
|
+
* _Synchronously_ attempts to locate the edge driver executable on the current
|
|
90
|
+
* system.
|
|
91
|
+
*
|
|
92
|
+
* @return {?string} the located executable, or `null`.
|
|
91
93
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
function locateSynchronously() {
|
|
95
|
+
return process.platform === 'win32'
|
|
96
|
+
? io.findInPath(EDGEDRIVER_EXE, true) : null;
|
|
97
|
+
}
|
|
95
98
|
|
|
96
99
|
|
|
97
100
|
/**
|
|
98
101
|
* Class for managing MicrosoftEdgeDriver specific options.
|
|
99
102
|
*/
|
|
100
|
-
class Options {
|
|
101
|
-
constructor() {
|
|
102
|
-
/** @private {!Object} */
|
|
103
|
-
this.options_ = {};
|
|
104
|
-
|
|
105
|
-
/** @private {?capabilities.ProxyConfig} */
|
|
106
|
-
this.proxy_ = null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Extracts the MicrosoftEdgeDriver specific options from the given
|
|
111
|
-
* capabilities object.
|
|
112
|
-
* @param {!capabilities.Capabilities} caps The capabilities object.
|
|
113
|
-
* @return {!Options} The MicrosoftEdgeDriver options.
|
|
114
|
-
*/
|
|
115
|
-
static fromCapabilities(caps) {
|
|
116
|
-
var options = new Options();
|
|
117
|
-
var map = options.options_;
|
|
118
|
-
|
|
119
|
-
Object.keys(CAPABILITY_KEY).forEach(function(key) {
|
|
120
|
-
key = CAPABILITY_KEY[key];
|
|
121
|
-
if (caps.has(key)) {
|
|
122
|
-
map[key] = caps.get(key);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
if (caps.has(capabilities.Capability.PROXY)) {
|
|
127
|
-
options.setProxy(caps.get(capabilities.Capability.PROXY));
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return options;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Sets the proxy settings for the new session.
|
|
135
|
-
* @param {capabilities.ProxyConfig} proxy The proxy configuration to use.
|
|
136
|
-
* @return {!Options} A self reference.
|
|
137
|
-
*/
|
|
138
|
-
setProxy(proxy) {
|
|
139
|
-
this.proxy_ = proxy;
|
|
140
|
-
return this;
|
|
141
|
-
}
|
|
142
|
-
|
|
103
|
+
class Options extends Capabilities {
|
|
143
104
|
/**
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* @param {string} pageLoadStrategy The page load strategy to use.
|
|
148
|
-
* @return {!Options} A self reference.
|
|
105
|
+
* @param {(Capabilities|Map<string, ?>|Object)=} other Another set of
|
|
106
|
+
* capabilities to initialize this instance from.
|
|
149
107
|
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return this;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Converts this options instance to a {@link capabilities.Capabilities}
|
|
158
|
-
* object.
|
|
159
|
-
* @param {capabilities.Capabilities=} opt_capabilities The capabilities to
|
|
160
|
-
* merge these options into, if any.
|
|
161
|
-
* @return {!capabilities.Capabilities} The capabilities.
|
|
162
|
-
*/
|
|
163
|
-
toCapabilities(opt_capabilities) {
|
|
164
|
-
var caps = opt_capabilities || capabilities.Capabilities.edge();
|
|
165
|
-
if (this.proxy_) {
|
|
166
|
-
caps.set(capabilities.Capability.PROXY, this.proxy_);
|
|
167
|
-
}
|
|
168
|
-
Object.keys(this.options_).forEach(function(key) {
|
|
169
|
-
caps.set(key, this.options_[key]);
|
|
170
|
-
}, this);
|
|
171
|
-
return caps;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Converts this instance to its JSON wire protocol representation. Note this
|
|
176
|
-
* function is an implementation not intended for general use.
|
|
177
|
-
* @return {{pageLoadStrategy: (string|undefined)}}
|
|
178
|
-
* The JSON wire protocol representation of this instance.
|
|
179
|
-
*/
|
|
180
|
-
[Symbols.serialize]() {
|
|
181
|
-
var json = {};
|
|
182
|
-
for (var key in this.options_) {
|
|
183
|
-
if (this.options_[key] != null) {
|
|
184
|
-
json[key] = this.options_[key];
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return json;
|
|
108
|
+
constructor(other = undefined) {
|
|
109
|
+
super(other);
|
|
110
|
+
this.setBrowserName(Browser.EDGE);
|
|
188
111
|
}
|
|
189
112
|
}
|
|
190
113
|
|
|
@@ -202,7 +125,7 @@ class ServiceBuilder extends remote.DriverService.Builder {
|
|
|
202
125
|
* MicrosoftEdgeDriver cannot be found on the PATH.
|
|
203
126
|
*/
|
|
204
127
|
constructor(opt_exe) {
|
|
205
|
-
let exe = opt_exe ||
|
|
128
|
+
let exe = opt_exe || locateSynchronously();
|
|
206
129
|
if (!exe) {
|
|
207
130
|
throw Error(
|
|
208
131
|
'The ' + EDGEDRIVER_EXE + ' could not be found on the current PATH. ' +
|
|
@@ -218,6 +141,14 @@ class ServiceBuilder extends remote.DriverService.Builder {
|
|
|
218
141
|
// (or can we?), force the DriverService to use "localhost".
|
|
219
142
|
this.setHostname('localhost');
|
|
220
143
|
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Enables verbose logging.
|
|
147
|
+
* @return {!ServiceBuilder} A self reference.
|
|
148
|
+
*/
|
|
149
|
+
enableVerboseLogging() {
|
|
150
|
+
return this.addArguments('--verbose');
|
|
151
|
+
}
|
|
221
152
|
}
|
|
222
153
|
|
|
223
154
|
|
|
@@ -261,25 +192,19 @@ class Driver extends webdriver.WebDriver {
|
|
|
261
192
|
/**
|
|
262
193
|
* Creates a new browser session for Microsoft's Edge browser.
|
|
263
194
|
*
|
|
264
|
-
* @param {(
|
|
265
|
-
*
|
|
266
|
-
* @param {remote.DriverService=} opt_service The session to use; will use
|
|
195
|
+
* @param {(Capabilities|Options)=} options The configuration options.
|
|
196
|
+
* @param {remote.DriverService=} service The session to use; will use
|
|
267
197
|
* the {@linkplain #getDefaultService default service} by default.
|
|
268
|
-
* @param {promise.ControlFlow=} opt_flow The control flow to use, or
|
|
269
|
-
* {@code null} to use the currently active flow.
|
|
270
198
|
* @return {!Driver} A new driver instance.
|
|
271
199
|
*/
|
|
272
|
-
static createSession(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
var caps =
|
|
278
|
-
opt_config instanceof Options ? opt_config.toCapabilities() :
|
|
279
|
-
(opt_config || capabilities.Capabilities.edge());
|
|
200
|
+
static createSession(options, opt_service) {
|
|
201
|
+
let service = opt_service || getDefaultService();
|
|
202
|
+
let client = service.start().then(url => new http.HttpClient(url));
|
|
203
|
+
let executor = new http.Executor(client);
|
|
280
204
|
|
|
205
|
+
options = options || new Options();
|
|
281
206
|
return /** @type {!Driver} */(super.createSession(
|
|
282
|
-
executor,
|
|
207
|
+
executor, options, () => service.kill()));
|
|
283
208
|
}
|
|
284
209
|
|
|
285
210
|
/**
|
|
@@ -299,3 +224,4 @@ exports.Options = Options;
|
|
|
299
224
|
exports.ServiceBuilder = ServiceBuilder;
|
|
300
225
|
exports.getDefaultService = getDefaultService;
|
|
301
226
|
exports.setDefaultService = setDefaultService;
|
|
227
|
+
exports.locateSynchronously = locateSynchronously;
|
|
@@ -23,21 +23,20 @@
|
|
|
23
23
|
|
|
24
24
|
'use strict';
|
|
25
25
|
|
|
26
|
-
const {Builder, By,
|
|
26
|
+
const {Builder, By, Key, until} = require('..');
|
|
27
27
|
const {Options} = require('../chrome');
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
(async function() {
|
|
30
30
|
let driver;
|
|
31
31
|
try {
|
|
32
|
-
driver =
|
|
32
|
+
driver = await new Builder()
|
|
33
33
|
.forBrowser('chrome')
|
|
34
34
|
.setChromeOptions(new Options().androidChrome())
|
|
35
35
|
.build();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
yield driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
36
|
+
await driver.get('http://www.google.com/ncr');
|
|
37
|
+
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
38
|
+
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
40
39
|
} finally {
|
|
41
|
-
|
|
40
|
+
await driver && driver.quit();
|
|
42
41
|
}
|
|
43
|
-
}).then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
|
|
42
|
+
})().then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
|
|
@@ -22,22 +22,21 @@
|
|
|
22
22
|
|
|
23
23
|
'use strict';
|
|
24
24
|
|
|
25
|
-
const {Builder, By,
|
|
25
|
+
const {Builder, By, Key, until} = require('..');
|
|
26
26
|
const {Options} = require('../chrome');
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
(async function() {
|
|
29
29
|
let driver;
|
|
30
30
|
try {
|
|
31
|
-
driver =
|
|
31
|
+
driver = await new Builder()
|
|
32
32
|
.forBrowser('chrome')
|
|
33
33
|
.setChromeOptions(
|
|
34
34
|
new Options().setMobileEmulation({deviceName: 'Nexus 5X'}))
|
|
35
35
|
.build();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
yield driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
36
|
+
await driver.get('http://www.google.com/ncr');
|
|
37
|
+
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
|
|
38
|
+
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
|
|
40
39
|
} finally {
|
|
41
|
-
|
|
40
|
+
await driver && driver.quit();
|
|
42
41
|
}
|
|
43
|
-
}).then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
|
|
42
|
+
})().then(_ => console.log('SUCCESS'), err => console.error('ERROR: ' + err));
|