selenium-webdriver 2.47.0 → 2.52.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.
- package/CHANGES.md +96 -0
- package/NOTICE +1 -1
- package/README.md +57 -6
- package/builder.js +375 -358
- package/chrome.js +549 -586
- package/edge.js +378 -0
- package/error.js +597 -5
- package/example/google_search_generator.js +2 -4
- package/example/logging.js +6 -2
- package/executors.js +11 -27
- package/firefox/binary.js +80 -114
- package/firefox/extension.js +10 -19
- package/firefox/index.js +175 -171
- package/firefox/profile.js +221 -239
- package/http/index.js +396 -77
- package/http/util.js +35 -35
- package/ie.js +288 -309
- package/index.js +34 -125
- package/io/exec.js +58 -39
- package/io/index.js +54 -48
- package/lib/actions.js +594 -0
- package/lib/by.js +276 -0
- package/lib/capabilities.js +404 -0
- package/lib/{webdriver/command.js → command.js} +89 -72
- package/lib/{webdriver/button.js → devmode.js} +13 -8
- package/lib/events.js +210 -0
- package/lib/firefox/amd64/libnoblur64.so +0 -0
- package/lib/firefox/i386/libnoblur.so +0 -0
- package/lib/firefox/webdriver.json +6 -1
- package/lib/firefox/webdriver.xpi +0 -0
- package/lib/{webdriver/key.js → input.js} +82 -2
- package/lib/logging.js +668 -0
- package/lib/promise.js +3093 -0
- package/lib/safari/client.js +697 -659
- package/lib/session.js +79 -0
- package/{test/promise_aplus_test.js → lib/symbols.js} +15 -25
- package/lib/test/build.js +4 -4
- package/lib/test/data/click_tests/disappearing_element.html +62 -0
- package/lib/test/data/click_tests/html5_submit_buttons.html +2 -1
- package/lib/test/data/click_tests/overlapping_elements.html +70 -0
- package/lib/test/data/click_tests/partially_overlapping_elements.html +124 -0
- package/lib/test/data/click_tests/wrapped_overlapping_elements.html +13 -0
- package/lib/test/data/readOnlyPage.html +3 -1
- package/lib/test/data/selectPage.html +18 -2
- package/lib/test/data/simpleTest.html +1 -0
- package/lib/test/fileserver.js +3 -4
- package/lib/test/index.js +13 -4
- package/lib/test/resources.js +1 -1
- package/lib/until.js +428 -0
- package/lib/webdriver.js +2351 -0
- package/net/portprober.js +15 -11
- package/opera.js +295 -314
- package/package.json +6 -5
- package/phantomjs.js +135 -140
- package/proxy.js +6 -4
- package/remote/index.js +234 -219
- package/safari.js +319 -310
- package/test/chrome/options_test.js +11 -9
- package/test/element_finding_test.js +51 -13
- package/test/error_test.js +163 -0
- package/test/execute_script_test.js +1 -1
- package/test/firefox/firefox_test.js +24 -0
- package/test/http/http_test.js +354 -43
- package/test/http/util_test.js +25 -23
- package/test/io_test.js +6 -1
- package/test/lib/by_test.js +127 -0
- package/test/lib/capabilities_test.js +84 -0
- package/test/lib/events_test.js +177 -0
- package/test/lib/logging_test.js +272 -0
- package/test/lib/promise_aplus_test.js +74 -0
- package/test/lib/promise_error_test.js +808 -0
- package/test/lib/promise_flow_test.js +2282 -0
- package/test/lib/promise_generator_test.js +308 -0
- package/test/lib/promise_test.js +996 -0
- package/test/lib/testutil.js +90 -0
- package/test/lib/until_test.js +436 -0
- package/test/lib/webdriver_test.js +2207 -0
- package/test/page_loading_test.js +7 -9
- package/test/stale_element_test.js +2 -2
- package/test/testing/assert_test.js +374 -0
- package/test/testing/index_test.js +9 -11
- package/testing/assert.js +334 -17
- package/testing/index.js +10 -0
- package/_base.js +0 -200
- package/docs/Changes.html +0 -317
- package/docs/class_bot_Error.html +0 -15
- package/docs/class_webdriver_ActionSequence.html +0 -115
- package/docs/class_webdriver_Alert.html +0 -24
- package/docs/class_webdriver_AlertPromise.html +0 -91
- package/docs/class_webdriver_Capabilities.html +0 -60
- package/docs/class_webdriver_Command.html +0 -15
- package/docs/class_webdriver_EventEmitter.html +0 -35
- package/docs/class_webdriver_FileDetector.html +0 -21
- package/docs/class_webdriver_Locator.html +0 -12
- package/docs/class_webdriver_Serializable.html +0 -9
- package/docs/class_webdriver_Session.html +0 -13
- package/docs/class_webdriver_TouchSequence.html +0 -49
- package/docs/class_webdriver_UnhandledAlertError.html +0 -18
- package/docs/class_webdriver_WebDriver.html +0 -313
- package/docs/class_webdriver_WebDriver_Logs.html +0 -15
- package/docs/class_webdriver_WebDriver_Navigation.html +0 -16
- package/docs/class_webdriver_WebDriver_Options.html +0 -41
- package/docs/class_webdriver_WebDriver_TargetLocator.html +0 -38
- package/docs/class_webdriver_WebDriver_Timeouts.html +0 -29
- package/docs/class_webdriver_WebDriver_Window.html +0 -27
- package/docs/class_webdriver_WebElement.html +0 -216
- package/docs/class_webdriver_WebElementPromise.html +0 -266
- package/docs/class_webdriver_http_Executor.html +0 -22
- package/docs/class_webdriver_http_Request.html +0 -12
- package/docs/class_webdriver_http_Response.html +0 -13
- package/docs/class_webdriver_logging_Entry.html +0 -15
- package/docs/class_webdriver_logging_Level.html +0 -55
- package/docs/class_webdriver_logging_LogRecord.html +0 -45
- package/docs/class_webdriver_logging_Logger.html +0 -119
- package/docs/class_webdriver_logging_Preferences.html +0 -8
- package/docs/class_webdriver_promise_CancellationError.html +0 -18
- package/docs/class_webdriver_promise_ControlFlow.html +0 -109
- package/docs/class_webdriver_promise_Deferred.html +0 -84
- package/docs/class_webdriver_promise_Promise.html +0 -74
- package/docs/class_webdriver_stacktrace_Frame.html +0 -20
- package/docs/class_webdriver_stacktrace_Snapshot.html +0 -6
- package/docs/class_webdriver_testing_Assertion.html +0 -99
- package/docs/class_webdriver_testing_Assertion_DelegatingMatcher_.html +0 -13
- package/docs/class_webdriver_testing_ContainsMatcher.html +0 -11
- package/docs/class_webdriver_testing_NegatedAssertion.html +0 -97
- package/docs/class_webdriver_until_Condition.html +0 -7
- package/docs/dossier.css +0 -1
- package/docs/dossier.js +0 -86
- package/docs/enum_bot_ErrorCode.html +0 -3
- package/docs/enum_bot_Error_State.html +0 -2
- package/docs/enum_webdriver_Browser.html +0 -2
- package/docs/enum_webdriver_Button.html +0 -2
- package/docs/enum_webdriver_Capability.html +0 -33
- package/docs/enum_webdriver_CommandName.html +0 -3
- package/docs/enum_webdriver_Key.html +0 -12
- package/docs/enum_webdriver_logging_Type.html +0 -6
- package/docs/enum_webdriver_promise_ControlFlow_EventType.html +0 -9
- package/docs/index.html +0 -123
- package/docs/interface_webdriver_CommandExecutor.html +0 -9
- package/docs/interface_webdriver_http_Client.html +0 -10
- package/docs/interface_webdriver_promise_Thenable.html +0 -77
- package/docs/module_selenium-webdriver.html +0 -23
- package/docs/module_selenium-webdriver__base.html +0 -23
- package/docs/module_selenium-webdriver__base_class_Context.html +0 -5
- package/docs/module_selenium-webdriver_builder.html +0 -2
- package/docs/module_selenium-webdriver_builder_class_Builder.html +0 -138
- package/docs/module_selenium-webdriver_chrome.html +0 -90
- package/docs/module_selenium-webdriver_chrome_class_Driver.html +0 -280
- package/docs/module_selenium-webdriver_chrome_class_Options.html +0 -127
- package/docs/module_selenium-webdriver_chrome_class_ServiceBuilder.html +0 -46
- package/docs/module_selenium-webdriver_class_ActionSequence.html +0 -115
- package/docs/module_selenium-webdriver_class_Builder.html +0 -138
- package/docs/module_selenium-webdriver_class_Capabilities.html +0 -60
- package/docs/module_selenium-webdriver_class_Command.html +0 -15
- package/docs/module_selenium-webdriver_class_EventEmitter.html +0 -35
- package/docs/module_selenium-webdriver_class_FileDetector.html +0 -21
- package/docs/module_selenium-webdriver_class_Serializable.html +0 -9
- package/docs/module_selenium-webdriver_class_Session.html +0 -13
- package/docs/module_selenium-webdriver_class_WebDriver.html +0 -313
- package/docs/module_selenium-webdriver_class_WebElement.html +0 -216
- package/docs/module_selenium-webdriver_class_WebElementPromise.html +0 -266
- package/docs/module_selenium-webdriver_enum_Browser.html +0 -2
- package/docs/module_selenium-webdriver_enum_Button.html +0 -2
- package/docs/module_selenium-webdriver_enum_Capability.html +0 -33
- package/docs/module_selenium-webdriver_enum_CommandName.html +0 -3
- package/docs/module_selenium-webdriver_enum_Key.html +0 -12
- package/docs/module_selenium-webdriver_error.html +0 -4
- package/docs/module_selenium-webdriver_error_class_Error.html +0 -15
- package/docs/module_selenium-webdriver_error_enum_ErrorCode.html +0 -3
- package/docs/module_selenium-webdriver_executors.html +0 -10
- package/docs/module_selenium-webdriver_executors_class_DeferredExecutor.html +0 -12
- package/docs/module_selenium-webdriver_firefox.html +0 -67
- package/docs/module_selenium-webdriver_firefox_binary.html +0 -4
- package/docs/module_selenium-webdriver_firefox_binary_class_Binary.html +0 -21
- package/docs/module_selenium-webdriver_firefox_class_Binary.html +0 -21
- package/docs/module_selenium-webdriver_firefox_class_Driver.html +0 -276
- package/docs/module_selenium-webdriver_firefox_class_Options.html +0 -19
- package/docs/module_selenium-webdriver_firefox_class_Profile.html +0 -50
- package/docs/module_selenium-webdriver_firefox_extension.html +0 -8
- package/docs/module_selenium-webdriver_firefox_profile.html +0 -13
- package/docs/module_selenium-webdriver_firefox_profile_class_Profile.html +0 -50
- package/docs/module_selenium-webdriver_http.html +0 -9
- package/docs/module_selenium-webdriver_http_class_Executor.html +0 -22
- package/docs/module_selenium-webdriver_http_class_HttpClient.html +0 -16
- package/docs/module_selenium-webdriver_http_class_Request.html +0 -12
- package/docs/module_selenium-webdriver_http_class_Response.html +0 -13
- package/docs/module_selenium-webdriver_http_util.html +0 -17
- package/docs/module_selenium-webdriver_ie.html +0 -11
- package/docs/module_selenium-webdriver_ie_class_Driver.html +0 -274
- package/docs/module_selenium-webdriver_ie_class_Options.html +0 -89
- package/docs/module_selenium-webdriver_ie_enum_Level.html +0 -1
- package/docs/module_selenium-webdriver_io.html +0 -37
- package/docs/module_selenium-webdriver_io_exec.html +0 -6
- package/docs/module_selenium-webdriver_namespace_By.html +0 -56
- package/docs/module_selenium-webdriver_namespace_error.html +0 -4
- package/docs/module_selenium-webdriver_namespace_logging.html +0 -18
- package/docs/module_selenium-webdriver_namespace_promise.html +0 -162
- package/docs/module_selenium-webdriver_namespace_stacktrace.html +0 -17
- package/docs/module_selenium-webdriver_namespace_until.html +0 -82
- package/docs/module_selenium-webdriver_net.html +0 -7
- package/docs/module_selenium-webdriver_net_portprober.html +0 -12
- package/docs/module_selenium-webdriver_opera.html +0 -62
- package/docs/module_selenium-webdriver_opera_class_Driver.html +0 -276
- package/docs/module_selenium-webdriver_opera_class_Options.html +0 -44
- package/docs/module_selenium-webdriver_opera_class_ServiceBuilder.html +0 -35
- package/docs/module_selenium-webdriver_phantomjs.html +0 -2
- package/docs/module_selenium-webdriver_phantomjs_class_Driver.html +0 -299
- package/docs/module_selenium-webdriver_proxy.html +0 -28
- package/docs/module_selenium-webdriver_remote.html +0 -8
- package/docs/module_selenium-webdriver_remote_class_DriverService.html +0 -32
- package/docs/module_selenium-webdriver_remote_class_FileDetector.html +0 -22
- package/docs/module_selenium-webdriver_remote_class_SeleniumServer.html +0 -40
- package/docs/module_selenium-webdriver_safari.html +0 -9
- package/docs/module_selenium-webdriver_safari_class_Driver.html +0 -279
- package/docs/module_selenium-webdriver_safari_class_Options.html +0 -23
- package/docs/module_selenium-webdriver_testing.html +0 -74
- package/docs/module_selenium-webdriver_testing_assert.html +0 -9
- package/docs/namespace_bot.html +0 -4
- package/docs/namespace_bot_json.html +0 -20
- package/docs/namespace_bot_response.html +0 -18
- package/docs/namespace_bot_userAgent.html +0 -33
- package/docs/namespace_webdriver.html +0 -30
- package/docs/namespace_webdriver_By.html +0 -56
- package/docs/namespace_webdriver_http.html +0 -6
- package/docs/namespace_webdriver_logging.html +0 -70
- package/docs/namespace_webdriver_promise.html +0 -165
- package/docs/namespace_webdriver_stacktrace.html +0 -17
- package/docs/namespace_webdriver_testing.html +0 -7
- package/docs/namespace_webdriver_testing_assert.html +0 -9
- package/docs/namespace_webdriver_testing_asserts.html +0 -18
- package/docs/namespace_webdriver_until.html +0 -82
- package/docs/source/_base.js.src.html +0 -1
- package/docs/source/builder.js.src.html +0 -1
- package/docs/source/chrome.js.src.html +0 -1
- package/docs/source/error.js.src.html +0 -1
- package/docs/source/executors.js.src.html +0 -1
- package/docs/source/firefox/binary.js.src.html +0 -1
- package/docs/source/firefox/extension.js.src.html +0 -1
- package/docs/source/firefox/index.js.src.html +0 -1
- package/docs/source/firefox/profile.js.src.html +0 -1
- package/docs/source/http/index.js.src.html +0 -1
- package/docs/source/http/util.js.src.html +0 -1
- package/docs/source/ie.js.src.html +0 -1
- package/docs/source/index.js.src.html +0 -1
- package/docs/source/io/exec.js.src.html +0 -1
- package/docs/source/io/index.js.src.html +0 -1
- package/docs/source/lib/atoms/error.js.src.html +0 -1
- package/docs/source/lib/atoms/json.js.src.html +0 -1
- package/docs/source/lib/atoms/response.js.src.html +0 -1
- package/docs/source/lib/atoms/userAgent.js.src.html +0 -1
- package/docs/source/lib/goog/array/array.js.src.html +0 -1
- package/docs/source/lib/goog/asserts/asserts.js.src.html +0 -1
- package/docs/source/lib/goog/async/freelist.js.src.html +0 -1
- package/docs/source/lib/goog/async/nexttick.js.src.html +0 -1
- package/docs/source/lib/goog/async/run.js.src.html +0 -1
- package/docs/source/lib/goog/async/workqueue.js.src.html +0 -1
- package/docs/source/lib/goog/base.js.src.html +0 -1
- package/docs/source/lib/goog/debug/debug.js.src.html +0 -1
- package/docs/source/lib/goog/debug/entrypointregistry.js.src.html +0 -1
- package/docs/source/lib/goog/debug/error.js.src.html +0 -1
- package/docs/source/lib/goog/debug/logbuffer.js.src.html +0 -1
- package/docs/source/lib/goog/debug/logger.js.src.html +0 -1
- package/docs/source/lib/goog/debug/logrecord.js.src.html +0 -1
- package/docs/source/lib/goog/deps.js.src.html +0 -1
- package/docs/source/lib/goog/disposable/disposable.js.src.html +0 -1
- package/docs/source/lib/goog/disposable/idisposable.js.src.html +0 -1
- package/docs/source/lib/goog/dom/browserfeature.js.src.html +0 -1
- package/docs/source/lib/goog/dom/dom.js.src.html +0 -1
- package/docs/source/lib/goog/dom/nodetype.js.src.html +0 -1
- package/docs/source/lib/goog/dom/safe.js.src.html +0 -1
- package/docs/source/lib/goog/dom/tagname.js.src.html +0 -1
- package/docs/source/lib/goog/dom/tags.js.src.html +0 -1
- package/docs/source/lib/goog/dom/vendor.js.src.html +0 -1
- package/docs/source/lib/goog/events/browserevent.js.src.html +0 -1
- package/docs/source/lib/goog/events/browserfeature.js.src.html +0 -1
- package/docs/source/lib/goog/events/event.js.src.html +0 -1
- package/docs/source/lib/goog/events/eventid.js.src.html +0 -1
- package/docs/source/lib/goog/events/events.js.src.html +0 -1
- package/docs/source/lib/goog/events/eventtarget.js.src.html +0 -1
- package/docs/source/lib/goog/events/eventtype.js.src.html +0 -1
- package/docs/source/lib/goog/events/keycodes.js.src.html +0 -1
- package/docs/source/lib/goog/events/listenable.js.src.html +0 -1
- package/docs/source/lib/goog/events/listener.js.src.html +0 -1
- package/docs/source/lib/goog/events/listenermap.js.src.html +0 -1
- package/docs/source/lib/goog/fs/url.js.src.html +0 -1
- package/docs/source/lib/goog/functions/functions.js.src.html +0 -1
- package/docs/source/lib/goog/html/safehtml.js.src.html +0 -1
- package/docs/source/lib/goog/html/safescript.js.src.html +0 -1
- package/docs/source/lib/goog/html/safestyle.js.src.html +0 -1
- package/docs/source/lib/goog/html/safestylesheet.js.src.html +0 -1
- package/docs/source/lib/goog/html/safeurl.js.src.html +0 -1
- package/docs/source/lib/goog/html/trustedresourceurl.js.src.html +0 -1
- package/docs/source/lib/goog/html/uncheckedconversions.js.src.html +0 -1
- package/docs/source/lib/goog/i18n/bidi.js.src.html +0 -1
- package/docs/source/lib/goog/iter/iter.js.src.html +0 -1
- package/docs/source/lib/goog/json/json.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/assertthat.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/logicmatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/matcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/numbermatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/objectmatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/testing/stringmatcher.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/browser.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/engine.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/platform.js.src.html +0 -1
- package/docs/source/lib/goog/labs/useragent/util.js.src.html +0 -1
- package/docs/source/lib/goog/math/box.js.src.html +0 -1
- package/docs/source/lib/goog/math/coordinate.js.src.html +0 -1
- package/docs/source/lib/goog/math/math.js.src.html +0 -1
- package/docs/source/lib/goog/math/rect.js.src.html +0 -1
- package/docs/source/lib/goog/math/size.js.src.html +0 -1
- package/docs/source/lib/goog/net/wrapperxmlhttpfactory.js.src.html +0 -1
- package/docs/source/lib/goog/net/xhrlike.js.src.html +0 -1
- package/docs/source/lib/goog/net/xmlhttp.js.src.html +0 -1
- package/docs/source/lib/goog/net/xmlhttpfactory.js.src.html +0 -1
- package/docs/source/lib/goog/object/object.js.src.html +0 -1
- package/docs/source/lib/goog/promise/promise.js.src.html +0 -1
- package/docs/source/lib/goog/promise/resolver.js.src.html +0 -1
- package/docs/source/lib/goog/promise/thenable.js.src.html +0 -1
- package/docs/source/lib/goog/reflect/reflect.js.src.html +0 -1
- package/docs/source/lib/goog/string/const.js.src.html +0 -1
- package/docs/source/lib/goog/string/string.js.src.html +0 -1
- package/docs/source/lib/goog/string/typedstring.js.src.html +0 -1
- package/docs/source/lib/goog/structs/collection.js.src.html +0 -1
- package/docs/source/lib/goog/structs/map.js.src.html +0 -1
- package/docs/source/lib/goog/structs/set.js.src.html +0 -1
- package/docs/source/lib/goog/structs/structs.js.src.html +0 -1
- package/docs/source/lib/goog/style/style.js.src.html +0 -1
- package/docs/source/lib/goog/testing/asserts.js.src.html +0 -1
- package/docs/source/lib/goog/testing/events/events.js.src.html +0 -1
- package/docs/source/lib/goog/testing/functionmock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/jsunit.js.src.html +0 -1
- package/docs/source/lib/goog/testing/loosemock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockclock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockcontrol.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockinterface.js.src.html +0 -1
- package/docs/source/lib/goog/testing/mockmatchers.js.src.html +0 -1
- package/docs/source/lib/goog/testing/objectpropertystring.js.src.html +0 -1
- package/docs/source/lib/goog/testing/propertyreplacer.js.src.html +0 -1
- package/docs/source/lib/goog/testing/recordfunction.js.src.html +0 -1
- package/docs/source/lib/goog/testing/stacktrace.js.src.html +0 -1
- package/docs/source/lib/goog/testing/strictmock.js.src.html +0 -1
- package/docs/source/lib/goog/testing/testcase.js.src.html +0 -1
- package/docs/source/lib/goog/testing/testrunner.js.src.html +0 -1
- package/docs/source/lib/goog/testing/watchers.js.src.html +0 -1
- package/docs/source/lib/goog/uri/uri.js.src.html +0 -1
- package/docs/source/lib/goog/uri/utils.js.src.html +0 -1
- package/docs/source/lib/goog/useragent/product.js.src.html +0 -1
- package/docs/source/lib/goog/useragent/product_isversion.js.src.html +0 -1
- package/docs/source/lib/goog/useragent/useragent.js.src.html +0 -1
- package/docs/source/lib/webdriver/actionsequence.js.src.html +0 -1
- package/docs/source/lib/webdriver/button.js.src.html +0 -1
- package/docs/source/lib/webdriver/capabilities.js.src.html +0 -1
- package/docs/source/lib/webdriver/command.js.src.html +0 -1
- package/docs/source/lib/webdriver/events.js.src.html +0 -1
- package/docs/source/lib/webdriver/http/http.js.src.html +0 -1
- package/docs/source/lib/webdriver/key.js.src.html +0 -1
- package/docs/source/lib/webdriver/locators.js.src.html +0 -1
- package/docs/source/lib/webdriver/logging.js.src.html +0 -1
- package/docs/source/lib/webdriver/promise.js.src.html +0 -1
- package/docs/source/lib/webdriver/serializable.js.src.html +0 -1
- package/docs/source/lib/webdriver/session.js.src.html +0 -1
- package/docs/source/lib/webdriver/stacktrace.js.src.html +0 -1
- package/docs/source/lib/webdriver/testing/asserts.js.src.html +0 -1
- package/docs/source/lib/webdriver/touchsequence.js.src.html +0 -1
- package/docs/source/lib/webdriver/until.js.src.html +0 -1
- package/docs/source/lib/webdriver/webdriver.js.src.html +0 -1
- package/docs/source/net/index.js.src.html +0 -1
- package/docs/source/net/portprober.js.src.html +0 -1
- package/docs/source/opera.js.src.html +0 -1
- package/docs/source/phantomjs.js.src.html +0 -1
- package/docs/source/proxy.js.src.html +0 -1
- package/docs/source/remote/index.js.src.html +0 -1
- package/docs/source/safari.js.src.html +0 -1
- package/docs/source/testing/assert.js.src.html +0 -1
- package/docs/source/testing/index.js.src.html +0 -1
- package/docs/types.js +0 -1
- package/lib/atoms/error.js +0 -202
- package/lib/atoms/json.js +0 -80
- package/lib/atoms/response.js +0 -110
- package/lib/atoms/userAgent.js +0 -257
- package/lib/goog/LICENSE +0 -176
- package/lib/goog/array/array.js +0 -1655
- package/lib/goog/asserts/asserts.js +0 -365
- package/lib/goog/async/freelist.js +0 -88
- package/lib/goog/async/nexttick.js +0 -241
- package/lib/goog/async/run.js +0 -139
- package/lib/goog/async/workqueue.js +0 -139
- package/lib/goog/base.js +0 -2547
- package/lib/goog/debug/debug.js +0 -653
- package/lib/goog/debug/entrypointregistry.js +0 -158
- package/lib/goog/debug/error.js +0 -63
- package/lib/goog/debug/logbuffer.js +0 -148
- package/lib/goog/debug/logger.js +0 -873
- package/lib/goog/debug/logrecord.js +0 -242
- package/lib/goog/deps.js +0 -151
- package/lib/goog/disposable/disposable.js +0 -307
- package/lib/goog/disposable/idisposable.js +0 -45
- package/lib/goog/dom/browserfeature.js +0 -72
- package/lib/goog/dom/dom.js +0 -2995
- package/lib/goog/dom/nodetype.js +0 -48
- package/lib/goog/dom/safe.js +0 -347
- package/lib/goog/dom/tagname.js +0 -160
- package/lib/goog/dom/tags.js +0 -42
- package/lib/goog/dom/vendor.js +0 -96
- package/lib/goog/events/browserevent.js +0 -386
- package/lib/goog/events/browserfeature.js +0 -85
- package/lib/goog/events/event.js +0 -143
- package/lib/goog/events/eventid.js +0 -47
- package/lib/goog/events/events.js +0 -984
- package/lib/goog/events/eventtarget.js +0 -394
- package/lib/goog/events/eventtype.js +0 -233
- package/lib/goog/events/keycodes.js +0 -420
- package/lib/goog/events/listenable.js +0 -335
- package/lib/goog/events/listener.js +0 -131
- package/lib/goog/events/listenermap.js +0 -308
- package/lib/goog/fs/url.js +0 -105
- package/lib/goog/functions/functions.js +0 -332
- package/lib/goog/html/safehtml.js +0 -756
- package/lib/goog/html/safescript.js +0 -234
- package/lib/goog/html/safestyle.js +0 -442
- package/lib/goog/html/safestylesheet.js +0 -276
- package/lib/goog/html/safeurl.js +0 -431
- package/lib/goog/html/trustedresourceurl.js +0 -224
- package/lib/goog/html/uncheckedconversions.js +0 -231
- package/lib/goog/i18n/bidi.js +0 -908
- package/lib/goog/iter/iter.js +0 -1305
- package/lib/goog/json/json.js +0 -365
- package/lib/goog/labs/testing/assertthat.js +0 -58
- package/lib/goog/labs/testing/logicmatcher.js +0 -212
- package/lib/goog/labs/testing/matcher.js +0 -80
- package/lib/goog/labs/testing/numbermatcher.js +0 -346
- package/lib/goog/labs/testing/objectmatcher.js +0 -317
- package/lib/goog/labs/testing/stringmatcher.js +0 -415
- package/lib/goog/labs/useragent/browser.js +0 -327
- package/lib/goog/labs/useragent/engine.js +0 -160
- package/lib/goog/labs/useragent/platform.js +0 -160
- package/lib/goog/labs/useragent/util.js +0 -148
- package/lib/goog/math/box.js +0 -389
- package/lib/goog/math/coordinate.js +0 -268
- package/lib/goog/math/math.js +0 -451
- package/lib/goog/math/rect.js +0 -476
- package/lib/goog/math/size.js +0 -227
- package/lib/goog/net/wrapperxmlhttpfactory.js +0 -71
- package/lib/goog/net/xhrlike.js +0 -124
- package/lib/goog/net/xmlhttp.js +0 -246
- package/lib/goog/net/xmlhttpfactory.js +0 -67
- package/lib/goog/object/object.js +0 -686
- package/lib/goog/promise/promise.js +0 -1310
- package/lib/goog/promise/resolver.js +0 -48
- package/lib/goog/promise/thenable.js +0 -126
- package/lib/goog/reflect/reflect.js +0 -78
- package/lib/goog/string/const.js +0 -182
- package/lib/goog/string/string.js +0 -1565
- package/lib/goog/string/typedstring.js +0 -48
- package/lib/goog/structs/collection.js +0 -56
- package/lib/goog/structs/map.js +0 -456
- package/lib/goog/structs/set.js +0 -279
- package/lib/goog/structs/structs.js +0 -354
- package/lib/goog/style/style.js +0 -2054
- package/lib/goog/testing/asserts.js +0 -1265
- package/lib/goog/testing/events/events.js +0 -727
- package/lib/goog/testing/functionmock.js +0 -176
- package/lib/goog/testing/jsunit.js +0 -162
- package/lib/goog/testing/loosemock.js +0 -242
- package/lib/goog/testing/mock.js +0 -645
- package/lib/goog/testing/mockclock.js +0 -617
- package/lib/goog/testing/mockcontrol.js +0 -220
- package/lib/goog/testing/mockinterface.js +0 -45
- package/lib/goog/testing/mockmatchers.js +0 -400
- package/lib/goog/testing/objectpropertystring.js +0 -68
- package/lib/goog/testing/propertyreplacer.js +0 -245
- package/lib/goog/testing/recordfunction.js +0 -215
- package/lib/goog/testing/stacktrace.js +0 -594
- package/lib/goog/testing/strictmock.js +0 -130
- package/lib/goog/testing/testcase.js +0 -1569
- package/lib/goog/testing/testrunner.js +0 -440
- package/lib/goog/testing/watchers.js +0 -46
- package/lib/goog/uri/uri.js +0 -1507
- package/lib/goog/uri/utils.js +0 -1116
- package/lib/goog/useragent/product.js +0 -175
- package/lib/goog/useragent/product_isversion.js +0 -143
- package/lib/goog/useragent/useragent.js +0 -538
- package/lib/webdriver/actionsequence.js +0 -356
- package/lib/webdriver/builder.js +0 -208
- package/lib/webdriver/capabilities.js +0 -411
- package/lib/webdriver/events.js +0 -179
- package/lib/webdriver/firefoxdomexecutor.js +0 -175
- package/lib/webdriver/http/corsclient.js +0 -133
- package/lib/webdriver/http/http.js +0 -523
- package/lib/webdriver/http/xhrclient.js +0 -67
- package/lib/webdriver/locators.js +0 -257
- package/lib/webdriver/logging.js +0 -347
- package/lib/webdriver/promise.js +0 -2609
- package/lib/webdriver/serializable.js +0 -41
- package/lib/webdriver/session.js +0 -74
- package/lib/webdriver/stacktrace.js +0 -619
- package/lib/webdriver/test/builder_test.js +0 -53
- package/lib/webdriver/test/capabilities_test.js +0 -72
- package/lib/webdriver/test/events_test.js +0 -203
- package/lib/webdriver/test/http/corsclient_test.js +0 -151
- package/lib/webdriver/test/http/http_test.js +0 -428
- package/lib/webdriver/test/http/xhrclient_test.js +0 -196
- package/lib/webdriver/test/locators_test.js +0 -59
- package/lib/webdriver/test/logging_test.js +0 -85
- package/lib/webdriver/test/promise_error_test.js +0 -719
- package/lib/webdriver/test/promise_flow_test.js +0 -1957
- package/lib/webdriver/test/promise_generator_test.js +0 -251
- package/lib/webdriver/test/promise_test.js +0 -1981
- package/lib/webdriver/test/stacktrace_test.js +0 -480
- package/lib/webdriver/test/test_bootstrap.js +0 -67
- package/lib/webdriver/test/testing/asserts_test.js +0 -117
- package/lib/webdriver/test/testing/client_test.js +0 -88
- package/lib/webdriver/test/testing/testcase_test.js +0 -229
- package/lib/webdriver/test/testutil.js +0 -209
- package/lib/webdriver/test/testutil_test.js +0 -104
- package/lib/webdriver/test/until_test.js +0 -411
- package/lib/webdriver/test/webdriver_generator_test.js +0 -92
- package/lib/webdriver/test/webdriver_test.js +0 -2369
- package/lib/webdriver/testing/asserts.js +0 -487
- package/lib/webdriver/testing/client.js +0 -179
- package/lib/webdriver/testing/jsunit.js +0 -363
- package/lib/webdriver/testing/testcase.js +0 -168
- package/lib/webdriver/testing/window.js +0 -244
- package/lib/webdriver/touchsequence.js +0 -248
- package/lib/webdriver/until.js +0 -412
- package/lib/webdriver/webdriver.js +0 -2492
- package/test/_base_test.js +0 -129
|
@@ -0,0 +1,2207 @@
|
|
|
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 testutil = require('./testutil');
|
|
21
|
+
|
|
22
|
+
const error = require('../../error');
|
|
23
|
+
|
|
24
|
+
const By = require('../../lib/by').By;
|
|
25
|
+
const Capabilities = require('../../lib/capabilities').Capabilities;
|
|
26
|
+
const Executor = require('../../lib/command').Executor;
|
|
27
|
+
const CName = require('../../lib/command').Name;
|
|
28
|
+
const Button = require('../../lib/input').Button;
|
|
29
|
+
const Key = require('../../lib/input').Key;
|
|
30
|
+
const logging = require('../../lib/logging');
|
|
31
|
+
const Session = require('../../lib/session').Session;
|
|
32
|
+
const promise = require('../../lib/promise');
|
|
33
|
+
const Alert = require('../../lib/webdriver').Alert;
|
|
34
|
+
const AlertPromise = require('../../lib/webdriver').AlertPromise;
|
|
35
|
+
const UnhandledAlertError = require('../../lib/webdriver').UnhandledAlertError;
|
|
36
|
+
const WebDriver = require('../../lib/webdriver').WebDriver;
|
|
37
|
+
const WebElement = require('../../lib/webdriver').WebElement;
|
|
38
|
+
const WebElementPromise = require('../../lib/webdriver').WebElementPromise;
|
|
39
|
+
|
|
40
|
+
const assert = require('assert');
|
|
41
|
+
const sinon = require('sinon');
|
|
42
|
+
|
|
43
|
+
const SESSION_ID = 'test_session_id';
|
|
44
|
+
|
|
45
|
+
// Aliases for readability.
|
|
46
|
+
const NativePromise = Promise;
|
|
47
|
+
const ECode = error.ErrorCode;
|
|
48
|
+
const StubError = testutil.StubError;
|
|
49
|
+
const assertIsInstance = testutil.assertIsInstance;
|
|
50
|
+
const assertIsStubError = testutil.assertIsStubError;
|
|
51
|
+
const throwStubError = testutil.throwStubError;
|
|
52
|
+
const fail = (msg) => assert.fail(msg);
|
|
53
|
+
|
|
54
|
+
describe('WebDriver', function() {
|
|
55
|
+
const LOG = logging.getLogger('webdriver.test');
|
|
56
|
+
|
|
57
|
+
// before(function() {
|
|
58
|
+
// logging.getLogger('webdriver').setLevel(logging.Level.ALL);
|
|
59
|
+
// logging.installConsoleHandler();
|
|
60
|
+
// });
|
|
61
|
+
|
|
62
|
+
// after(function() {
|
|
63
|
+
// logging.getLogger('webdriver').setLevel(null);
|
|
64
|
+
// logging.removeConsoleHandler();
|
|
65
|
+
// });
|
|
66
|
+
|
|
67
|
+
var driver;
|
|
68
|
+
var flow;
|
|
69
|
+
var uncaughtExceptions;
|
|
70
|
+
|
|
71
|
+
beforeEach(function setUp() {
|
|
72
|
+
flow = promise.controlFlow();
|
|
73
|
+
uncaughtExceptions = [];
|
|
74
|
+
flow.on('uncaughtException', onUncaughtException);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
afterEach(function tearDown() {
|
|
78
|
+
return waitForIdle(flow).then(function() {
|
|
79
|
+
assert.deepEqual([], uncaughtExceptions);
|
|
80
|
+
flow.reset();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
function onUncaughtException(e) {
|
|
85
|
+
uncaughtExceptions.push(e);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function waitForIdle(opt_flow) {
|
|
89
|
+
var theFlow = opt_flow || flow;
|
|
90
|
+
return new Promise(function(fulfill, reject) {
|
|
91
|
+
if (theFlow.isIdle()) {
|
|
92
|
+
fulfill();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
theFlow.once('idle', fulfill);
|
|
96
|
+
theFlow.once('uncaughtException', reject);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function waitForAbort(opt_flow, opt_n) {
|
|
101
|
+
var n = opt_n || 1;
|
|
102
|
+
var theFlow = opt_flow || flow;
|
|
103
|
+
theFlow.removeAllListeners(
|
|
104
|
+
promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION);
|
|
105
|
+
return new Promise(function(fulfill, reject) {
|
|
106
|
+
theFlow.once('idle', function() {
|
|
107
|
+
reject(Error('expected flow to report an unhandled error'));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
var errors = [];
|
|
111
|
+
theFlow.on('uncaughtException', onError);
|
|
112
|
+
function onError(e) {
|
|
113
|
+
errors.push(e);
|
|
114
|
+
if (errors.length === n) {
|
|
115
|
+
theFlow.removeListener('uncaughtException', onError);
|
|
116
|
+
fulfill(n === 1 ? errors[0] : errors);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function expectedError(ctor, message) {
|
|
123
|
+
return function(e) {
|
|
124
|
+
assertIsInstance(ctor, e);
|
|
125
|
+
assert.equal(message, e.message);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
class Expectation {
|
|
130
|
+
constructor(executor, name, opt_parameters) {
|
|
131
|
+
this.executor_ = executor;
|
|
132
|
+
this.name_ = name;
|
|
133
|
+
this.times_ = 1;
|
|
134
|
+
this.sessionId_ = SESSION_ID;
|
|
135
|
+
this.check_ = null;
|
|
136
|
+
this.toDo_ = null;
|
|
137
|
+
this.withParameters(opt_parameters || {});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
anyTimes() {
|
|
141
|
+
this.times_ = Infinity;
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
times(n) {
|
|
146
|
+
this.times_ = n;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
withParameters(parameters) {
|
|
151
|
+
this.parameters_ = parameters;
|
|
152
|
+
if (this.name_ !== CName.NEW_SESSION) {
|
|
153
|
+
this.parameters_['sessionId'] = this.sessionId_;
|
|
154
|
+
}
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
andReturn(code, opt_value) {
|
|
159
|
+
this.toDo_ = function(command) {
|
|
160
|
+
LOG.info('executing ' + command.getName() + '; returning ' + code);
|
|
161
|
+
return Promise.resolve({
|
|
162
|
+
'status': code,
|
|
163
|
+
'sessionId': {
|
|
164
|
+
'value': SESSION_ID
|
|
165
|
+
},
|
|
166
|
+
'value': opt_value !== void(0) ? opt_value : null
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
andReturnSuccess(opt_value) {
|
|
173
|
+
return this.andReturn(0, opt_value);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
andReturnError(code, opt_value) {
|
|
177
|
+
return this.andReturn(code, opt_value);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
expect(name, opt_parameters) {
|
|
181
|
+
this.end();
|
|
182
|
+
return this.executor_.expect(name, opt_parameters);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
end() {
|
|
186
|
+
if (!this.toDo_) {
|
|
187
|
+
this.andReturnSuccess(null);
|
|
188
|
+
}
|
|
189
|
+
return this.executor_;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
execute(command) {
|
|
193
|
+
assert.deepEqual(this.parameters_, command.getParameters());
|
|
194
|
+
return this.toDo_(command);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
class FakeExecutor {
|
|
199
|
+
constructor() {
|
|
200
|
+
this.commands_ = new Map;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
execute(command) {
|
|
204
|
+
let expectations = this.commands_.get(command.getName());
|
|
205
|
+
if (!expectations || !expectations.length) {
|
|
206
|
+
assert.fail('unexpected command: ' + command.getName());
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
let next = expectations[0];
|
|
211
|
+
let result = next.execute(command);
|
|
212
|
+
if (next.times_ != Infinity) {
|
|
213
|
+
next.times_ -= 1;
|
|
214
|
+
if (!next.times_) {
|
|
215
|
+
expectations.shift();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
expect(commandName, opt_parameters) {
|
|
222
|
+
if (!this.commands_.has(commandName)) {
|
|
223
|
+
this.commands_.set(commandName, []);
|
|
224
|
+
}
|
|
225
|
+
let e = new Expectation(this, commandName, opt_parameters);
|
|
226
|
+
this.commands_.get(commandName).push(e);
|
|
227
|
+
return e;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
createDriver(opt_session) {
|
|
231
|
+
let session = opt_session || new Session(SESSION_ID, {});
|
|
232
|
+
return new WebDriver(session, this);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
238
|
+
//
|
|
239
|
+
// Tests
|
|
240
|
+
//
|
|
241
|
+
/////////////////////////////////////////////////////////////////////////////
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
describe('testAttachToSession', function() {
|
|
245
|
+
it('sessionIsAvailable', function() {
|
|
246
|
+
let executor = new FakeExecutor().
|
|
247
|
+
expect(CName.DESCRIBE_SESSION).
|
|
248
|
+
withParameters({'sessionId': SESSION_ID}).
|
|
249
|
+
andReturnSuccess({'browserName': 'firefox'}).
|
|
250
|
+
end();
|
|
251
|
+
|
|
252
|
+
let driver = WebDriver.attachToSession(executor, SESSION_ID);
|
|
253
|
+
return driver.getSession().then(function(session) {
|
|
254
|
+
assert.deepEqual({'value': 'test_session_id'}, session.getId());
|
|
255
|
+
assert.equal('firefox', session.getCapability('browserName'));
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('failsToGetSessionInfo', function() {
|
|
260
|
+
let executor = new FakeExecutor().
|
|
261
|
+
expect(CName.DESCRIBE_SESSION).
|
|
262
|
+
withParameters({'sessionId': SESSION_ID}).
|
|
263
|
+
andReturnError(ECode.UNKNOWN_ERROR, {'message': 'boom'}).
|
|
264
|
+
end();
|
|
265
|
+
|
|
266
|
+
let driver = WebDriver.attachToSession(executor, SESSION_ID);
|
|
267
|
+
return driver.getSession()
|
|
268
|
+
.then(() => assert.fail('should have failed!'), function(e) {
|
|
269
|
+
assertIsInstance(error.WebDriverError, e);
|
|
270
|
+
assert.equal('boom', e.message);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('usesActiveFlowByDefault', function() {
|
|
275
|
+
let executor = new FakeExecutor().
|
|
276
|
+
expect(CName.DESCRIBE_SESSION).
|
|
277
|
+
withParameters({'sessionId': SESSION_ID}).
|
|
278
|
+
andReturnSuccess({}).
|
|
279
|
+
end();
|
|
280
|
+
|
|
281
|
+
var driver = WebDriver.attachToSession(executor, SESSION_ID);
|
|
282
|
+
assert.equal(driver.controlFlow(), promise.controlFlow());
|
|
283
|
+
|
|
284
|
+
return waitForIdle(driver.controlFlow());
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('canAttachInCustomFlow', function() {
|
|
288
|
+
let executor = new FakeExecutor().
|
|
289
|
+
expect(CName.DESCRIBE_SESSION).
|
|
290
|
+
withParameters({'sessionId': SESSION_ID}).
|
|
291
|
+
andReturnSuccess({}).
|
|
292
|
+
end();
|
|
293
|
+
|
|
294
|
+
var otherFlow = new promise.ControlFlow();
|
|
295
|
+
var driver = WebDriver.attachToSession(executor, SESSION_ID, otherFlow);
|
|
296
|
+
assert.equal(otherFlow, driver.controlFlow());
|
|
297
|
+
assert.notEqual(otherFlow, promise.controlFlow());
|
|
298
|
+
|
|
299
|
+
return waitForIdle(otherFlow);
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
describe('testCreateSession', function() {
|
|
304
|
+
it('happyPathWithCapabilitiesHashObject', function() {
|
|
305
|
+
let executor = new FakeExecutor().
|
|
306
|
+
expect(CName.NEW_SESSION).
|
|
307
|
+
withParameters({
|
|
308
|
+
'desiredCapabilities': {'browserName': 'firefox'}
|
|
309
|
+
}).
|
|
310
|
+
andReturnSuccess({'browserName': 'firefox'}).
|
|
311
|
+
end();
|
|
312
|
+
|
|
313
|
+
var driver = WebDriver.createSession(executor, {
|
|
314
|
+
'browserName': 'firefox'
|
|
315
|
+
});
|
|
316
|
+
return driver.getSession().then(function(session) {
|
|
317
|
+
assert.deepEqual({
|
|
318
|
+
'value':'test_session_id'
|
|
319
|
+
}, session.getId());
|
|
320
|
+
assert.equal('firefox', session.getCapability('browserName'));
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('happyPathWithCapabilitiesInstance', function() {
|
|
325
|
+
let executor = new FakeExecutor().
|
|
326
|
+
expect(CName.NEW_SESSION).
|
|
327
|
+
withParameters({'desiredCapabilities': {'browserName': 'firefox'}}).
|
|
328
|
+
andReturnSuccess({'browserName': 'firefox'}).
|
|
329
|
+
end();
|
|
330
|
+
|
|
331
|
+
var driver = WebDriver.createSession(executor, Capabilities.firefox());
|
|
332
|
+
return driver.getSession().then(function(session) {
|
|
333
|
+
assert.deepEqual({'value':'test_session_id' }, session.getId());
|
|
334
|
+
assert.equal('firefox', session.getCapability('browserName'));
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it('failsToCreateSession', function() {
|
|
339
|
+
let executor = new FakeExecutor().
|
|
340
|
+
expect(CName.NEW_SESSION).
|
|
341
|
+
withParameters({'desiredCapabilities': {'browserName': 'firefox'}}).
|
|
342
|
+
andReturnError(ECode.UNKNOWN_ERROR, {'message': 'boom'}).
|
|
343
|
+
end();
|
|
344
|
+
|
|
345
|
+
var driver =
|
|
346
|
+
WebDriver.createSession(executor, {'browserName': 'firefox'});
|
|
347
|
+
return driver.getSession().then(fail, function(e) {
|
|
348
|
+
assertIsInstance(error.WebDriverError, e);
|
|
349
|
+
assert.equal('boom', e.message);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('usesActiveFlowByDefault', function() {
|
|
354
|
+
let executor = new FakeExecutor().
|
|
355
|
+
expect(CName.NEW_SESSION).
|
|
356
|
+
withParameters({'desiredCapabilities': {}}).
|
|
357
|
+
andReturnSuccess({}).
|
|
358
|
+
end();
|
|
359
|
+
|
|
360
|
+
var driver = WebDriver.createSession(executor, {});
|
|
361
|
+
assert.equal(promise.controlFlow(), driver.controlFlow());
|
|
362
|
+
|
|
363
|
+
return waitForIdle(driver.controlFlow());
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it('canCreateInCustomFlow', function() {
|
|
367
|
+
let executor = new FakeExecutor().
|
|
368
|
+
expect(CName.NEW_SESSION).
|
|
369
|
+
withParameters({'desiredCapabilities': {}}).
|
|
370
|
+
andReturnSuccess({}).
|
|
371
|
+
end();
|
|
372
|
+
|
|
373
|
+
var otherFlow = new promise.ControlFlow();
|
|
374
|
+
var driver = WebDriver.createSession(executor, {}, otherFlow);
|
|
375
|
+
assert.equal(otherFlow, driver.controlFlow());
|
|
376
|
+
assert.notEqual(otherFlow, promise.controlFlow());
|
|
377
|
+
|
|
378
|
+
return waitForIdle(otherFlow);
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('testDoesNotExecuteCommandIfSessionDoesNotResolve', function() {
|
|
383
|
+
var session = Promise.reject(new StubError);
|
|
384
|
+
new FakeExecutor().createDriver(session).getTitle();
|
|
385
|
+
return waitForAbort().then(assertIsStubError);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it('testCommandReturnValuesArePassedToFirstCallback', function() {
|
|
389
|
+
let executor = new FakeExecutor().
|
|
390
|
+
expect(CName.GET_TITLE).andReturnSuccess('Google Search').
|
|
391
|
+
end();
|
|
392
|
+
|
|
393
|
+
var driver = executor.createDriver();
|
|
394
|
+
return driver.getTitle().then(function(title) {
|
|
395
|
+
assert.equal('Google Search', title);
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it('testStopsCommandExecutionWhenAnErrorOccurs', function() {
|
|
400
|
+
let executor = new FakeExecutor().
|
|
401
|
+
expect(CName.SWITCH_TO_WINDOW).
|
|
402
|
+
withParameters({'name': 'foo'}).
|
|
403
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message': 'window not found'}).
|
|
404
|
+
end();
|
|
405
|
+
|
|
406
|
+
var driver = executor.createDriver();
|
|
407
|
+
driver.switchTo().window('foo');
|
|
408
|
+
driver.getTitle(); // mock should blow if this gets executed
|
|
409
|
+
|
|
410
|
+
return waitForAbort().
|
|
411
|
+
then(expectedError(error.NoSuchWindowError, 'window not found'));
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it('testCanSuppressCommandFailures', function() {
|
|
415
|
+
let executor = new FakeExecutor().
|
|
416
|
+
expect(CName.SWITCH_TO_WINDOW).
|
|
417
|
+
withParameters({'name': 'foo'}).
|
|
418
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message': 'window not found'}).
|
|
419
|
+
expect(CName.GET_TITLE).
|
|
420
|
+
andReturnSuccess('Google Search').
|
|
421
|
+
end();
|
|
422
|
+
|
|
423
|
+
var driver = executor.createDriver();
|
|
424
|
+
driver.switchTo().window('foo')
|
|
425
|
+
.thenCatch(expectedError(error.NoSuchWindowError, 'window not found'));
|
|
426
|
+
driver.getTitle();
|
|
427
|
+
return waitForIdle();
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it('testErrorsPropagateUpToTheRunningApplication', function() {
|
|
431
|
+
let executor = new FakeExecutor().
|
|
432
|
+
expect(CName.SWITCH_TO_WINDOW).
|
|
433
|
+
withParameters({'name':'foo'}).
|
|
434
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message': 'window not found'}).
|
|
435
|
+
end();
|
|
436
|
+
|
|
437
|
+
executor.createDriver().switchTo().window('foo');
|
|
438
|
+
return waitForAbort().
|
|
439
|
+
then(expectedError(error.NoSuchWindowError, 'window not found'));
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it('testErrbacksThatReturnErrorsStillSwitchToCallbackChain', function() {
|
|
443
|
+
let executor = new FakeExecutor().
|
|
444
|
+
expect(CName.SWITCH_TO_WINDOW).
|
|
445
|
+
withParameters({'name':'foo'}).
|
|
446
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message':'window not found'}).
|
|
447
|
+
end();
|
|
448
|
+
|
|
449
|
+
var driver = executor.createDriver();
|
|
450
|
+
return driver.switchTo().window('foo').
|
|
451
|
+
thenCatch(function() { return new StubError; });
|
|
452
|
+
then(assertIsStubError);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('testErrbacksThrownCanOverrideOriginalError', function() {
|
|
456
|
+
let executor = new FakeExecutor().
|
|
457
|
+
expect(CName.SWITCH_TO_WINDOW, {'name': 'foo'}).
|
|
458
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message':'window not found'}).
|
|
459
|
+
end();
|
|
460
|
+
|
|
461
|
+
var driver = executor.createDriver();
|
|
462
|
+
driver.switchTo().window('foo').thenCatch(throwStubError);
|
|
463
|
+
|
|
464
|
+
return waitForAbort().then(assertIsStubError);
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
it('testCannotScheduleCommandsIfTheSessionIdHasBeenDeleted', function() {
|
|
468
|
+
var driver = new FakeExecutor().createDriver();
|
|
469
|
+
delete driver.session_;
|
|
470
|
+
assert.throws(() => driver.get('http://www.google.com'));
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
it('testDeletesSessionIdAfterQuitting', function() {
|
|
474
|
+
var driver;
|
|
475
|
+
let executor = new FakeExecutor().
|
|
476
|
+
expect(CName.QUIT).
|
|
477
|
+
end();
|
|
478
|
+
|
|
479
|
+
driver = executor.createDriver();
|
|
480
|
+
return driver.quit().then(function() {
|
|
481
|
+
assert.equal(void 0, driver.session_);
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it('testReportsErrorWhenExecutingCommandsAfterExecutingAQuit', function() {
|
|
486
|
+
let executor = new FakeExecutor().
|
|
487
|
+
expect(CName.QUIT).
|
|
488
|
+
end();
|
|
489
|
+
|
|
490
|
+
var driver = executor.createDriver();
|
|
491
|
+
driver.quit();
|
|
492
|
+
driver.get('http://www.google.com');
|
|
493
|
+
return waitForAbort().
|
|
494
|
+
then(expectedError(
|
|
495
|
+
error.UnsupportedOperationError,
|
|
496
|
+
'This driver instance does not have a valid session ID ' +
|
|
497
|
+
'(did you call WebDriver.quit()?) and may no longer be used.'));
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it('testCallbackCommandsExecuteBeforeNextCommand', function() {
|
|
501
|
+
let executor = new FakeExecutor().
|
|
502
|
+
expect(CName.GET_CURRENT_URL).
|
|
503
|
+
expect(CName.GET, {'url': 'http://www.google.com'}).
|
|
504
|
+
expect(CName.CLOSE).
|
|
505
|
+
expect(CName.GET_TITLE).
|
|
506
|
+
end();
|
|
507
|
+
|
|
508
|
+
var driver = executor.createDriver();
|
|
509
|
+
driver.getCurrentUrl().then(function() {
|
|
510
|
+
driver.get('http://www.google.com').then(function() {
|
|
511
|
+
driver.close();
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
driver.getTitle();
|
|
515
|
+
|
|
516
|
+
return waitForIdle();
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
it('testEachCallbackFrameRunsToCompletionBeforeTheNext', function() {
|
|
520
|
+
let executor = new FakeExecutor().
|
|
521
|
+
expect(CName.GET_TITLE).
|
|
522
|
+
expect(CName.GET_CURRENT_URL).
|
|
523
|
+
expect(CName.GET_CURRENT_WINDOW_HANDLE).
|
|
524
|
+
expect(CName.CLOSE).
|
|
525
|
+
expect(CName.QUIT).
|
|
526
|
+
end();
|
|
527
|
+
|
|
528
|
+
var driver = executor.createDriver();
|
|
529
|
+
driver.getTitle().
|
|
530
|
+
// Everything in this callback...
|
|
531
|
+
then(function() {
|
|
532
|
+
driver.getCurrentUrl();
|
|
533
|
+
driver.getWindowHandle();
|
|
534
|
+
}).
|
|
535
|
+
// ...should execute before everything in this callback.
|
|
536
|
+
then(function() {
|
|
537
|
+
driver.close();
|
|
538
|
+
});
|
|
539
|
+
// This should execute after everything above
|
|
540
|
+
driver.quit();
|
|
541
|
+
|
|
542
|
+
return waitForIdle();
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
describe('nestedCommandFailures', function() {
|
|
546
|
+
it('bubbleUpToGlobalHandlerIfUnsuppressed', function() {
|
|
547
|
+
let executor = new FakeExecutor().
|
|
548
|
+
expect(CName.GET_TITLE).
|
|
549
|
+
expect(CName.SWITCH_TO_WINDOW, {'name': 'foo'}).
|
|
550
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message':'window not found'}).
|
|
551
|
+
end();
|
|
552
|
+
|
|
553
|
+
var driver = executor.createDriver();
|
|
554
|
+
driver.getTitle().then(function() {
|
|
555
|
+
driver.switchTo().window('foo');
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
return waitForAbort().
|
|
559
|
+
then(expectedError(error.NoSuchWindowError, 'window not found'));
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
it('canBeSuppressWhenTheyOccur', function() {
|
|
563
|
+
let executor = new FakeExecutor().
|
|
564
|
+
expect(CName.GET_TITLE).
|
|
565
|
+
expect(CName.SWITCH_TO_WINDOW, {'name':'foo'}).
|
|
566
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message':'window not found'}).
|
|
567
|
+
expect(CName.CLOSE).
|
|
568
|
+
end();
|
|
569
|
+
|
|
570
|
+
var driver = executor.createDriver();
|
|
571
|
+
driver.getTitle().then(function() {
|
|
572
|
+
driver.switchTo().window('foo').thenCatch(function() {});
|
|
573
|
+
});
|
|
574
|
+
driver.close();
|
|
575
|
+
|
|
576
|
+
return waitForIdle();
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
it('bubbleUpThroughTheFrameStack', function() {
|
|
580
|
+
let executor = new FakeExecutor().
|
|
581
|
+
expect(CName.GET_TITLE).
|
|
582
|
+
expect(CName.SWITCH_TO_WINDOW, {'name':'foo'}).
|
|
583
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message':'window not found'}).
|
|
584
|
+
end();
|
|
585
|
+
|
|
586
|
+
var driver = executor.createDriver();
|
|
587
|
+
driver.getTitle().
|
|
588
|
+
then(function() {
|
|
589
|
+
return driver.switchTo().window('foo');
|
|
590
|
+
}).
|
|
591
|
+
thenCatch(function(e) {
|
|
592
|
+
assertIsInstance(error.NoSuchWindowError, e);
|
|
593
|
+
assert.equal('window not found', e.message);
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
return waitForIdle();
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
it('canBeCaughtAndSuppressed', function() {
|
|
600
|
+
let executor = new FakeExecutor().
|
|
601
|
+
expect(CName.GET_TITLE).
|
|
602
|
+
expect(CName.GET_CURRENT_URL).
|
|
603
|
+
expect(CName.SWITCH_TO_WINDOW, {'name':'foo'}).
|
|
604
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message':'window not found'}).
|
|
605
|
+
expect(CName.CLOSE).
|
|
606
|
+
end();
|
|
607
|
+
|
|
608
|
+
var driver = executor.createDriver();
|
|
609
|
+
driver.getTitle().then(function() {
|
|
610
|
+
driver.getCurrentUrl().
|
|
611
|
+
then(function() {
|
|
612
|
+
return driver.switchTo().window('foo');
|
|
613
|
+
}).
|
|
614
|
+
thenCatch(function() {});
|
|
615
|
+
driver.close();
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
return waitForIdle();
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
describe('returningAPromise', function() {
|
|
623
|
+
it('fromACallback', function() {
|
|
624
|
+
let executor = new FakeExecutor().
|
|
625
|
+
expect(CName.GET_TITLE).
|
|
626
|
+
expect(CName.GET_CURRENT_URL).
|
|
627
|
+
andReturnSuccess('http://www.google.com').
|
|
628
|
+
end();
|
|
629
|
+
|
|
630
|
+
var driver = executor.createDriver();
|
|
631
|
+
driver.getTitle().
|
|
632
|
+
then(function() {
|
|
633
|
+
return driver.getCurrentUrl();
|
|
634
|
+
}).
|
|
635
|
+
then(function(value) {
|
|
636
|
+
assert.equal('http://www.google.com', value);
|
|
637
|
+
});
|
|
638
|
+
return waitForIdle();
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
it('fromAnErrbackSuppressesTheError', function() {
|
|
642
|
+
var count = 0;
|
|
643
|
+
let executor = new FakeExecutor().
|
|
644
|
+
expect(CName.SWITCH_TO_WINDOW, {'name':'foo'}).
|
|
645
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message':'window not found'}).
|
|
646
|
+
expect(CName.GET_CURRENT_URL).
|
|
647
|
+
andReturnSuccess('http://www.google.com').
|
|
648
|
+
end();
|
|
649
|
+
|
|
650
|
+
var driver = executor.createDriver();
|
|
651
|
+
driver.switchTo().window('foo').
|
|
652
|
+
thenCatch(function(e) {
|
|
653
|
+
assertIsInstance(error.NoSuchWindowError, e);
|
|
654
|
+
assert.equal('window not found', e.message);
|
|
655
|
+
count += 1;
|
|
656
|
+
return driver.getCurrentUrl();
|
|
657
|
+
}).
|
|
658
|
+
then(function(url) {
|
|
659
|
+
count += 1;
|
|
660
|
+
assert.equal('http://www.google.com', url);
|
|
661
|
+
});
|
|
662
|
+
return waitForIdle().then(function() {
|
|
663
|
+
assert.equal(2, count);
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
describe('customFunctions', function() {
|
|
669
|
+
it('returnsANonPromiseValue', function() {
|
|
670
|
+
var driver = new FakeExecutor().createDriver();
|
|
671
|
+
return driver.call(() => 'abc123').then(function(value) {
|
|
672
|
+
assert.equal('abc123', value);
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
|
|
676
|
+
it('executionOrderWithCustomFunctions', function() {
|
|
677
|
+
var msg = [];
|
|
678
|
+
let executor = new FakeExecutor().
|
|
679
|
+
expect(CName.GET_TITLE).andReturnSuccess('cheese ').
|
|
680
|
+
expect(CName.GET_CURRENT_URL).andReturnSuccess('tasty').
|
|
681
|
+
end();
|
|
682
|
+
|
|
683
|
+
var driver = executor.createDriver();
|
|
684
|
+
|
|
685
|
+
var pushMsg = msg.push.bind(msg);
|
|
686
|
+
driver.getTitle().then(pushMsg);
|
|
687
|
+
driver.call(() => 'is ').then(pushMsg);
|
|
688
|
+
driver.getCurrentUrl().then(pushMsg);
|
|
689
|
+
driver.call(() => '!').then(pushMsg);
|
|
690
|
+
|
|
691
|
+
return waitForIdle().then(function() {
|
|
692
|
+
assert.equal('cheese is tasty!', msg.join(''));
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
it('passingArgumentsToACustomFunction', function() {
|
|
697
|
+
var add = function(a, b) {
|
|
698
|
+
return a + b;
|
|
699
|
+
};
|
|
700
|
+
var driver = new FakeExecutor().createDriver();
|
|
701
|
+
return driver.call(add, null, 1, 2).then(function(value) {
|
|
702
|
+
assert.equal(3, value);
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
it('passingPromisedArgumentsToACustomFunction', function() {
|
|
707
|
+
var promisedArg = promise.fulfilled(2);
|
|
708
|
+
var add = function(a, b) {
|
|
709
|
+
return a + b;
|
|
710
|
+
};
|
|
711
|
+
var driver = new FakeExecutor().createDriver();
|
|
712
|
+
return driver.call(add, null, 1, promisedArg).then(function(value) {
|
|
713
|
+
assert.equal(3, value);
|
|
714
|
+
});
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
it('passingArgumentsAndScopeToACustomFunction', function() {
|
|
718
|
+
function Foo(name) {
|
|
719
|
+
this.name = name;
|
|
720
|
+
}
|
|
721
|
+
Foo.prototype.getName = function() {
|
|
722
|
+
return this.name;
|
|
723
|
+
};
|
|
724
|
+
var foo = new Foo('foo');
|
|
725
|
+
|
|
726
|
+
var driver = new FakeExecutor().createDriver();
|
|
727
|
+
return driver.call(foo.getName, foo).then(function(value) {
|
|
728
|
+
assert.equal('foo', value);
|
|
729
|
+
});
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
it('customFunctionThrowsAnError', function() {
|
|
733
|
+
var driver = new FakeExecutor().createDriver();
|
|
734
|
+
return driver.call(throwStubError).then(fail, assertIsStubError);
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
it('customFunctionSchedulesCommands', function() {
|
|
738
|
+
let executor = new FakeExecutor().
|
|
739
|
+
expect(CName.GET_TITLE).
|
|
740
|
+
expect(CName.CLOSE).
|
|
741
|
+
expect(CName.QUIT).
|
|
742
|
+
end();
|
|
743
|
+
|
|
744
|
+
var driver = executor.createDriver();
|
|
745
|
+
driver.call(function() {
|
|
746
|
+
driver.getTitle();
|
|
747
|
+
driver.close();
|
|
748
|
+
});
|
|
749
|
+
driver.quit();
|
|
750
|
+
return waitForIdle();
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
it('returnsATaskResultAfterSchedulingAnother', function() {
|
|
754
|
+
let executor = new FakeExecutor().
|
|
755
|
+
expect(CName.GET_TITLE).
|
|
756
|
+
andReturnSuccess('Google Search').
|
|
757
|
+
expect(CName.CLOSE).
|
|
758
|
+
end();
|
|
759
|
+
|
|
760
|
+
var driver = executor.createDriver();
|
|
761
|
+
return driver.call(function() {
|
|
762
|
+
var title = driver.getTitle();
|
|
763
|
+
driver.close();
|
|
764
|
+
return title;
|
|
765
|
+
}).then(function(title) {
|
|
766
|
+
assert.equal('Google Search', title);
|
|
767
|
+
});
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
it('hasANestedCommandThatFails', function() {
|
|
771
|
+
let executor = new FakeExecutor().
|
|
772
|
+
expect(CName.SWITCH_TO_WINDOW, {'name': 'foo'}).
|
|
773
|
+
andReturnError(ECode.NO_SUCH_WINDOW, {'message':'window not found'}).
|
|
774
|
+
end();
|
|
775
|
+
|
|
776
|
+
var driver = executor.createDriver();
|
|
777
|
+
return driver.call(function() {
|
|
778
|
+
return driver.switchTo().window('foo');
|
|
779
|
+
}).then(fail, function(e) {
|
|
780
|
+
assertIsInstance(error.NoSuchWindowError, e);
|
|
781
|
+
assert.equal('window not found', e.message);
|
|
782
|
+
});
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
it('doesNotCompleteUntilReturnedPromiseIsResolved', function() {
|
|
786
|
+
var order = [];
|
|
787
|
+
var driver = new FakeExecutor().createDriver();
|
|
788
|
+
|
|
789
|
+
var d = promise.defer();
|
|
790
|
+
d.promise.then(function() {
|
|
791
|
+
order.push('b');
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
driver.call(function() {
|
|
795
|
+
order.push('a');
|
|
796
|
+
return d.promise;
|
|
797
|
+
});
|
|
798
|
+
driver.call(function() {
|
|
799
|
+
order.push('c');
|
|
800
|
+
});
|
|
801
|
+
|
|
802
|
+
// timeout to ensure the first function starts its execution before we
|
|
803
|
+
// trigger d's callbacks.
|
|
804
|
+
return new Promise(f => setTimeout(f, 0)).then(function() {
|
|
805
|
+
assert.deepEqual(['a'], order);
|
|
806
|
+
d.fulfill();
|
|
807
|
+
return waitForIdle().then(function() {
|
|
808
|
+
assert.deepEqual(['a', 'b', 'c'], order);
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
it('returnsADeferredAction', function() {
|
|
814
|
+
let executor = new FakeExecutor().
|
|
815
|
+
expect(CName.GET_TITLE).andReturnSuccess('Google').
|
|
816
|
+
end();
|
|
817
|
+
|
|
818
|
+
var driver = executor.createDriver();
|
|
819
|
+
driver.call(function() {
|
|
820
|
+
return driver.getTitle();
|
|
821
|
+
}).then(function(title) {
|
|
822
|
+
assert.equal('Google', title);
|
|
823
|
+
});
|
|
824
|
+
return waitForIdle();
|
|
825
|
+
});
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
describe('nestedCommands', function() {
|
|
829
|
+
it('commandExecutionOrder', function() {
|
|
830
|
+
var msg = [];
|
|
831
|
+
var driver = new FakeExecutor().createDriver();
|
|
832
|
+
driver.call(msg.push, msg, 'a');
|
|
833
|
+
driver.call(function() {
|
|
834
|
+
driver.call(msg.push, msg, 'c');
|
|
835
|
+
driver.call(function() {
|
|
836
|
+
driver.call(msg.push, msg, 'e');
|
|
837
|
+
driver.call(msg.push, msg, 'f');
|
|
838
|
+
});
|
|
839
|
+
driver.call(msg.push, msg, 'd');
|
|
840
|
+
});
|
|
841
|
+
driver.call(msg.push, msg, 'b');
|
|
842
|
+
return waitForIdle().then(function() {
|
|
843
|
+
assert.equal('acefdb', msg.join(''));
|
|
844
|
+
});
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
it('basicUsage', function() {
|
|
848
|
+
var msg = [];
|
|
849
|
+
var driver = new FakeExecutor().createDriver();
|
|
850
|
+
var pushMsg = msg.push.bind(msg);
|
|
851
|
+
driver.call(() => 'cheese ').then(pushMsg);
|
|
852
|
+
driver.call(function() {
|
|
853
|
+
driver.call(() => 'is ').then(pushMsg);
|
|
854
|
+
driver.call(() => 'tasty').then(pushMsg);
|
|
855
|
+
});
|
|
856
|
+
driver.call(() => '!').then(pushMsg);
|
|
857
|
+
return waitForIdle().then(function() {
|
|
858
|
+
assert.equal('cheese is tasty!', msg.join(''));
|
|
859
|
+
});
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
it('canReturnValueFromNestedFunction', function() {
|
|
863
|
+
var driver = new FakeExecutor().createDriver();
|
|
864
|
+
return driver.call(function() {
|
|
865
|
+
return driver.call(function() {
|
|
866
|
+
return driver.call(() => 'foobar');
|
|
867
|
+
});
|
|
868
|
+
}).then(function(value) {
|
|
869
|
+
assert.equal('foobar', value);
|
|
870
|
+
});
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
it('normalCommandAfterNestedCommandThatReturnsAnAction', function() {
|
|
874
|
+
var msg = [];
|
|
875
|
+
let executor = new FakeExecutor().
|
|
876
|
+
expect(CName.CLOSE).
|
|
877
|
+
end();
|
|
878
|
+
var driver = executor.createDriver();
|
|
879
|
+
driver.call(function() {
|
|
880
|
+
return driver.call(function() {
|
|
881
|
+
msg.push('a');
|
|
882
|
+
return driver.call(() => 'foobar');
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
driver.close().then(function() {
|
|
886
|
+
msg.push('b');
|
|
887
|
+
});
|
|
888
|
+
return waitForIdle().then(function() {
|
|
889
|
+
assert.equal('ab', msg.join(''));
|
|
890
|
+
});
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
it('errorsBubbleUp_caught', function() {
|
|
894
|
+
var driver = new FakeExecutor().createDriver();
|
|
895
|
+
var result = driver.call(function() {
|
|
896
|
+
return driver.call(function() {
|
|
897
|
+
return driver.call(throwStubError);
|
|
898
|
+
});
|
|
899
|
+
}).then(fail, assertIsStubError);
|
|
900
|
+
return Promise.all([waitForIdle(), result]);
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
it('errorsBubbleUp_uncaught', function() {
|
|
904
|
+
var driver = new FakeExecutor().createDriver();
|
|
905
|
+
driver.call(function() {
|
|
906
|
+
return driver.call(function() {
|
|
907
|
+
return driver.call(throwStubError);
|
|
908
|
+
});
|
|
909
|
+
});
|
|
910
|
+
return waitForAbort().then(assertIsStubError);
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
it('canScheduleCommands', function() {
|
|
914
|
+
let executor = new FakeExecutor().
|
|
915
|
+
expect(CName.GET_TITLE).
|
|
916
|
+
expect(CName.CLOSE).
|
|
917
|
+
end();
|
|
918
|
+
|
|
919
|
+
var driver = executor.createDriver();
|
|
920
|
+
driver.call(function() {
|
|
921
|
+
driver.call(function() {
|
|
922
|
+
driver.getTitle();
|
|
923
|
+
});
|
|
924
|
+
driver.close();
|
|
925
|
+
});
|
|
926
|
+
return waitForIdle();
|
|
927
|
+
});
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
describe('WebElementPromise', function() {
|
|
931
|
+
it('resolvesWhenUnderlyingElementDoes', function() {
|
|
932
|
+
var el = new WebElement({}, {'ELEMENT': 'foo'});
|
|
933
|
+
return new WebElementPromise({}, promise.fulfilled(el)).then(function(e) {
|
|
934
|
+
assert.strictEqual(e, el);
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
it('resolvesBeforeCallbacksOnWireValueTrigger', function() {
|
|
939
|
+
var el = new promise.Deferred();
|
|
940
|
+
|
|
941
|
+
var element = new WebElementPromise({}, el.promise);
|
|
942
|
+
var messages = [];
|
|
943
|
+
|
|
944
|
+
element.then(function() {
|
|
945
|
+
messages.push('element resolved');
|
|
946
|
+
});
|
|
947
|
+
element.getId().then(function() {
|
|
948
|
+
messages.push('wire value resolved');
|
|
949
|
+
});
|
|
950
|
+
|
|
951
|
+
assert.deepEqual([], messages);
|
|
952
|
+
el.fulfill(new WebElement({}, {'ELEMENT': 'foo'}));
|
|
953
|
+
return waitForIdle().then(function() {
|
|
954
|
+
assert.deepEqual([
|
|
955
|
+
'element resolved',
|
|
956
|
+
'wire value resolved'
|
|
957
|
+
], messages);
|
|
958
|
+
});
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
it('isRejectedIfUnderlyingIdIsRejected', function() {
|
|
962
|
+
var element = new WebElementPromise({}, promise.rejected(new StubError));
|
|
963
|
+
return element.then(fail, assertIsStubError);
|
|
964
|
+
});
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
describe('executeScript', function() {
|
|
968
|
+
it('nullReturnValue', function() {
|
|
969
|
+
let executor = new FakeExecutor().
|
|
970
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
971
|
+
withParameters({
|
|
972
|
+
'script': 'return document.body;',
|
|
973
|
+
'args': []
|
|
974
|
+
}).
|
|
975
|
+
andReturnSuccess(null).
|
|
976
|
+
end();
|
|
977
|
+
|
|
978
|
+
var driver = executor.createDriver();
|
|
979
|
+
return driver.executeScript('return document.body;')
|
|
980
|
+
.then((result) => assert.equal(null, result));
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
it('primitiveReturnValue', function() {
|
|
984
|
+
let executor = new FakeExecutor().
|
|
985
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
986
|
+
withParameters({
|
|
987
|
+
'script': 'return document.body;',
|
|
988
|
+
'args': []
|
|
989
|
+
}).
|
|
990
|
+
andReturnSuccess(123).
|
|
991
|
+
end();
|
|
992
|
+
|
|
993
|
+
var driver = executor.createDriver();
|
|
994
|
+
return driver.executeScript('return document.body;')
|
|
995
|
+
.then((result) => assert.equal(123, result));
|
|
996
|
+
});
|
|
997
|
+
|
|
998
|
+
it('webElementReturnValue', function() {
|
|
999
|
+
var json = WebElement.buildId('foo');
|
|
1000
|
+
|
|
1001
|
+
let executor = new FakeExecutor().
|
|
1002
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
1003
|
+
withParameters({
|
|
1004
|
+
'script': 'return document.body;',
|
|
1005
|
+
'args': []
|
|
1006
|
+
}).
|
|
1007
|
+
andReturnSuccess(json).
|
|
1008
|
+
end();
|
|
1009
|
+
|
|
1010
|
+
var driver = executor.createDriver();
|
|
1011
|
+
return driver.executeScript('return document.body;')
|
|
1012
|
+
.then((element) => element.getId())
|
|
1013
|
+
.then((id) => assert.equal(id, 'foo'));
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
it('arrayReturnValue', function() {
|
|
1017
|
+
var json = [WebElement.buildId('foo')];
|
|
1018
|
+
|
|
1019
|
+
let executor = new FakeExecutor().
|
|
1020
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
1021
|
+
withParameters({
|
|
1022
|
+
'script': 'return document.body;',
|
|
1023
|
+
'args': []
|
|
1024
|
+
}).
|
|
1025
|
+
andReturnSuccess(json).
|
|
1026
|
+
end();
|
|
1027
|
+
|
|
1028
|
+
var driver = executor.createDriver();
|
|
1029
|
+
return driver.executeScript('return document.body;')
|
|
1030
|
+
.then(function(array) {
|
|
1031
|
+
assert.equal(1, array.length);
|
|
1032
|
+
return array[0].getId();
|
|
1033
|
+
})
|
|
1034
|
+
.then((id) => assert.equal('foo', id));
|
|
1035
|
+
});
|
|
1036
|
+
|
|
1037
|
+
it('objectReturnValue', function() {
|
|
1038
|
+
var json = {'foo': WebElement.buildId('foo')};
|
|
1039
|
+
|
|
1040
|
+
let executor = new FakeExecutor().
|
|
1041
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
1042
|
+
withParameters({
|
|
1043
|
+
'script': 'return document.body;',
|
|
1044
|
+
'args': []
|
|
1045
|
+
}).
|
|
1046
|
+
andReturnSuccess(json).
|
|
1047
|
+
end();
|
|
1048
|
+
|
|
1049
|
+
var driver = executor.createDriver();
|
|
1050
|
+
var callback;
|
|
1051
|
+
return driver.executeScript('return document.body;')
|
|
1052
|
+
.then((obj) => obj['foo'].getId())
|
|
1053
|
+
.then((id) => assert.equal(id, 'foo'));
|
|
1054
|
+
});
|
|
1055
|
+
|
|
1056
|
+
it('scriptAsFunction', function() {
|
|
1057
|
+
let executor = new FakeExecutor().
|
|
1058
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
1059
|
+
withParameters({
|
|
1060
|
+
'script': 'return (' + function() {} +
|
|
1061
|
+
').apply(null, arguments);',
|
|
1062
|
+
'args': []
|
|
1063
|
+
}).
|
|
1064
|
+
andReturnSuccess(null).
|
|
1065
|
+
end();
|
|
1066
|
+
|
|
1067
|
+
var driver = executor.createDriver();
|
|
1068
|
+
return driver.executeScript(function() {});
|
|
1069
|
+
});
|
|
1070
|
+
|
|
1071
|
+
it('simpleArgumentConversion', function() {
|
|
1072
|
+
let executor = new FakeExecutor().
|
|
1073
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
1074
|
+
withParameters({
|
|
1075
|
+
'script': 'return 1;',
|
|
1076
|
+
'args': ['abc', 123, true, [123, {'foo': 'bar'}]]
|
|
1077
|
+
}).
|
|
1078
|
+
andReturnSuccess(null).
|
|
1079
|
+
end();
|
|
1080
|
+
|
|
1081
|
+
var driver = executor.createDriver();
|
|
1082
|
+
return driver.executeScript(
|
|
1083
|
+
'return 1;', 'abc', 123, true, [123, {'foo': 'bar'}]);
|
|
1084
|
+
});
|
|
1085
|
+
|
|
1086
|
+
it('webElementArgumentConversion', function() {
|
|
1087
|
+
var elementJson = WebElement.buildId('fefifofum');
|
|
1088
|
+
|
|
1089
|
+
let executor = new FakeExecutor().
|
|
1090
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
1091
|
+
withParameters({
|
|
1092
|
+
'script': 'return 1;',
|
|
1093
|
+
'args': [elementJson]
|
|
1094
|
+
}).
|
|
1095
|
+
andReturnSuccess(null).
|
|
1096
|
+
end();
|
|
1097
|
+
|
|
1098
|
+
var driver = executor.createDriver();
|
|
1099
|
+
return driver.executeScript('return 1;',
|
|
1100
|
+
new WebElement(driver, 'fefifofum'));
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
it('webElementPromiseArgumentConversion', function() {
|
|
1104
|
+
var elementJson = WebElement.buildId('bar');
|
|
1105
|
+
|
|
1106
|
+
let executor = new FakeExecutor().
|
|
1107
|
+
expect(CName.FIND_ELEMENT,
|
|
1108
|
+
{'using': 'css selector', 'value': '*[id="foo"]'}).
|
|
1109
|
+
andReturnSuccess(elementJson).
|
|
1110
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
1111
|
+
withParameters({
|
|
1112
|
+
'script': 'return 1;',
|
|
1113
|
+
'args': [elementJson]
|
|
1114
|
+
}).
|
|
1115
|
+
andReturnSuccess(null).
|
|
1116
|
+
end();
|
|
1117
|
+
|
|
1118
|
+
var driver = executor.createDriver();
|
|
1119
|
+
var element = driver.findElement(By.id('foo'));
|
|
1120
|
+
return driver.executeScript('return 1;', element);
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1123
|
+
it('argumentConversion', function() {
|
|
1124
|
+
var elementJson = WebElement.buildId('fefifofum');
|
|
1125
|
+
|
|
1126
|
+
let executor = new FakeExecutor().
|
|
1127
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
1128
|
+
withParameters({
|
|
1129
|
+
'script': 'return 1;',
|
|
1130
|
+
'args': ['abc', 123, true, elementJson, [123, {'foo': 'bar'}]]
|
|
1131
|
+
}).
|
|
1132
|
+
andReturnSuccess(null).
|
|
1133
|
+
end();
|
|
1134
|
+
|
|
1135
|
+
var driver = executor.createDriver();
|
|
1136
|
+
var element = new WebElement(driver, 'fefifofum');
|
|
1137
|
+
return driver.executeScript('return 1;',
|
|
1138
|
+
'abc', 123, true, element, [123, {'foo': 'bar'}]);
|
|
1139
|
+
});
|
|
1140
|
+
|
|
1141
|
+
it('scriptReturnsAnError', function() {
|
|
1142
|
+
let executor = new FakeExecutor().
|
|
1143
|
+
expect(CName.EXECUTE_SCRIPT).
|
|
1144
|
+
withParameters({
|
|
1145
|
+
'script': 'throw Error(arguments[0]);',
|
|
1146
|
+
'args': ['bam']
|
|
1147
|
+
}).
|
|
1148
|
+
andReturnError(ECode.UNKNOWN_ERROR, {'message':'bam'}).
|
|
1149
|
+
end();
|
|
1150
|
+
var driver = executor.createDriver();
|
|
1151
|
+
return driver.executeScript('throw Error(arguments[0]);', 'bam').
|
|
1152
|
+
then(fail, function(e) {
|
|
1153
|
+
assertIsInstance(error.WebDriverError, e);
|
|
1154
|
+
assert.equal('bam', e.message);
|
|
1155
|
+
});
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
it('failsIfArgumentIsARejectedPromise', function() {
|
|
1159
|
+
let executor = new FakeExecutor();
|
|
1160
|
+
|
|
1161
|
+
var arg = promise.rejected(new StubError);
|
|
1162
|
+
arg.thenCatch(function() {}); // Suppress default handler.
|
|
1163
|
+
|
|
1164
|
+
var driver = executor.createDriver();
|
|
1165
|
+
return driver.executeScript(function() {}, arg).
|
|
1166
|
+
then(fail, assertIsStubError);
|
|
1167
|
+
});
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
describe('executeAsyncScript', function() {
|
|
1171
|
+
it('failsIfArgumentIsARejectedPromise', function() {
|
|
1172
|
+
var arg = promise.rejected(new StubError);
|
|
1173
|
+
arg.thenCatch(function() {}); // Suppress default handler.
|
|
1174
|
+
|
|
1175
|
+
var driver = new FakeExecutor().createDriver();
|
|
1176
|
+
return driver.executeAsyncScript(function() {}, arg).
|
|
1177
|
+
then(fail, assertIsStubError);
|
|
1178
|
+
});
|
|
1179
|
+
});
|
|
1180
|
+
|
|
1181
|
+
describe('findElement', function() {
|
|
1182
|
+
it('elementNotFound', function() {
|
|
1183
|
+
let executor = new FakeExecutor().
|
|
1184
|
+
expect(CName.FIND_ELEMENT,
|
|
1185
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1186
|
+
andReturnError(ECode.NO_SUCH_ELEMENT, {
|
|
1187
|
+
'message':'Unable to find element'
|
|
1188
|
+
}).
|
|
1189
|
+
end();
|
|
1190
|
+
|
|
1191
|
+
var driver = executor.createDriver();
|
|
1192
|
+
var element = driver.findElement(By.id('foo'));
|
|
1193
|
+
element.click(); // This should never execute.
|
|
1194
|
+
return waitForAbort().then(function(e) {
|
|
1195
|
+
assertIsInstance(error.NoSuchElementError, e);
|
|
1196
|
+
assert.equal('Unable to find element', e.message);
|
|
1197
|
+
});
|
|
1198
|
+
});
|
|
1199
|
+
|
|
1200
|
+
it('elementNotFoundInACallback', function() {
|
|
1201
|
+
let executor = new FakeExecutor().
|
|
1202
|
+
expect(CName.FIND_ELEMENT,
|
|
1203
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1204
|
+
andReturnError(
|
|
1205
|
+
ECode.NO_SUCH_ELEMENT, {'message':'Unable to find element'}).
|
|
1206
|
+
end();
|
|
1207
|
+
|
|
1208
|
+
var driver = executor.createDriver();
|
|
1209
|
+
promise.fulfilled().then(function() {
|
|
1210
|
+
var element = driver.findElement(By.id('foo'));
|
|
1211
|
+
return element.click(); // Should not execute.
|
|
1212
|
+
});
|
|
1213
|
+
return waitForAbort().then(function(e) {
|
|
1214
|
+
assertIsInstance(error.NoSuchElementError, e);
|
|
1215
|
+
assert.equal('Unable to find element', e.message);
|
|
1216
|
+
});
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1219
|
+
it('elementFound', function() {
|
|
1220
|
+
let executor = new FakeExecutor().
|
|
1221
|
+
expect(CName.FIND_ELEMENT,
|
|
1222
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1223
|
+
andReturnSuccess(WebElement.buildId('bar')).
|
|
1224
|
+
expect(CName.CLICK_ELEMENT, {'id': 'bar'}).
|
|
1225
|
+
andReturnSuccess().
|
|
1226
|
+
end();
|
|
1227
|
+
|
|
1228
|
+
var driver = executor.createDriver();
|
|
1229
|
+
var element = driver.findElement(By.id('foo'));
|
|
1230
|
+
element.click();
|
|
1231
|
+
return waitForIdle();
|
|
1232
|
+
});
|
|
1233
|
+
|
|
1234
|
+
it('canUseElementInCallback', function() {
|
|
1235
|
+
let executor = new FakeExecutor().
|
|
1236
|
+
expect(CName.FIND_ELEMENT,
|
|
1237
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1238
|
+
andReturnSuccess(WebElement.buildId('bar')).
|
|
1239
|
+
expect(CName.CLICK_ELEMENT, {'id': 'bar'}).
|
|
1240
|
+
andReturnSuccess().
|
|
1241
|
+
end();
|
|
1242
|
+
|
|
1243
|
+
var driver = executor.createDriver();
|
|
1244
|
+
driver.findElement(By.id('foo')).then(function(element) {
|
|
1245
|
+
element.click();
|
|
1246
|
+
});
|
|
1247
|
+
return waitForIdle();
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1250
|
+
it('byJs', function() {
|
|
1251
|
+
let executor = new FakeExecutor().
|
|
1252
|
+
expect(CName.EXECUTE_SCRIPT, {
|
|
1253
|
+
'script': 'return document.body',
|
|
1254
|
+
'args': []
|
|
1255
|
+
}).
|
|
1256
|
+
andReturnSuccess(WebElement.buildId('bar')).
|
|
1257
|
+
expect(CName.CLICK_ELEMENT, {'id': 'bar'}).
|
|
1258
|
+
end();
|
|
1259
|
+
|
|
1260
|
+
var driver = executor.createDriver();
|
|
1261
|
+
var element = driver.findElement(By.js('return document.body'));
|
|
1262
|
+
element.click(); // just to make sure
|
|
1263
|
+
return waitForIdle();
|
|
1264
|
+
});
|
|
1265
|
+
|
|
1266
|
+
it('byJs_returnsNonWebElementValue', function() {
|
|
1267
|
+
let executor = new FakeExecutor().
|
|
1268
|
+
expect(CName.EXECUTE_SCRIPT, {'script': 'return 123', 'args': []}).
|
|
1269
|
+
andReturnSuccess(123).
|
|
1270
|
+
end();
|
|
1271
|
+
|
|
1272
|
+
var driver = executor.createDriver();
|
|
1273
|
+
var element = driver.findElement(By.js('return 123'));
|
|
1274
|
+
element.click(); // Should not execute.
|
|
1275
|
+
return waitForAbort().then(function(e) {
|
|
1276
|
+
assertIsInstance(TypeError, e);
|
|
1277
|
+
assert.equal('Custom locator did not return a WebElement', e.message);
|
|
1278
|
+
});
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
it('byJs_canPassArguments', function() {
|
|
1282
|
+
var script = 'return document.getElementsByTagName(arguments[0]);';
|
|
1283
|
+
let executor = new FakeExecutor().
|
|
1284
|
+
expect(CName.EXECUTE_SCRIPT, {
|
|
1285
|
+
'script': script,
|
|
1286
|
+
'args': ['div']
|
|
1287
|
+
}).
|
|
1288
|
+
andReturnSuccess({'ELEMENT':'one'}).
|
|
1289
|
+
end();
|
|
1290
|
+
var driver = executor.createDriver();
|
|
1291
|
+
driver.findElement(By.js(script, 'div'));
|
|
1292
|
+
return waitForIdle();
|
|
1293
|
+
});
|
|
1294
|
+
|
|
1295
|
+
it('customLocator', function() {
|
|
1296
|
+
let executor = new FakeExecutor().
|
|
1297
|
+
expect(CName.FIND_ELEMENTS, {'using': 'css selector', 'value': 'a'}).
|
|
1298
|
+
andReturnSuccess([
|
|
1299
|
+
WebElement.buildId('foo'),
|
|
1300
|
+
WebElement.buildId('bar')]).
|
|
1301
|
+
expect(CName.CLICK_ELEMENT, {'id': 'foo'}).
|
|
1302
|
+
andReturnSuccess().
|
|
1303
|
+
end();
|
|
1304
|
+
|
|
1305
|
+
var driver = executor.createDriver();
|
|
1306
|
+
var element = driver.findElement(function(d) {
|
|
1307
|
+
assert.equal(driver, d);
|
|
1308
|
+
return d.findElements(By.tagName('a'));
|
|
1309
|
+
});
|
|
1310
|
+
element.click();
|
|
1311
|
+
return waitForIdle();
|
|
1312
|
+
});
|
|
1313
|
+
|
|
1314
|
+
it('customLocatorThrowsIfresultIsNotAWebElement', function() {
|
|
1315
|
+
var driver = new FakeExecutor().createDriver();
|
|
1316
|
+
driver.findElement(function() {
|
|
1317
|
+
return 1;
|
|
1318
|
+
});
|
|
1319
|
+
return waitForAbort().then(function(e) {
|
|
1320
|
+
assertIsInstance(TypeError, e);
|
|
1321
|
+
assert.equal('Custom locator did not return a WebElement', e.message);
|
|
1322
|
+
});
|
|
1323
|
+
});
|
|
1324
|
+
});
|
|
1325
|
+
|
|
1326
|
+
describe('isElementPresent', function() {
|
|
1327
|
+
it('elementNotFound', function() {
|
|
1328
|
+
let executor = new FakeExecutor().
|
|
1329
|
+
expect(CName.FIND_ELEMENTS,
|
|
1330
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1331
|
+
andReturnSuccess([]).
|
|
1332
|
+
end();
|
|
1333
|
+
|
|
1334
|
+
var driver = executor.createDriver();
|
|
1335
|
+
return driver.isElementPresent(By.id('foo'))
|
|
1336
|
+
.then((found) => assert.ok(!found));
|
|
1337
|
+
});
|
|
1338
|
+
|
|
1339
|
+
it('elementFound', function() {
|
|
1340
|
+
let executor = new FakeExecutor().
|
|
1341
|
+
expect(CName.FIND_ELEMENTS,
|
|
1342
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1343
|
+
andReturnSuccess([WebElement.buildId('bar')]).
|
|
1344
|
+
end();
|
|
1345
|
+
|
|
1346
|
+
var driver = executor.createDriver();
|
|
1347
|
+
return driver.isElementPresent(By.id('foo')).then(assert.ok);
|
|
1348
|
+
});
|
|
1349
|
+
|
|
1350
|
+
it('letsErrorsPropagate', function() {
|
|
1351
|
+
let executor = new FakeExecutor().
|
|
1352
|
+
expect(CName.FIND_ELEMENTS,
|
|
1353
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1354
|
+
andReturnError(ECode.UNKNOWN_ERROR, {'message':'There is no spoon'}).
|
|
1355
|
+
end();
|
|
1356
|
+
|
|
1357
|
+
var driver = executor.createDriver();
|
|
1358
|
+
driver.isElementPresent(By.id('foo'));
|
|
1359
|
+
return waitForAbort().then(function(e) {
|
|
1360
|
+
assertIsInstance(error.WebDriverError, e);
|
|
1361
|
+
assert.equal(e.message, 'There is no spoon');
|
|
1362
|
+
});
|
|
1363
|
+
});
|
|
1364
|
+
|
|
1365
|
+
it('byJs', function() {
|
|
1366
|
+
let executor = new FakeExecutor().
|
|
1367
|
+
expect(CName.EXECUTE_SCRIPT, {'script': 'return 123', 'args': []}).
|
|
1368
|
+
andReturnSuccess([WebElement.buildId('bar')]).
|
|
1369
|
+
end();
|
|
1370
|
+
|
|
1371
|
+
var driver = executor.createDriver();
|
|
1372
|
+
return driver.isElementPresent(By.js('return 123')).then(assert.ok);
|
|
1373
|
+
});
|
|
1374
|
+
|
|
1375
|
+
it('byJs_canPassScriptArguments', function() {
|
|
1376
|
+
var script = 'return document.getElementsByTagName(arguments[0]);';
|
|
1377
|
+
let executor = new FakeExecutor().
|
|
1378
|
+
expect(CName.EXECUTE_SCRIPT, {
|
|
1379
|
+
'script': script,
|
|
1380
|
+
'args': ['div']
|
|
1381
|
+
}).
|
|
1382
|
+
andReturnSuccess([WebElement.buildId('one')]).
|
|
1383
|
+
end();
|
|
1384
|
+
|
|
1385
|
+
var driver = executor.createDriver();
|
|
1386
|
+
driver.isElementPresent(By.js(script, 'div')).then(assert.ok);
|
|
1387
|
+
return waitForIdle();
|
|
1388
|
+
});
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1391
|
+
describe('findElements', function() {
|
|
1392
|
+
it('returnsMultipleElements', function() {
|
|
1393
|
+
var ids = ['foo', 'bar', 'baz'];
|
|
1394
|
+
let executor = new FakeExecutor().
|
|
1395
|
+
expect(CName.FIND_ELEMENTS, {'using':'css selector', 'value':'a'}).
|
|
1396
|
+
andReturnSuccess(ids.map(WebElement.buildId)).
|
|
1397
|
+
end();
|
|
1398
|
+
|
|
1399
|
+
var driver = executor.createDriver();
|
|
1400
|
+
return driver.findElements(By.tagName('a'))
|
|
1401
|
+
.then(function(elements) {
|
|
1402
|
+
return promise.all(elements.map(function(e) {
|
|
1403
|
+
assert.ok(e instanceof WebElement);
|
|
1404
|
+
return e.getId();
|
|
1405
|
+
}));
|
|
1406
|
+
})
|
|
1407
|
+
.then((actual) => assert.deepEqual(ids, actual));
|
|
1408
|
+
});
|
|
1409
|
+
|
|
1410
|
+
it('byJs', function() {
|
|
1411
|
+
var ids = ['foo', 'bar', 'baz'];
|
|
1412
|
+
let executor = new FakeExecutor().
|
|
1413
|
+
expect(CName.EXECUTE_SCRIPT, {
|
|
1414
|
+
'script': 'return document.getElementsByTagName("div");',
|
|
1415
|
+
'args': []
|
|
1416
|
+
}).
|
|
1417
|
+
andReturnSuccess(ids.map(WebElement.buildId)).
|
|
1418
|
+
end();
|
|
1419
|
+
|
|
1420
|
+
var driver = executor.createDriver();
|
|
1421
|
+
|
|
1422
|
+
return driver.
|
|
1423
|
+
findElements(By.js('return document.getElementsByTagName("div");')).
|
|
1424
|
+
then(function(elements) {
|
|
1425
|
+
return promise.all(elements.map(function(e) {
|
|
1426
|
+
assert.ok(e instanceof WebElement);
|
|
1427
|
+
return e.getId();
|
|
1428
|
+
}));
|
|
1429
|
+
}).
|
|
1430
|
+
then((actual) => assert.deepEqual(ids, actual));
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
it('byJs_filtersOutNonWebElementResponses', function() {
|
|
1434
|
+
var ids = ['foo', 'bar', 'baz'];
|
|
1435
|
+
var json = [
|
|
1436
|
+
WebElement.buildId(ids[0]),
|
|
1437
|
+
123,
|
|
1438
|
+
'a',
|
|
1439
|
+
false,
|
|
1440
|
+
WebElement.buildId(ids[1]),
|
|
1441
|
+
{'not a web element': 1},
|
|
1442
|
+
WebElement.buildId(ids[2])
|
|
1443
|
+
];
|
|
1444
|
+
let executor = new FakeExecutor().
|
|
1445
|
+
expect(CName.EXECUTE_SCRIPT, {
|
|
1446
|
+
'script': 'return document.getElementsByTagName("div");',
|
|
1447
|
+
'args': []
|
|
1448
|
+
}).
|
|
1449
|
+
andReturnSuccess(json).
|
|
1450
|
+
end();
|
|
1451
|
+
|
|
1452
|
+
var driver = executor.createDriver();
|
|
1453
|
+
driver.findElements(By.js('return document.getElementsByTagName("div");')).
|
|
1454
|
+
then(function(elements) {
|
|
1455
|
+
return promise.all(elements.map(function(e) {
|
|
1456
|
+
assert.ok(e instanceof WebElement);
|
|
1457
|
+
return e.getId();
|
|
1458
|
+
}));
|
|
1459
|
+
}).
|
|
1460
|
+
then((actual) => assert.deepEqual(ids, actual));
|
|
1461
|
+
return waitForIdle();
|
|
1462
|
+
});
|
|
1463
|
+
|
|
1464
|
+
it('byJs_convertsSingleWebElementResponseToArray', function() {
|
|
1465
|
+
let executor = new FakeExecutor().
|
|
1466
|
+
expect(CName.EXECUTE_SCRIPT, {
|
|
1467
|
+
'script': 'return document.getElementsByTagName("div");',
|
|
1468
|
+
'args': []
|
|
1469
|
+
}).
|
|
1470
|
+
andReturnSuccess(WebElement.buildId('foo')).
|
|
1471
|
+
end();
|
|
1472
|
+
|
|
1473
|
+
var driver = executor.createDriver();
|
|
1474
|
+
return driver.
|
|
1475
|
+
findElements(By.js('return document.getElementsByTagName("div");')).
|
|
1476
|
+
then(function(elements) {
|
|
1477
|
+
return promise.all(elements.map(function(e) {
|
|
1478
|
+
assert.ok(e instanceof WebElement);
|
|
1479
|
+
return e.getId();
|
|
1480
|
+
}));
|
|
1481
|
+
}).
|
|
1482
|
+
then((actual) => assert.deepEqual(['foo'], actual));
|
|
1483
|
+
});
|
|
1484
|
+
|
|
1485
|
+
it('byJs_canPassScriptArguments', function() {
|
|
1486
|
+
var script = 'return document.getElementsByTagName(arguments[0]);';
|
|
1487
|
+
let executor = new FakeExecutor().
|
|
1488
|
+
expect(CName.EXECUTE_SCRIPT, {
|
|
1489
|
+
'script': script,
|
|
1490
|
+
'args': ['div']
|
|
1491
|
+
}).
|
|
1492
|
+
andReturnSuccess([
|
|
1493
|
+
WebElement.buildId('one'),
|
|
1494
|
+
WebElement.buildId('two')
|
|
1495
|
+
]).
|
|
1496
|
+
end();
|
|
1497
|
+
|
|
1498
|
+
var driver = executor.createDriver();
|
|
1499
|
+
return driver.findElements(By.js(script, 'div'))
|
|
1500
|
+
then(function(elements) {
|
|
1501
|
+
return promise.all(elements.map(function(e) {
|
|
1502
|
+
assert.ok(e instanceof WebElement);
|
|
1503
|
+
return e.getId();
|
|
1504
|
+
}));
|
|
1505
|
+
}).
|
|
1506
|
+
then((actual) => assert.deepEqual(['one', 'two'], actual));
|
|
1507
|
+
});
|
|
1508
|
+
});
|
|
1509
|
+
|
|
1510
|
+
describe('sendKeys', function() {
|
|
1511
|
+
it('convertsVarArgsIntoStrings_simpleArgs', function() {
|
|
1512
|
+
let executor = new FakeExecutor().
|
|
1513
|
+
expect(CName.SEND_KEYS_TO_ELEMENT, {'id': 'one',
|
|
1514
|
+
'value':['1','2','abc','3']}).
|
|
1515
|
+
andReturnSuccess().
|
|
1516
|
+
end();
|
|
1517
|
+
|
|
1518
|
+
var driver = executor.createDriver();
|
|
1519
|
+
var element = new WebElement(driver, 'one');
|
|
1520
|
+
element.sendKeys(1, 2, 'abc', 3);
|
|
1521
|
+
return waitForIdle();
|
|
1522
|
+
});
|
|
1523
|
+
|
|
1524
|
+
it('convertsVarArgsIntoStrings_promisedArgs', function() {
|
|
1525
|
+
let executor = new FakeExecutor().
|
|
1526
|
+
expect(CName.FIND_ELEMENT,
|
|
1527
|
+
{'using':'css selector', 'value':'*[id="foo"]'}).
|
|
1528
|
+
andReturnSuccess(WebElement.buildId('one')).
|
|
1529
|
+
expect(CName.SEND_KEYS_TO_ELEMENT, {'id':'one',
|
|
1530
|
+
'value':['abc', '123', 'def']}).
|
|
1531
|
+
andReturnSuccess().
|
|
1532
|
+
end();
|
|
1533
|
+
|
|
1534
|
+
var driver = executor.createDriver();
|
|
1535
|
+
var element = driver.findElement(By.id('foo'));
|
|
1536
|
+
element.sendKeys(
|
|
1537
|
+
promise.fulfilled('abc'), 123,
|
|
1538
|
+
promise.fulfilled('def'));
|
|
1539
|
+
return waitForIdle();
|
|
1540
|
+
});
|
|
1541
|
+
|
|
1542
|
+
it('sendKeysWithAFileDetector', function() {
|
|
1543
|
+
let executor = new FakeExecutor().
|
|
1544
|
+
expect(CName.FIND_ELEMENT,
|
|
1545
|
+
{'using':'css selector', 'value':'*[id="foo"]'}).
|
|
1546
|
+
andReturnSuccess(WebElement.buildId('one')).
|
|
1547
|
+
expect(CName.SEND_KEYS_TO_ELEMENT, {'id': 'one',
|
|
1548
|
+
'value':['modified/path']}).
|
|
1549
|
+
andReturnSuccess().
|
|
1550
|
+
end();
|
|
1551
|
+
|
|
1552
|
+
let driver = executor.createDriver();
|
|
1553
|
+
let handleFile = function(d, path) {
|
|
1554
|
+
assert.strictEqual(driver, d);
|
|
1555
|
+
assert.equal(path, 'original/path');
|
|
1556
|
+
return promise.fulfilled('modified/path');
|
|
1557
|
+
};
|
|
1558
|
+
driver.setFileDetector({handleFile});
|
|
1559
|
+
|
|
1560
|
+
var element = driver.findElement(By.id('foo'));
|
|
1561
|
+
element.sendKeys('original/', 'path');
|
|
1562
|
+
return waitForIdle();
|
|
1563
|
+
});
|
|
1564
|
+
});
|
|
1565
|
+
|
|
1566
|
+
describe('elementEquality', function() {
|
|
1567
|
+
it('isReflexive', function() {
|
|
1568
|
+
var a = new WebElement({}, 'foo');
|
|
1569
|
+
return WebElement.equals(a, a).then(assert.ok);
|
|
1570
|
+
});
|
|
1571
|
+
|
|
1572
|
+
it('failsIfAnInputElementCouldNotBeFound', function() {
|
|
1573
|
+
var id = promise.rejected(new StubError);
|
|
1574
|
+
id.thenCatch(function() {}); // Suppress default handler.
|
|
1575
|
+
|
|
1576
|
+
var driver = new FakeExecutor().createDriver();
|
|
1577
|
+
var a = new WebElement(driver, 'foo');
|
|
1578
|
+
var b = new WebElementPromise(driver, id);
|
|
1579
|
+
|
|
1580
|
+
return WebElement.equals(a, b).then(fail, assertIsStubError);
|
|
1581
|
+
});
|
|
1582
|
+
});
|
|
1583
|
+
|
|
1584
|
+
describe('waiting', function() {
|
|
1585
|
+
it('waitSucceeds', function() {
|
|
1586
|
+
let executor = new FakeExecutor().
|
|
1587
|
+
expect(CName.FIND_ELEMENTS,
|
|
1588
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1589
|
+
andReturnSuccess([]).
|
|
1590
|
+
times(2).
|
|
1591
|
+
expect(CName.FIND_ELEMENTS,
|
|
1592
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1593
|
+
andReturnSuccess([WebElement.buildId('bar')]).
|
|
1594
|
+
end();
|
|
1595
|
+
|
|
1596
|
+
var driver = executor.createDriver();
|
|
1597
|
+
driver.wait(function() {
|
|
1598
|
+
return driver.isElementPresent(By.id('foo'));
|
|
1599
|
+
}, 200);
|
|
1600
|
+
return waitForIdle();
|
|
1601
|
+
});
|
|
1602
|
+
|
|
1603
|
+
it('waitTimesout_timeoutCaught', function() {
|
|
1604
|
+
let executor = new FakeExecutor().
|
|
1605
|
+
expect(CName.FIND_ELEMENTS,
|
|
1606
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1607
|
+
andReturnSuccess([]).
|
|
1608
|
+
anyTimes().
|
|
1609
|
+
end();
|
|
1610
|
+
|
|
1611
|
+
var driver = executor.createDriver();
|
|
1612
|
+
return driver.wait(function() {
|
|
1613
|
+
return driver.isElementPresent(By.id('foo'));
|
|
1614
|
+
}, 25).then(fail, function(e) {
|
|
1615
|
+
assert.equal('Wait timed out after ',
|
|
1616
|
+
e.message.substring(0, 'Wait timed out after '.length));
|
|
1617
|
+
});
|
|
1618
|
+
});
|
|
1619
|
+
|
|
1620
|
+
it('waitTimesout_timeoutNotCaught', function() {
|
|
1621
|
+
let executor = new FakeExecutor().
|
|
1622
|
+
expect(CName.FIND_ELEMENTS,
|
|
1623
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1624
|
+
andReturnSuccess([]).
|
|
1625
|
+
anyTimes().
|
|
1626
|
+
end();
|
|
1627
|
+
|
|
1628
|
+
var driver = executor.createDriver();
|
|
1629
|
+
driver.wait(function() {
|
|
1630
|
+
return driver.isElementPresent(By.id('foo'));
|
|
1631
|
+
}, 25);
|
|
1632
|
+
return waitForAbort().then(function(e) {
|
|
1633
|
+
assert.equal('Wait timed out after ',
|
|
1634
|
+
e.message.substring(0, 'Wait timed out after '.length));
|
|
1635
|
+
});
|
|
1636
|
+
});
|
|
1637
|
+
});
|
|
1638
|
+
|
|
1639
|
+
describe('alert handling', function() {
|
|
1640
|
+
it('interceptsAndTransformsUnhandledAlertErrors', function() {
|
|
1641
|
+
let executor = new FakeExecutor().
|
|
1642
|
+
expect(CName.FIND_ELEMENT,
|
|
1643
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1644
|
+
andReturnError(ECode.UNEXPECTED_ALERT_OPEN, {
|
|
1645
|
+
'message': 'boom',
|
|
1646
|
+
'alert': {'text': 'hello'}
|
|
1647
|
+
}).
|
|
1648
|
+
end();
|
|
1649
|
+
|
|
1650
|
+
var driver = executor.createDriver();
|
|
1651
|
+
return driver.findElement(By.id('foo')).then(fail, function(e) {
|
|
1652
|
+
assertIsInstance(UnhandledAlertError, e);
|
|
1653
|
+
assert.equal('hello', e.getAlertText());
|
|
1654
|
+
});
|
|
1655
|
+
});
|
|
1656
|
+
|
|
1657
|
+
it('usesEmptyStringIfAlertTextOmittedFromResponse', function() {
|
|
1658
|
+
let executor = new FakeExecutor().
|
|
1659
|
+
expect(CName.FIND_ELEMENT,
|
|
1660
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1661
|
+
andReturnError(ECode.UNEXPECTED_ALERT_OPEN, {'message': 'boom'}).
|
|
1662
|
+
end();
|
|
1663
|
+
|
|
1664
|
+
var driver = executor.createDriver();
|
|
1665
|
+
return driver.findElement(By.id('foo')).then(fail, function(e) {
|
|
1666
|
+
assertIsInstance(UnhandledAlertError, e);
|
|
1667
|
+
assert.equal('', e.getAlertText());
|
|
1668
|
+
});
|
|
1669
|
+
});
|
|
1670
|
+
|
|
1671
|
+
it('alertResolvesWhenPromisedTextResolves', function() {
|
|
1672
|
+
var textPromise = new promise.Deferred();
|
|
1673
|
+
|
|
1674
|
+
var alert = new AlertPromise({}, textPromise);
|
|
1675
|
+
assert.ok(alert.isPending());
|
|
1676
|
+
|
|
1677
|
+
textPromise.fulfill(new Alert({}, 'foo'));
|
|
1678
|
+
return alert.getText().then(function(text) {
|
|
1679
|
+
assert.equal('foo', text);
|
|
1680
|
+
});
|
|
1681
|
+
});
|
|
1682
|
+
|
|
1683
|
+
it('cannotSwitchToAlertThatIsNotPresent', function() {
|
|
1684
|
+
let executor = new FakeExecutor()
|
|
1685
|
+
.expect(CName.GET_ALERT_TEXT)
|
|
1686
|
+
.andReturnError(ECode.NO_SUCH_ALERT, {'message': 'no alert'})
|
|
1687
|
+
.end();
|
|
1688
|
+
|
|
1689
|
+
var driver = executor.createDriver();
|
|
1690
|
+
var alert = driver.switchTo().alert();
|
|
1691
|
+
alert.dismiss(); // Should never execute.
|
|
1692
|
+
return waitForAbort().then(function(e) {
|
|
1693
|
+
assertIsInstance(error.NoSuchAlertError, e);
|
|
1694
|
+
assert.equal('no alert', e.message);
|
|
1695
|
+
});
|
|
1696
|
+
});
|
|
1697
|
+
|
|
1698
|
+
it('alertsBelongToSameFlowAsParentDriver', function() {
|
|
1699
|
+
let executor = new FakeExecutor()
|
|
1700
|
+
.expect(CName.GET_ALERT_TEXT).andReturnSuccess('hello')
|
|
1701
|
+
.end();
|
|
1702
|
+
|
|
1703
|
+
var driver = executor.createDriver();
|
|
1704
|
+
var otherFlow = new promise.ControlFlow();
|
|
1705
|
+
otherFlow.execute(function() {
|
|
1706
|
+
driver.switchTo().alert().then(function() {
|
|
1707
|
+
assert.strictEqual(
|
|
1708
|
+
driver.controlFlow(), promise.controlFlow(),
|
|
1709
|
+
'Alert should belong to the same flow as its parent driver');
|
|
1710
|
+
});
|
|
1711
|
+
});
|
|
1712
|
+
|
|
1713
|
+
assert.notEqual(otherFlow, driver.controlFlow);
|
|
1714
|
+
return Promise.all([
|
|
1715
|
+
waitForIdle(otherFlow),
|
|
1716
|
+
waitForIdle(driver.controlFlow())
|
|
1717
|
+
]);
|
|
1718
|
+
});
|
|
1719
|
+
|
|
1720
|
+
it('commandsFailIfAlertNotPresent', function() {
|
|
1721
|
+
let executor = new FakeExecutor()
|
|
1722
|
+
.expect(CName.GET_ALERT_TEXT)
|
|
1723
|
+
.andReturnError(ECode.NO_SUCH_ALERT, {'message': 'no alert'})
|
|
1724
|
+
.end();
|
|
1725
|
+
|
|
1726
|
+
var driver = executor.createDriver();
|
|
1727
|
+
var alert = driver.switchTo().alert();
|
|
1728
|
+
|
|
1729
|
+
var expectError = expectedError(error.NoSuchAlertError, 'no alert');
|
|
1730
|
+
|
|
1731
|
+
return alert.getText()
|
|
1732
|
+
.then(fail, expectedError)
|
|
1733
|
+
.then(() => alert.accept())
|
|
1734
|
+
.then(fail, expectedError)
|
|
1735
|
+
.then(() => alert.dismiss())
|
|
1736
|
+
.then(fail, expectError)
|
|
1737
|
+
.then(() => alert.sendKeys('hi'))
|
|
1738
|
+
.then(fail, expectError);
|
|
1739
|
+
});
|
|
1740
|
+
});
|
|
1741
|
+
|
|
1742
|
+
it('testWebElementsBelongToSameFlowAsParentDriver', function() {
|
|
1743
|
+
let executor = new FakeExecutor()
|
|
1744
|
+
.expect(CName.FIND_ELEMENT,
|
|
1745
|
+
{using: 'css selector', value: '*[id="foo"]'})
|
|
1746
|
+
.andReturnSuccess(WebElement.buildId('abc123'))
|
|
1747
|
+
.end();
|
|
1748
|
+
|
|
1749
|
+
var driver = executor.createDriver();
|
|
1750
|
+
var otherFlow = new promise.ControlFlow();
|
|
1751
|
+
otherFlow.execute(function() {
|
|
1752
|
+
driver.findElement({id: 'foo'}).then(function() {
|
|
1753
|
+
assert.equal(driver.controlFlow(), promise.controlFlow());
|
|
1754
|
+
});
|
|
1755
|
+
});
|
|
1756
|
+
|
|
1757
|
+
assert.notEqual(otherFlow, driver.controlFlow);
|
|
1758
|
+
return Promise.all([
|
|
1759
|
+
waitForIdle(otherFlow),
|
|
1760
|
+
waitForIdle(driver.controlFlow())
|
|
1761
|
+
]);
|
|
1762
|
+
});
|
|
1763
|
+
|
|
1764
|
+
it('testFetchingLogs', function() {
|
|
1765
|
+
let executor = new FakeExecutor().
|
|
1766
|
+
expect(CName.GET_LOG, {'type': 'browser'}).
|
|
1767
|
+
andReturnSuccess([
|
|
1768
|
+
{'level': 'INFO', 'message': 'hello', 'timestamp': 1234},
|
|
1769
|
+
{'level': 'DEBUG', 'message': 'abc123', 'timestamp': 5678}
|
|
1770
|
+
]).
|
|
1771
|
+
end();
|
|
1772
|
+
|
|
1773
|
+
var driver = executor.createDriver();
|
|
1774
|
+
return driver.manage().logs().get('browser').then(function(entries) {
|
|
1775
|
+
assert.equal(2, entries.length);
|
|
1776
|
+
|
|
1777
|
+
assert.ok(entries[0] instanceof logging.Entry);
|
|
1778
|
+
assert.equal(logging.Level.INFO.value, entries[0].level.value);
|
|
1779
|
+
assert.equal('hello', entries[0].message);
|
|
1780
|
+
assert.equal(1234, entries[0].timestamp);
|
|
1781
|
+
|
|
1782
|
+
assert.ok(entries[1] instanceof logging.Entry);
|
|
1783
|
+
assert.equal(logging.Level.DEBUG.value, entries[1].level.value);
|
|
1784
|
+
assert.equal('abc123', entries[1].message);
|
|
1785
|
+
assert.equal(5678, entries[1].timestamp);
|
|
1786
|
+
});
|
|
1787
|
+
});
|
|
1788
|
+
|
|
1789
|
+
it('testCommandsFailIfInitialSessionCreationFailed', function() {
|
|
1790
|
+
var session = promise.rejected(new StubError);
|
|
1791
|
+
|
|
1792
|
+
var driver = new FakeExecutor().createDriver(session);
|
|
1793
|
+
var navigateResult = driver.get('some-url').then(fail, assertIsStubError);
|
|
1794
|
+
var quitResult = driver.quit().then(fail, assertIsStubError);
|
|
1795
|
+
|
|
1796
|
+
return waitForIdle().then(function() {
|
|
1797
|
+
return promise.all(navigateResult, quitResult);
|
|
1798
|
+
});
|
|
1799
|
+
});
|
|
1800
|
+
|
|
1801
|
+
it('testWebElementCommandsFailIfInitialDriverCreationFailed', function() {
|
|
1802
|
+
var session = Promise.reject(new StubError);
|
|
1803
|
+
var driver = new FakeExecutor().createDriver(session);
|
|
1804
|
+
return driver.findElement(By.id('foo')).click().
|
|
1805
|
+
then(fail, assertIsStubError);
|
|
1806
|
+
});
|
|
1807
|
+
|
|
1808
|
+
it('testWebElementCommansFailIfElementCouldNotBeFound', function() {
|
|
1809
|
+
let executor = new FakeExecutor().
|
|
1810
|
+
expect(CName.FIND_ELEMENT,
|
|
1811
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1812
|
+
andReturnError(ECode.NO_SUCH_ELEMENT,
|
|
1813
|
+
{'message':'Unable to find element'}).
|
|
1814
|
+
end();
|
|
1815
|
+
|
|
1816
|
+
var driver = executor.createDriver();
|
|
1817
|
+
return driver.findElement(By.id('foo')).click()
|
|
1818
|
+
.then(fail, function(e) {
|
|
1819
|
+
assertIsInstance(error.NoSuchElementError, e);
|
|
1820
|
+
assert.equal('Unable to find element', e.message);
|
|
1821
|
+
});
|
|
1822
|
+
});
|
|
1823
|
+
|
|
1824
|
+
it('testCannotFindChildElementsIfParentCouldNotBeFound', function() {
|
|
1825
|
+
let executor = new FakeExecutor().
|
|
1826
|
+
expect(CName.FIND_ELEMENT,
|
|
1827
|
+
{using: 'css selector', value: '*[id="foo"]'}).
|
|
1828
|
+
andReturnError(ECode.NO_SUCH_ELEMENT,
|
|
1829
|
+
{'message':'Unable to find element'}).
|
|
1830
|
+
end();
|
|
1831
|
+
|
|
1832
|
+
var driver = executor.createDriver();
|
|
1833
|
+
return driver.findElement(By.id('foo'))
|
|
1834
|
+
.findElement(By.id('bar'))
|
|
1835
|
+
.findElement(By.id('baz'))
|
|
1836
|
+
.then(fail, function(e) {
|
|
1837
|
+
assertIsInstance(error.NoSuchElementError, e);
|
|
1838
|
+
assert.equal('Unable to find element', e.message);
|
|
1839
|
+
});
|
|
1840
|
+
});
|
|
1841
|
+
|
|
1842
|
+
describe('actions()', function() {
|
|
1843
|
+
it('failsIfInitialDriverCreationFailed', function() {
|
|
1844
|
+
let session = promise.rejected(new StubError);
|
|
1845
|
+
session.catch(function() {});
|
|
1846
|
+
return new FakeExecutor().
|
|
1847
|
+
createDriver(session).
|
|
1848
|
+
actions().
|
|
1849
|
+
mouseDown().
|
|
1850
|
+
mouseUp().
|
|
1851
|
+
perform().
|
|
1852
|
+
thenCatch(assertIsStubError);
|
|
1853
|
+
});
|
|
1854
|
+
|
|
1855
|
+
describe('mouseMove', function() {
|
|
1856
|
+
it('noElement', function() {
|
|
1857
|
+
let executor = new FakeExecutor()
|
|
1858
|
+
.expect(CName.MOVE_TO, {'xoffset': 0, 'yoffset': 125})
|
|
1859
|
+
.andReturnSuccess()
|
|
1860
|
+
.end();
|
|
1861
|
+
|
|
1862
|
+
return executor.createDriver().
|
|
1863
|
+
actions().
|
|
1864
|
+
mouseMove({x: 0, y: 125}).
|
|
1865
|
+
perform();
|
|
1866
|
+
});
|
|
1867
|
+
|
|
1868
|
+
it('element', function() {
|
|
1869
|
+
let executor = new FakeExecutor()
|
|
1870
|
+
.expect(CName.FIND_ELEMENT,
|
|
1871
|
+
{using: 'css selector', value: '*[id="foo"]'})
|
|
1872
|
+
.andReturnSuccess(WebElement.buildId('abc123'))
|
|
1873
|
+
.expect(CName.MOVE_TO,
|
|
1874
|
+
{'element': 'abc123', 'xoffset': 0, 'yoffset': 125})
|
|
1875
|
+
.andReturnSuccess()
|
|
1876
|
+
.end();
|
|
1877
|
+
|
|
1878
|
+
var driver = executor.createDriver();
|
|
1879
|
+
var element = driver.findElement(By.id('foo'));
|
|
1880
|
+
return driver.actions()
|
|
1881
|
+
.mouseMove(element, {x: 0, y: 125})
|
|
1882
|
+
.perform();
|
|
1883
|
+
});
|
|
1884
|
+
});
|
|
1885
|
+
|
|
1886
|
+
it('supportsMouseDown', function() {
|
|
1887
|
+
let executor = new FakeExecutor()
|
|
1888
|
+
.expect(CName.MOUSE_DOWN, {'button': Button.LEFT})
|
|
1889
|
+
.andReturnSuccess()
|
|
1890
|
+
.end();
|
|
1891
|
+
|
|
1892
|
+
return executor.createDriver().
|
|
1893
|
+
actions().
|
|
1894
|
+
mouseDown().
|
|
1895
|
+
perform();
|
|
1896
|
+
});
|
|
1897
|
+
|
|
1898
|
+
it('testActionSequence', function() {
|
|
1899
|
+
let executor = new FakeExecutor()
|
|
1900
|
+
.expect(CName.FIND_ELEMENT,
|
|
1901
|
+
{using: 'css selector', value: '*[id="a"]'})
|
|
1902
|
+
.andReturnSuccess(WebElement.buildId('id1'))
|
|
1903
|
+
.expect(CName.FIND_ELEMENT,
|
|
1904
|
+
{using: 'css selector', value: '*[id="b"]'})
|
|
1905
|
+
.andReturnSuccess(WebElement.buildId('id2'))
|
|
1906
|
+
.expect(CName.SEND_KEYS_TO_ACTIVE_ELEMENT,
|
|
1907
|
+
{'value': [Key.SHIFT]})
|
|
1908
|
+
.andReturnSuccess()
|
|
1909
|
+
.expect(CName.MOVE_TO, {'element': 'id1'})
|
|
1910
|
+
.andReturnSuccess()
|
|
1911
|
+
.expect(CName.CLICK, {'button': Button.LEFT})
|
|
1912
|
+
.andReturnSuccess()
|
|
1913
|
+
.expect(CName.MOVE_TO, {'element': 'id2'})
|
|
1914
|
+
.andReturnSuccess()
|
|
1915
|
+
.expect(CName.CLICK, {'button': Button.LEFT})
|
|
1916
|
+
.andReturnSuccess()
|
|
1917
|
+
.end();
|
|
1918
|
+
|
|
1919
|
+
var driver = executor.createDriver();
|
|
1920
|
+
var element1 = driver.findElement(By.id('a'));
|
|
1921
|
+
var element2 = driver.findElement(By.id('b'));
|
|
1922
|
+
|
|
1923
|
+
return driver.actions()
|
|
1924
|
+
.keyDown(Key.SHIFT)
|
|
1925
|
+
.click(element1)
|
|
1926
|
+
.click(element2)
|
|
1927
|
+
.perform();
|
|
1928
|
+
});
|
|
1929
|
+
});
|
|
1930
|
+
|
|
1931
|
+
describe('touchActions()', function() {
|
|
1932
|
+
it('failsIfInitialDriverCreationFailed', function() {
|
|
1933
|
+
let session = promise.rejected(new StubError);
|
|
1934
|
+
session.catch(function() {});
|
|
1935
|
+
return new FakeExecutor().
|
|
1936
|
+
createDriver(session).
|
|
1937
|
+
touchActions().
|
|
1938
|
+
scroll({x: 3, y: 4}).
|
|
1939
|
+
perform().
|
|
1940
|
+
thenCatch(assertIsStubError);
|
|
1941
|
+
});
|
|
1942
|
+
|
|
1943
|
+
it('testTouchActionSequence', function() {
|
|
1944
|
+
let executor = new FakeExecutor()
|
|
1945
|
+
.expect(CName.TOUCH_DOWN, {x: 1, y: 2}).andReturnSuccess()
|
|
1946
|
+
.expect(CName.TOUCH_MOVE, {x: 3, y: 4}).andReturnSuccess()
|
|
1947
|
+
.expect(CName.TOUCH_UP, {x: 5, y: 6}).andReturnSuccess()
|
|
1948
|
+
.end();
|
|
1949
|
+
|
|
1950
|
+
var driver = executor.createDriver();
|
|
1951
|
+
return driver.touchActions()
|
|
1952
|
+
.tapAndHold({x: 1, y: 2})
|
|
1953
|
+
.move({x: 3, y: 4})
|
|
1954
|
+
.release({x: 5, y: 6})
|
|
1955
|
+
.perform();
|
|
1956
|
+
});
|
|
1957
|
+
});
|
|
1958
|
+
|
|
1959
|
+
describe('generator support', function() {
|
|
1960
|
+
var driver;
|
|
1961
|
+
|
|
1962
|
+
beforeEach(function() {
|
|
1963
|
+
driver = new WebDriver(
|
|
1964
|
+
new Session('test-session', {}),
|
|
1965
|
+
new ExplodingExecutor());
|
|
1966
|
+
});
|
|
1967
|
+
|
|
1968
|
+
it('canUseGeneratorsWithWebDriverCall', function() {
|
|
1969
|
+
return driver.call(function* () {
|
|
1970
|
+
var x = yield promise.fulfilled(1);
|
|
1971
|
+
var y = yield promise.fulfilled(2);
|
|
1972
|
+
return x + y;
|
|
1973
|
+
}).then(function(value) {
|
|
1974
|
+
assert.deepEqual(3, value);
|
|
1975
|
+
});
|
|
1976
|
+
});
|
|
1977
|
+
|
|
1978
|
+
it('canDefineScopeOnGeneratorCall', function() {
|
|
1979
|
+
return driver.call(function* () {
|
|
1980
|
+
var x = yield promise.fulfilled(1);
|
|
1981
|
+
return this.name + x;
|
|
1982
|
+
}, {name: 'Bob'}).then(function(value) {
|
|
1983
|
+
assert.deepEqual('Bob1', value);
|
|
1984
|
+
});
|
|
1985
|
+
});
|
|
1986
|
+
|
|
1987
|
+
it('canSpecifyArgsOnGeneratorCall', function() {
|
|
1988
|
+
return driver.call(function* (a, b) {
|
|
1989
|
+
var x = yield promise.fulfilled(1);
|
|
1990
|
+
var y = yield promise.fulfilled(2);
|
|
1991
|
+
return [x + y, a, b];
|
|
1992
|
+
}, null, 'abc', 123).then(function(value) {
|
|
1993
|
+
assert.deepEqual([3, 'abc', 123], value);
|
|
1994
|
+
});
|
|
1995
|
+
});
|
|
1996
|
+
|
|
1997
|
+
it('canUseGeneratorWithWebDriverWait', function() {
|
|
1998
|
+
var values = [];
|
|
1999
|
+
return driver.wait(function* () {
|
|
2000
|
+
yield values.push(1);
|
|
2001
|
+
values.push(yield promise.delayed(10).then(function() {
|
|
2002
|
+
return 2;
|
|
2003
|
+
}));
|
|
2004
|
+
yield values.push(3);
|
|
2005
|
+
return values.length === 6;
|
|
2006
|
+
}, 250).then(function() {
|
|
2007
|
+
assert.deepEqual([1, 2, 3, 1, 2, 3], values);
|
|
2008
|
+
});
|
|
2009
|
+
});
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* @constructor
|
|
2013
|
+
* @implements {CommandExecutor}
|
|
2014
|
+
*/
|
|
2015
|
+
function ExplodingExecutor() {}
|
|
2016
|
+
|
|
2017
|
+
|
|
2018
|
+
/** @override */
|
|
2019
|
+
ExplodingExecutor.prototype.execute = function(command, cb) {
|
|
2020
|
+
cb(Error('Unsupported operation'));
|
|
2021
|
+
};
|
|
2022
|
+
});
|
|
2023
|
+
|
|
2024
|
+
describe('wire format', function() {
|
|
2025
|
+
describe('can serialize', function() {
|
|
2026
|
+
function runSerializeTest(input, want) {
|
|
2027
|
+
let executor = new FakeExecutor().
|
|
2028
|
+
expect(CName.NEW_SESSION).
|
|
2029
|
+
withParameters({'desiredCapabilities': want}).
|
|
2030
|
+
andReturnSuccess({'browserName': 'firefox'}).
|
|
2031
|
+
end();
|
|
2032
|
+
return WebDriver.createSession(executor, input)
|
|
2033
|
+
.getSession();
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
it('function as a string', function() {
|
|
2037
|
+
function foo() { return 'foo'; }
|
|
2038
|
+
return runSerializeTest(foo, '' + foo);
|
|
2039
|
+
});
|
|
2040
|
+
|
|
2041
|
+
it('object with toJSON()', function() {
|
|
2042
|
+
return runSerializeTest(
|
|
2043
|
+
new Date(605728511546),
|
|
2044
|
+
'1989-03-12T17:55:11.546Z');
|
|
2045
|
+
});
|
|
2046
|
+
|
|
2047
|
+
it('Session', function() {
|
|
2048
|
+
return runSerializeTest(new Session('foo', {}), 'foo');
|
|
2049
|
+
});
|
|
2050
|
+
|
|
2051
|
+
it('Capabilities', function() {
|
|
2052
|
+
var prefs = new logging.Preferences();
|
|
2053
|
+
prefs.setLevel(logging.Type.BROWSER, logging.Level.DEBUG);
|
|
2054
|
+
|
|
2055
|
+
var caps = Capabilities.chrome();
|
|
2056
|
+
caps.setLoggingPrefs(prefs);
|
|
2057
|
+
|
|
2058
|
+
return runSerializeTest(
|
|
2059
|
+
caps,
|
|
2060
|
+
{
|
|
2061
|
+
'browserName': 'chrome',
|
|
2062
|
+
'loggingPrefs': {'browser': 'DEBUG'}
|
|
2063
|
+
});
|
|
2064
|
+
});
|
|
2065
|
+
|
|
2066
|
+
it('WebElement', function() {
|
|
2067
|
+
return runSerializeTest(
|
|
2068
|
+
new WebElement({}, 'fefifofum'),
|
|
2069
|
+
WebElement.buildId('fefifofum'));
|
|
2070
|
+
});
|
|
2071
|
+
|
|
2072
|
+
it('WebElementPromise', function() {
|
|
2073
|
+
return runSerializeTest(
|
|
2074
|
+
new WebElementPromise(
|
|
2075
|
+
{}, promise.fulfilled(new WebElement({}, 'fefifofum'))),
|
|
2076
|
+
WebElement.buildId('fefifofum'));
|
|
2077
|
+
});
|
|
2078
|
+
|
|
2079
|
+
describe('an array', function() {
|
|
2080
|
+
it('with Serializable', function() {
|
|
2081
|
+
return runSerializeTest([new Session('foo', {})], ['foo']);
|
|
2082
|
+
});
|
|
2083
|
+
|
|
2084
|
+
it('with WebElement', function() {
|
|
2085
|
+
return runSerializeTest(
|
|
2086
|
+
[new WebElement({}, 'fefifofum')],
|
|
2087
|
+
[WebElement.buildId('fefifofum')]);
|
|
2088
|
+
});
|
|
2089
|
+
|
|
2090
|
+
it('with WebElementPromise', function() {
|
|
2091
|
+
return runSerializeTest(
|
|
2092
|
+
[new WebElementPromise(
|
|
2093
|
+
{}, promise.fulfilled(new WebElement({}, 'fefifofum')))],
|
|
2094
|
+
[WebElement.buildId('fefifofum')]);
|
|
2095
|
+
});
|
|
2096
|
+
|
|
2097
|
+
it('complex array', function() {
|
|
2098
|
+
var expected = [
|
|
2099
|
+
'abc', 123, true, WebElement.buildId('fefifofum'),
|
|
2100
|
+
[123, {'foo': 'bar'}]
|
|
2101
|
+
];
|
|
2102
|
+
|
|
2103
|
+
var element = new WebElement({}, 'fefifofum');
|
|
2104
|
+
var input = ['abc', 123, true, element, [123, {'foo': 'bar'}]];
|
|
2105
|
+
return runSerializeTest(input, expected);
|
|
2106
|
+
});
|
|
2107
|
+
|
|
2108
|
+
it('nested promises', function() {
|
|
2109
|
+
return runSerializeTest(
|
|
2110
|
+
['abc', Promise.resolve([123, Promise.resolve(true)])],
|
|
2111
|
+
['abc', [123, true]]);
|
|
2112
|
+
});
|
|
2113
|
+
});
|
|
2114
|
+
|
|
2115
|
+
describe('an object', function() {
|
|
2116
|
+
it('literal', function() {
|
|
2117
|
+
var expected = {sessionId: 'foo'};
|
|
2118
|
+
return runSerializeTest({sessionId: 'foo'}, expected);
|
|
2119
|
+
});
|
|
2120
|
+
|
|
2121
|
+
it('with sub-objects', function() {
|
|
2122
|
+
var expected = {sessionId: {value: 'foo'}};
|
|
2123
|
+
return runSerializeTest(
|
|
2124
|
+
{sessionId: {value: 'foo'}}, expected);
|
|
2125
|
+
});
|
|
2126
|
+
|
|
2127
|
+
it('with values that have toJSON', function() {
|
|
2128
|
+
return runSerializeTest(
|
|
2129
|
+
{a: {b: new Date(605728511546)}},
|
|
2130
|
+
{a: {b: '1989-03-12T17:55:11.546Z'}});
|
|
2131
|
+
});
|
|
2132
|
+
|
|
2133
|
+
it('with a Session', function() {
|
|
2134
|
+
return runSerializeTest(
|
|
2135
|
+
{a: new Session('foo', {})},
|
|
2136
|
+
{a: 'foo'});
|
|
2137
|
+
});
|
|
2138
|
+
|
|
2139
|
+
it('nested', function() {
|
|
2140
|
+
var elementJson = WebElement.buildId('fefifofum');
|
|
2141
|
+
var expected = {
|
|
2142
|
+
'script': 'return 1',
|
|
2143
|
+
'args': ['abc', 123, true, elementJson, [123, {'foo': 'bar'}]],
|
|
2144
|
+
'sessionId': 'foo'
|
|
2145
|
+
};
|
|
2146
|
+
|
|
2147
|
+
var element = new WebElement({}, 'fefifofum');
|
|
2148
|
+
var parameters = {
|
|
2149
|
+
'script': 'return 1',
|
|
2150
|
+
'args':['abc', 123, true, element, [123, {'foo': 'bar'}]],
|
|
2151
|
+
'sessionId': new Session('foo', {})
|
|
2152
|
+
};
|
|
2153
|
+
|
|
2154
|
+
return runSerializeTest(parameters, expected);
|
|
2155
|
+
});
|
|
2156
|
+
});
|
|
2157
|
+
});
|
|
2158
|
+
|
|
2159
|
+
describe('can deserialize', function() {
|
|
2160
|
+
function runDeserializeTest(original, want) {
|
|
2161
|
+
let executor = new FakeExecutor()
|
|
2162
|
+
.expect(CName.GET_CURRENT_URL)
|
|
2163
|
+
.andReturnSuccess(original)
|
|
2164
|
+
.end();
|
|
2165
|
+
let driver = executor.createDriver();
|
|
2166
|
+
return driver.getCurrentUrl().then(function(got) {
|
|
2167
|
+
assert.deepEqual(got, want);
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
it('primitives', function() {
|
|
2172
|
+
return Promise.all([
|
|
2173
|
+
runDeserializeTest(1, 1),
|
|
2174
|
+
runDeserializeTest('', ''),
|
|
2175
|
+
runDeserializeTest(true, true),
|
|
2176
|
+
runDeserializeTest(undefined, undefined),
|
|
2177
|
+
runDeserializeTest(null, null)
|
|
2178
|
+
]);
|
|
2179
|
+
});
|
|
2180
|
+
|
|
2181
|
+
it('simple object', function() {
|
|
2182
|
+
return runDeserializeTest(
|
|
2183
|
+
{sessionId: 'foo'},
|
|
2184
|
+
{sessionId: 'foo'});
|
|
2185
|
+
});
|
|
2186
|
+
|
|
2187
|
+
it('nested object', function() {
|
|
2188
|
+
return runDeserializeTest(
|
|
2189
|
+
{'foo': {'bar': 123}},
|
|
2190
|
+
{'foo': {'bar': 123}});
|
|
2191
|
+
});
|
|
2192
|
+
|
|
2193
|
+
it('array', function() {
|
|
2194
|
+
return runDeserializeTest(
|
|
2195
|
+
[{'foo': {'bar': 123}}],
|
|
2196
|
+
[{'foo': {'bar': 123}}]);
|
|
2197
|
+
});
|
|
2198
|
+
|
|
2199
|
+
it('passes through function properties', function() {
|
|
2200
|
+
function bar() {}
|
|
2201
|
+
return runDeserializeTest(
|
|
2202
|
+
[{foo: {'bar': 123}, func: bar}],
|
|
2203
|
+
[{foo: {'bar': 123}, func: bar}]);
|
|
2204
|
+
});
|
|
2205
|
+
});
|
|
2206
|
+
});
|
|
2207
|
+
});
|