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/test/lib/testutil.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
const assert = require('assert');
|
|
21
|
-
const sinon = require('sinon');
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class StubError extends Error {
|
|
25
|
-
constructor(opt_msg) {
|
|
26
|
-
super(opt_msg);
|
|
27
|
-
this.name = this.constructor.name;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.StubError = StubError;
|
|
31
|
-
|
|
32
|
-
exports.throwStubError = function() {
|
|
33
|
-
throw new StubError;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.assertIsStubError = function(value) {
|
|
37
|
-
assert.ok(value instanceof StubError, value + ' is not a ' + StubError.name);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
exports.assertIsInstance = function(ctor, value) {
|
|
41
|
-
assert.ok(value instanceof ctor, 'Not a ' + ctor.name + ': ' + value);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function callbackPair(cb, eb) {
|
|
45
|
-
if (cb && eb) {
|
|
46
|
-
throw new TypeError('can only specify one of callback or errback');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let callback = cb ? sinon.spy(cb) : sinon.spy();
|
|
50
|
-
let errback = eb ? sinon.spy(eb) : sinon.spy();
|
|
51
|
-
|
|
52
|
-
function assertCallback() {
|
|
53
|
-
assert.ok(callback.called, 'callback not called');
|
|
54
|
-
assert.ok(!errback.called, 'errback called');
|
|
55
|
-
if (callback.threw()) {
|
|
56
|
-
throw callback.exceptions[0];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function assertErrback() {
|
|
61
|
-
assert.ok(!callback.called, 'callback called');
|
|
62
|
-
assert.ok(errback.called, 'errback not called');
|
|
63
|
-
if (errback.threw()) {
|
|
64
|
-
throw errback.exceptions[0];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function assertNeither() {
|
|
69
|
-
assert.ok(!callback.called, 'callback called');
|
|
70
|
-
assert.ok(!errback.called, 'errback called');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
callback,
|
|
75
|
-
errback,
|
|
76
|
-
assertCallback,
|
|
77
|
-
assertErrback,
|
|
78
|
-
assertNeither
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
exports.callbackPair = callbackPair;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
exports.callbackHelper = function(cb) {
|
|
85
|
-
let pair = callbackPair(cb);
|
|
86
|
-
let wrapped = pair.callback.bind(null);
|
|
87
|
-
wrapped.assertCalled = () => pair.assertCallback();
|
|
88
|
-
wrapped.assertNotCalled = () => pair.assertNeither();
|
|
89
|
-
return wrapped;
|
|
90
|
-
};
|
package/test/lib/until_test.js
DELETED
|
@@ -1,478 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
const assert = require('assert');
|
|
21
|
-
|
|
22
|
-
const By = require('../../lib/by').By;
|
|
23
|
-
const CommandName = require('../../lib/command').Name;
|
|
24
|
-
const error = require('../../lib/error');
|
|
25
|
-
const promise = require('../../lib/promise');
|
|
26
|
-
const until = require('../../lib/until');
|
|
27
|
-
const webdriver = require('../../lib/webdriver'),
|
|
28
|
-
WebElement = webdriver.WebElement;
|
|
29
|
-
|
|
30
|
-
describe('until', function() {
|
|
31
|
-
let driver, executor;
|
|
32
|
-
|
|
33
|
-
class TestExecutor {
|
|
34
|
-
constructor() {
|
|
35
|
-
this.handlers_ = {};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
on(cmd, handler) {
|
|
39
|
-
this.handlers_[cmd] = handler;
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
execute(cmd) {
|
|
44
|
-
let self = this;
|
|
45
|
-
return Promise.resolve().then(function() {
|
|
46
|
-
if (!self.handlers_[cmd.getName()]) {
|
|
47
|
-
throw new error.UnknownCommandError(cmd.getName());
|
|
48
|
-
}
|
|
49
|
-
return self.handlers_[cmd.getName()](cmd);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function fail(opt_msg) {
|
|
55
|
-
throw new assert.AssertionError({message: opt_msg});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
beforeEach(function setUp() {
|
|
59
|
-
executor = new TestExecutor();
|
|
60
|
-
driver = new webdriver.WebDriver('session-id', executor);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('ableToSwitchToFrame', function() {
|
|
64
|
-
it('failsFastForNonSwitchErrors', function() {
|
|
65
|
-
let e = Error('boom');
|
|
66
|
-
executor.on(CommandName.SWITCH_TO_FRAME, function() {
|
|
67
|
-
throw e;
|
|
68
|
-
});
|
|
69
|
-
return driver.wait(until.ableToSwitchToFrame(0), 100)
|
|
70
|
-
.then(fail, (e2) => assert.strictEqual(e2, e));
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const ELEMENT_ID = 'some-element-id';
|
|
74
|
-
const ELEMENT_INDEX = 1234;
|
|
75
|
-
|
|
76
|
-
function onSwitchFrame(expectedId) {
|
|
77
|
-
if (typeof expectedId === 'string') {
|
|
78
|
-
expectedId = WebElement.buildId(expectedId);
|
|
79
|
-
} else {
|
|
80
|
-
assert.equal(typeof expectedId, 'number', 'must be string or number');
|
|
81
|
-
}
|
|
82
|
-
return cmd => {
|
|
83
|
-
assert.deepEqual(
|
|
84
|
-
cmd.getParameter('id'), expectedId, 'frame ID not specified');
|
|
85
|
-
return true;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
it('byIndex', function() {
|
|
90
|
-
executor.on(CommandName.SWITCH_TO_FRAME, onSwitchFrame(ELEMENT_INDEX));
|
|
91
|
-
return driver.wait(until.ableToSwitchToFrame(ELEMENT_INDEX), 100);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('byWebElement', function() {
|
|
95
|
-
executor.on(CommandName.SWITCH_TO_FRAME, onSwitchFrame(ELEMENT_ID));
|
|
96
|
-
|
|
97
|
-
var el = new webdriver.WebElement(driver, ELEMENT_ID);
|
|
98
|
-
return driver.wait(until.ableToSwitchToFrame(el), 100);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('byWebElementPromise', function() {
|
|
102
|
-
executor.on(CommandName.SWITCH_TO_FRAME, onSwitchFrame(ELEMENT_ID));
|
|
103
|
-
var el = new webdriver.WebElementPromise(driver,
|
|
104
|
-
Promise.resolve(new webdriver.WebElement(driver, ELEMENT_ID)));
|
|
105
|
-
return driver.wait(until.ableToSwitchToFrame(el), 100);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('byLocator', function() {
|
|
109
|
-
executor.on(CommandName.FIND_ELEMENTS, () => [WebElement.buildId(ELEMENT_ID)]);
|
|
110
|
-
executor.on(CommandName.SWITCH_TO_FRAME, onSwitchFrame(ELEMENT_ID));
|
|
111
|
-
return driver.wait(until.ableToSwitchToFrame(By.id('foo')), 100);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('byLocator_elementNotInitiallyFound', function() {
|
|
115
|
-
let foundResponses = [[], [], [WebElement.buildId(ELEMENT_ID)]];
|
|
116
|
-
executor.on(CommandName.FIND_ELEMENTS, () => foundResponses.shift());
|
|
117
|
-
executor.on(CommandName.SWITCH_TO_FRAME, onSwitchFrame(ELEMENT_ID));
|
|
118
|
-
|
|
119
|
-
return driver.wait(until.ableToSwitchToFrame(By.id('foo')), 2000)
|
|
120
|
-
.then(() => assert.deepEqual(foundResponses, []));
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('timesOutIfNeverAbletoSwitchFrames', function() {
|
|
124
|
-
var count = 0;
|
|
125
|
-
executor.on(CommandName.SWITCH_TO_FRAME, function() {
|
|
126
|
-
count += 1;
|
|
127
|
-
throw new error.NoSuchFrameError;
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
return driver.wait(until.ableToSwitchToFrame(0), 100)
|
|
131
|
-
.then(fail, function(e) {
|
|
132
|
-
assert.ok(count > 0);
|
|
133
|
-
assert.ok(
|
|
134
|
-
e.message.startsWith('Waiting to be able to switch to frame'),
|
|
135
|
-
'Wrong message: ' + e.message);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
describe('alertIsPresent', function() {
|
|
141
|
-
it('failsFastForNonAlertSwitchErrors', function() {
|
|
142
|
-
return driver.wait(until.alertIsPresent(), 100).then(fail, function(e) {
|
|
143
|
-
assert.ok(e instanceof error.UnknownCommandError);
|
|
144
|
-
assert.equal(e.message, CommandName.GET_ALERT_TEXT);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('waitsForAlert', function() {
|
|
149
|
-
var count = 0;
|
|
150
|
-
executor.on(CommandName.GET_ALERT_TEXT, function() {
|
|
151
|
-
if (count++ < 3) {
|
|
152
|
-
throw new error.NoSuchAlertError;
|
|
153
|
-
} else {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
}).on(CommandName.DISMISS_ALERT, () => true);
|
|
157
|
-
|
|
158
|
-
return driver.wait(until.alertIsPresent(), 1000).then(function(alert) {
|
|
159
|
-
assert.equal(count, 4);
|
|
160
|
-
return alert.dismiss();
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// TODO: Remove once GeckoDriver doesn't throw this unwanted error.
|
|
165
|
-
// See https://github.com/SeleniumHQ/selenium/pull/2137
|
|
166
|
-
describe('workaround for GeckoDriver', function() {
|
|
167
|
-
it('doesNotFailWhenCannotConvertNullToObject', function() {
|
|
168
|
-
var count = 0;
|
|
169
|
-
executor.on(CommandName.GET_ALERT_TEXT, function() {
|
|
170
|
-
if (count++ < 3) {
|
|
171
|
-
throw new error.WebDriverError(`can't convert null to object`);
|
|
172
|
-
} else {
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
}).on(CommandName.DISMISS_ALERT, () => true);
|
|
176
|
-
|
|
177
|
-
return driver.wait(until.alertIsPresent(), 1000).then(function(alert) {
|
|
178
|
-
assert.equal(count, 4);
|
|
179
|
-
return alert.dismiss();
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('keepsRaisingRegularWebdriverError', function() {
|
|
184
|
-
var webDriverError = new error.WebDriverError;
|
|
185
|
-
|
|
186
|
-
executor.on(CommandName.GET_ALERT_TEXT, function() {
|
|
187
|
-
throw webDriverError;
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
return driver.wait(until.alertIsPresent(), 1000).then(function() {
|
|
191
|
-
throw new Error('driver did not fail against WebDriverError');
|
|
192
|
-
}, function(error) {
|
|
193
|
-
assert.equal(error, webDriverError);
|
|
194
|
-
});
|
|
195
|
-
})
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it('testUntilTitleIs', function() {
|
|
200
|
-
var titles = ['foo', 'bar', 'baz'];
|
|
201
|
-
executor.on(CommandName.GET_TITLE, () => titles.shift());
|
|
202
|
-
|
|
203
|
-
return driver.wait(until.titleIs('bar'), 3000).then(function() {
|
|
204
|
-
assert.deepStrictEqual(titles, ['baz']);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('testUntilTitleContains', function() {
|
|
209
|
-
var titles = ['foo', 'froogle', 'google'];
|
|
210
|
-
executor.on(CommandName.GET_TITLE, () => titles.shift());
|
|
211
|
-
|
|
212
|
-
return driver.wait(until.titleContains('oogle'), 3000).then(function() {
|
|
213
|
-
assert.deepStrictEqual(titles, ['google']);
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('testUntilTitleMatches', function() {
|
|
218
|
-
var titles = ['foo', 'froogle', 'aaaabc', 'aabbbc', 'google'];
|
|
219
|
-
executor.on(CommandName.GET_TITLE, () => titles.shift());
|
|
220
|
-
|
|
221
|
-
return driver.wait(until.titleMatches(/^a{2,3}b+c$/), 3000)
|
|
222
|
-
.then(function() {
|
|
223
|
-
assert.deepStrictEqual(titles, ['google']);
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('testUntilUrlIs', function() {
|
|
228
|
-
var urls = ['http://www.foo.com', 'https://boo.com', 'http://docs.yes.com'];
|
|
229
|
-
executor.on(CommandName.GET_CURRENT_URL, () => urls.shift());
|
|
230
|
-
|
|
231
|
-
return driver.wait(until.urlIs('https://boo.com'), 3000).then(function() {
|
|
232
|
-
assert.deepStrictEqual(urls, ['http://docs.yes.com']);
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('testUntilUrlContains', function() {
|
|
237
|
-
var urls =
|
|
238
|
-
['http://foo.com', 'https://groups.froogle.com', 'http://google.com'];
|
|
239
|
-
executor.on(CommandName.GET_CURRENT_URL, () => urls.shift());
|
|
240
|
-
|
|
241
|
-
return driver.wait(until.urlContains('oogle.com'), 3000).then(function() {
|
|
242
|
-
assert.deepStrictEqual(urls, ['http://google.com']);
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('testUntilUrlMatches', function() {
|
|
247
|
-
var urls = ['foo', 'froogle', 'aaaabc', 'aabbbc', 'google'];
|
|
248
|
-
executor.on(CommandName.GET_CURRENT_URL, () => urls.shift());
|
|
249
|
-
|
|
250
|
-
return driver.wait(until.urlMatches(/^a{2,3}b+c$/), 3000)
|
|
251
|
-
.then(function() {
|
|
252
|
-
assert.deepStrictEqual(urls, ['google']);
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('testUntilElementLocated', function() {
|
|
257
|
-
var responses = [
|
|
258
|
-
[],
|
|
259
|
-
[WebElement.buildId('abc123'), WebElement.buildId('foo')],
|
|
260
|
-
['end']
|
|
261
|
-
];
|
|
262
|
-
executor.on(CommandName.FIND_ELEMENTS, () => responses.shift());
|
|
263
|
-
|
|
264
|
-
let element = driver.wait(until.elementLocated(By.id('quux')), 2000);
|
|
265
|
-
assert.ok(element instanceof webdriver.WebElementPromise);
|
|
266
|
-
return element.getId().then(function(id) {
|
|
267
|
-
assert.deepStrictEqual(responses, [['end']]);
|
|
268
|
-
assert.equal(id, 'abc123');
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
describe('untilElementLocated, elementNeverFound', function() {
|
|
273
|
-
function runNoElementFoundTest(locator, locatorStr) {
|
|
274
|
-
executor.on(CommandName.FIND_ELEMENTS, () => []);
|
|
275
|
-
|
|
276
|
-
function expectedFailure() {
|
|
277
|
-
fail('expected condition to timeout');
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return driver.wait(until.elementLocated(locator), 100)
|
|
281
|
-
.then(expectedFailure, function(error) {
|
|
282
|
-
var expected = 'Waiting for element to be located ' + locatorStr;
|
|
283
|
-
var lines = error.message.split(/\n/, 2);
|
|
284
|
-
assert.equal(lines[0], expected);
|
|
285
|
-
|
|
286
|
-
let regex = /^Wait timed out after \d+ms$/;
|
|
287
|
-
assert.ok(regex.test(lines[1]),
|
|
288
|
-
`Lines <${lines[1]}> does not match ${regex}`);
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
it('byLocator', function() {
|
|
293
|
-
return runNoElementFoundTest(
|
|
294
|
-
By.id('quux'), 'By(css selector, *[id="quux"])');
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it('byHash', function() {
|
|
298
|
-
return runNoElementFoundTest(
|
|
299
|
-
{id: 'quux'}, 'By(css selector, *[id="quux"])');
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it('byFunction', function() {
|
|
303
|
-
return runNoElementFoundTest(function() {}, 'by function()');
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it('testUntilElementsLocated', function() {
|
|
308
|
-
var responses = [
|
|
309
|
-
[],
|
|
310
|
-
[WebElement.buildId('abc123'), WebElement.buildId('foo')],
|
|
311
|
-
['end']
|
|
312
|
-
];
|
|
313
|
-
executor.on(CommandName.FIND_ELEMENTS, () => responses.shift());
|
|
314
|
-
|
|
315
|
-
return driver.wait(until.elementsLocated(By.id('quux')), 2000)
|
|
316
|
-
.then(function(els) {
|
|
317
|
-
return Promise.all(els.map(e => e.getId()));
|
|
318
|
-
}).then(function(ids) {
|
|
319
|
-
assert.deepStrictEqual(responses, [['end']]);
|
|
320
|
-
assert.equal(ids.length, 2);
|
|
321
|
-
assert.equal(ids[0], 'abc123');
|
|
322
|
-
assert.equal(ids[1], 'foo');
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
describe('untilElementsLocated, noElementsFound', function() {
|
|
327
|
-
function runNoElementsFoundTest(locator, locatorStr) {
|
|
328
|
-
executor.on(CommandName.FIND_ELEMENTS, () => []);
|
|
329
|
-
|
|
330
|
-
function expectedFailure() {
|
|
331
|
-
fail('expected condition to timeout');
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return driver.wait(until.elementsLocated(locator), 100)
|
|
335
|
-
.then(expectedFailure, function(error) {
|
|
336
|
-
var expected =
|
|
337
|
-
'Waiting for at least one element to be located ' + locatorStr;
|
|
338
|
-
var lines = error.message.split(/\n/, 2);
|
|
339
|
-
assert.equal(lines[0], expected);
|
|
340
|
-
|
|
341
|
-
let regex = /^Wait timed out after \d+ms$/;
|
|
342
|
-
assert.ok(regex.test(lines[1]),
|
|
343
|
-
`Lines <${lines[1]}> does not match ${regex}`);
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
it('byLocator', function() {
|
|
348
|
-
return runNoElementsFoundTest(
|
|
349
|
-
By.id('quux'), 'By(css selector, *[id="quux"])');
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
it('byHash', function() {
|
|
353
|
-
return runNoElementsFoundTest(
|
|
354
|
-
{id: 'quux'}, 'By(css selector, *[id="quux"])');
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it('byFunction', function() {
|
|
358
|
-
return runNoElementsFoundTest(function() {}, 'by function()');
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
it('testUntilStalenessOf', function() {
|
|
363
|
-
let count = 0;
|
|
364
|
-
executor.on(CommandName.GET_ELEMENT_TAG_NAME, function() {
|
|
365
|
-
while (count < 3) {
|
|
366
|
-
count += 1;
|
|
367
|
-
return 'body';
|
|
368
|
-
}
|
|
369
|
-
throw new error.StaleElementReferenceError('now stale');
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
var el = new webdriver.WebElement(driver, {ELEMENT: 'foo'});
|
|
373
|
-
return driver.wait(until.stalenessOf(el), 2000)
|
|
374
|
-
.then(() => assert.equal(count, 3));
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
describe('element state conditions', function() {
|
|
378
|
-
function runElementStateTest(predicate, command, responses, var_args) {
|
|
379
|
-
let original = new webdriver.WebElement(driver, 'foo');
|
|
380
|
-
let predicateArgs = [original];
|
|
381
|
-
if (arguments.length > 3) {
|
|
382
|
-
predicateArgs = predicateArgs.concat(arguments[1]);
|
|
383
|
-
command = arguments[2];
|
|
384
|
-
responses = arguments[3];
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
assert.ok(responses.length > 1);
|
|
388
|
-
|
|
389
|
-
responses = responses.concat(['end']);
|
|
390
|
-
executor.on(command, () => responses.shift());
|
|
391
|
-
|
|
392
|
-
let result = driver.wait(predicate.apply(null, predicateArgs), 2000);
|
|
393
|
-
assert.ok(result instanceof webdriver.WebElementPromise);
|
|
394
|
-
return result.then(function(value) {
|
|
395
|
-
assert.ok(value instanceof webdriver.WebElement);
|
|
396
|
-
assert.ok(!(value instanceof webdriver.WebElementPromise));
|
|
397
|
-
return value.getId();
|
|
398
|
-
}).then(function(id) {
|
|
399
|
-
assert.equal('foo', id);
|
|
400
|
-
assert.deepStrictEqual(responses, ['end']);
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
it('elementIsVisible', function() {
|
|
405
|
-
return runElementStateTest(
|
|
406
|
-
until.elementIsVisible,
|
|
407
|
-
CommandName.IS_ELEMENT_DISPLAYED, [false, false, true]);
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
it('elementIsNotVisible', function() {
|
|
411
|
-
return runElementStateTest(
|
|
412
|
-
until.elementIsNotVisible,
|
|
413
|
-
CommandName.IS_ELEMENT_DISPLAYED, [true, true, false]);
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
it('elementIsEnabled', function() {
|
|
417
|
-
return runElementStateTest(
|
|
418
|
-
until.elementIsEnabled,
|
|
419
|
-
CommandName.IS_ELEMENT_ENABLED, [false, false, true]);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it('elementIsDisabled', function() {
|
|
423
|
-
return runElementStateTest(
|
|
424
|
-
until.elementIsDisabled,
|
|
425
|
-
CommandName.IS_ELEMENT_ENABLED, [true, true, false]);
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
it('elementIsSelected', function() {
|
|
429
|
-
return runElementStateTest(
|
|
430
|
-
until.elementIsSelected,
|
|
431
|
-
CommandName.IS_ELEMENT_SELECTED, [false, false, true]);
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
it('elementIsNotSelected', function() {
|
|
435
|
-
return runElementStateTest(
|
|
436
|
-
until.elementIsNotSelected,
|
|
437
|
-
CommandName.IS_ELEMENT_SELECTED, [true, true, false]);
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
it('elementTextIs', function() {
|
|
441
|
-
return runElementStateTest(
|
|
442
|
-
until.elementTextIs, 'foobar',
|
|
443
|
-
CommandName.GET_ELEMENT_TEXT,
|
|
444
|
-
['foo', 'fooba', 'foobar']);
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
it('elementTextContains', function() {
|
|
448
|
-
return runElementStateTest(
|
|
449
|
-
until.elementTextContains, 'bar',
|
|
450
|
-
CommandName.GET_ELEMENT_TEXT,
|
|
451
|
-
['foo', 'foobaz', 'foobarbaz']);
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
it('elementTextMatches', function() {
|
|
455
|
-
return runElementStateTest(
|
|
456
|
-
until.elementTextMatches, /fo+bar{3}/,
|
|
457
|
-
CommandName.GET_ELEMENT_TEXT,
|
|
458
|
-
['foo', 'foobar', 'fooobarrr']);
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
describe('WebElementCondition', function() {
|
|
463
|
-
it('fails if wait completes with a non-WebElement value', function() {
|
|
464
|
-
let result = driver.wait(
|
|
465
|
-
new webdriver.WebElementCondition('testing', () => 123), 1000);
|
|
466
|
-
|
|
467
|
-
return result.then(
|
|
468
|
-
() => assert.fail('expected to fail'),
|
|
469
|
-
function(e) {
|
|
470
|
-
assert.ok(e instanceof TypeError);
|
|
471
|
-
assert.equal(
|
|
472
|
-
'WebElementCondition did not resolve to a WebElement: '
|
|
473
|
-
+ '[object Number]',
|
|
474
|
-
e.message);
|
|
475
|
-
});
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
|
-
});
|