selenium-webdriver 2.48.2 → 2.53.3
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 +116 -0
- package/NOTICE +1 -1
- package/README.md +59 -9
- package/builder.js +375 -358
- package/chrome.js +549 -586
- package/edge.js +378 -0
- package/error.js +9 -6
- package/example/google_search.js +1 -1
- package/example/google_search_generator.js +2 -4
- package/example/logging.js +6 -2
- package/example/sample.js +21 -0
- package/executors.js +11 -27
- package/firefox/binary.js +149 -98
- package/firefox/extension.js +15 -19
- package/firefox/index.js +256 -163
- package/firefox/profile.js +223 -243
- package/http/index.js +487 -81
- package/http/util.js +40 -36
- package/ie.js +288 -309
- package/index.js +34 -125
- package/io/exec.js +58 -39
- package/io/index.js +72 -60
- package/lib/README +4 -0
- package/lib/actions.js +596 -0
- package/lib/by.js +277 -0
- package/lib/capabilities.js +450 -0
- package/lib/{webdriver/command.js → command.js} +91 -72
- package/lib/{webdriver/button.js → devmode.js} +13 -8
- package/lib/error.js +690 -0
- package/lib/events.js +212 -0
- package/lib/firefox/amd64/libnoblur64.so +0 -0
- package/lib/firefox/i386/libnoblur.so +0 -0
- package/lib/firefox/webdriver.json +5 -1
- package/lib/firefox/webdriver.xpi +0 -0
- package/lib/{webdriver/key.js → input.js} +84 -2
- package/lib/logging.js +670 -0
- package/lib/{webdriver/promise.js → promise.js} +817 -644
- package/lib/safari/client.js +266 -214
- package/lib/session.js +80 -0
- package/lib/{webdriver/serializable.js → symbols.js} +16 -19
- package/lib/test/build.js +4 -4
- package/lib/test/data/click_tests/html5_submit_buttons.html +2 -1
- package/lib/test/data/click_tests/overlapping_elements.html +15 -4
- 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/hidden_partially.html +45 -0
- package/lib/test/data/readOnlyPage.html +1 -1
- package/lib/test/data/selectPage.html +18 -2
- package/lib/test/fileserver.js +3 -4
- package/lib/test/index.js +7 -3
- package/lib/test/resources.js +1 -1
- package/lib/until.js +376 -0
- package/lib/webdriver.js +2440 -0
- package/net/index.js +4 -0
- package/net/portprober.js +16 -12
- package/opera.js +295 -314
- package/package.json +6 -5
- package/phantomjs.js +144 -147
- package/proxy.js +10 -6
- package/remote/index.js +289 -238
- package/safari.js +326 -311
- package/test/chrome/options_test.js +11 -9
- package/test/element_finding_test.js +51 -13
- package/test/execute_script_test.js +17 -3
- package/test/firefox/firefox_test.js +0 -32
- package/test/http/http_test.js +671 -61
- package/test/http/util_test.js +25 -23
- package/test/io_test.js +67 -1
- package/test/lib/by_test.js +139 -0
- package/test/lib/capabilities_test.js +111 -0
- package/test/lib/error_test.js +325 -0
- package/test/lib/events_test.js +177 -0
- package/test/lib/logging_test.js +272 -0
- package/test/{promise_aplus_test.js → lib/promise_aplus_test.js} +4 -13
- 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 +400 -0
- package/test/lib/webdriver_test.js +2157 -0
- package/test/page_loading_test.js +7 -9
- package/test/remote_test.js +50 -3
- package/test/session_test.js +53 -0
- 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 +12 -2
- package/_base.js +0 -200
- package/docs/Changes.html +0 -356
- 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 -92
- 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 -223
- package/docs/class_webdriver_WebElementPromise.html +0 -274
- 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 -17
- package/docs/class_webdriver_promise_ControlFlow.html +0 -153
- package/docs/class_webdriver_promise_Deferred.html +0 -84
- package/docs/class_webdriver_promise_MultipleUnhandledRejectionError.html +0 -14
- package/docs/class_webdriver_promise_Promise.html +0 -75
- 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 -125
- 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 -223
- package/docs/module_selenium-webdriver_class_WebElementPromise.html +0 -274
- 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 -68
- package/docs/module_selenium-webdriver_firefox_binary.html +0 -5
- package/docs/module_selenium-webdriver_firefox_binary_class_Binary.html +0 -20
- package/docs/module_selenium-webdriver_firefox_class_Binary.html +0 -20
- 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 -163
- 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 -41
- 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 -688
- 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/log/log.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/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 -1654
- 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 -133
- package/lib/goog/async/workqueue.js +0 -139
- package/lib/goog/base.js +0 -2548
- 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 -2991
- 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 -41
- package/lib/goog/dom/vendor.js +0 -96
- package/lib/goog/events/browserevent.js +0 -400
- 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 -237
- package/lib/goog/events/keycodes.js +0 -427
- 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 -109
- package/lib/goog/functions/functions.js +0 -442
- package/lib/goog/html/safehtml.js +0 -757
- 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 -398
- package/lib/goog/html/trustedresourceurl.js +0 -224
- package/lib/goog/html/uncheckedconversions.js +0 -232
- package/lib/goog/i18n/bidi.js +0 -908
- package/lib/goog/iter/iter.js +0 -1302
- package/lib/goog/json/json.js +0 -363
- 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 -341
- 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/log/log.js +0 -197
- package/lib/goog/math/box.js +0 -398
- 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 -1350
- package/lib/goog/promise/resolver.js +0 -48
- package/lib/goog/promise/thenable.js +0 -126
- package/lib/goog/reflect/reflect.js +0 -77
- package/lib/goog/string/const.js +0 -182
- package/lib/goog/string/string.js +0 -1599
- package/lib/goog/string/typedstring.js +0 -48
- package/lib/goog/structs/collection.js +0 -56
- package/lib/goog/structs/map.js +0 -457
- package/lib/goog/structs/set.js +0 -279
- package/lib/goog/structs/structs.js +0 -354
- package/lib/goog/style/style.js +0 -2037
- package/lib/goog/testing/asserts.js +0 -1278
- package/lib/goog/testing/events/events.js +0 -767
- package/lib/goog/testing/functionmock.js +0 -175
- 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 -606
- 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 -262
- 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 -1629
- package/lib/goog/testing/testrunner.js +0 -440
- package/lib/goog/uri/uri.js +0 -1524
- package/lib/goog/uri/utils.js +0 -1064
- package/lib/goog/useragent/product.js +0 -183
- package/lib/goog/useragent/product_isversion.js +0 -144
- package/lib/goog/useragent/useragent.js +0 -572
- package/lib/webdriver/actionsequence.js +0 -356
- package/lib/webdriver/builder.js +0 -207
- package/lib/webdriver/capabilities.js +0 -412
- 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 -525
- 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/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 -892
- package/lib/webdriver/test/promise_flow_test.js +0 -2365
- package/lib/webdriver/test/promise_generator_test.js +0 -323
- package/lib/webdriver/test/promise_test.js +0 -2012
- 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 -2511
- package/test/_base_test.js +0 -129
package/test/http/http_test.js
CHANGED
|
@@ -15,15 +15,632 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
var http = require('http');
|
|
20
|
-
var url = require('url');
|
|
18
|
+
'use strict';
|
|
21
19
|
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
var assert = require('assert'),
|
|
21
|
+
http = require('http'),
|
|
22
|
+
sinon = require('sinon'),
|
|
23
|
+
url = require('url');
|
|
24
|
+
|
|
25
|
+
var error = require('../../error'),
|
|
26
|
+
Executor = require('../../http').Executor,
|
|
27
|
+
HttpClient = require('../../http').HttpClient,
|
|
28
|
+
HttpRequest = require('../../http').Request,
|
|
29
|
+
HttpResponse = require('../../http').Response,
|
|
30
|
+
buildPath = require('../../http').buildPath,
|
|
31
|
+
Capabilities = require('../../lib/capabilities').Capabilities,
|
|
32
|
+
Command = require('../../lib/command').Command,
|
|
33
|
+
CommandName = require('../../lib/command').Name,
|
|
34
|
+
Session = require('../../lib/session').Session,
|
|
35
|
+
Server = require('../../lib/test/httpserver').Server,
|
|
36
|
+
promise = require('../../lib/promise'),
|
|
37
|
+
WebElement = require('../../lib/webdriver').WebElement;
|
|
38
|
+
|
|
39
|
+
describe('buildPath', function() {
|
|
40
|
+
it('properly replaces path segments with command parameters', function() {
|
|
41
|
+
var parameters = {'sessionId':'foo', 'url':'http://www.google.com'};
|
|
42
|
+
var finalPath = buildPath('/session/:sessionId/url', parameters);
|
|
43
|
+
assert.equal(finalPath, '/session/foo/url');
|
|
44
|
+
assert.deepEqual(parameters, {'url':'http://www.google.com'});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('handles web element references', function() {
|
|
48
|
+
var parameters = {'sessionId':'foo', 'id': WebElement.buildId('bar')};
|
|
49
|
+
|
|
50
|
+
var finalPath = buildPath(
|
|
51
|
+
'/session/:sessionId/element/:id/click', parameters);
|
|
52
|
+
assert.equal(finalPath, '/session/foo/element/bar/click');
|
|
53
|
+
assert.deepEqual(parameters, {});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('throws if missing a parameter', function() {
|
|
57
|
+
assert.throws(
|
|
58
|
+
() => buildPath('/session/:sessionId', {}),
|
|
59
|
+
function(err) {
|
|
60
|
+
return err instanceof error.InvalidArgumentError
|
|
61
|
+
&& 'Missing required parameter: sessionId' === err.message;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
assert.throws(
|
|
65
|
+
() => buildPath('/session/:sessionId/element/:id', {'sessionId': 'foo'}),
|
|
66
|
+
function(err) {
|
|
67
|
+
return err instanceof error.InvalidArgumentError
|
|
68
|
+
&& 'Missing required parameter: id' === err.message;
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('does not match on segments that do not start with a colon', function() {
|
|
73
|
+
assert.equal(buildPath('/session/foo:bar/baz', {}), '/session/foo:bar/baz');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('Executor', function() {
|
|
78
|
+
let executor;
|
|
79
|
+
let client;
|
|
80
|
+
let send;
|
|
81
|
+
|
|
82
|
+
beforeEach(function setUp() {
|
|
83
|
+
client = new HttpClient('http://www.example.com');
|
|
84
|
+
send = sinon.stub(client, 'send');
|
|
85
|
+
executor = new Executor(client);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('command routing', function() {
|
|
89
|
+
it('rejects unrecognized commands', function() {
|
|
90
|
+
assert.throws(
|
|
91
|
+
() => executor.execute(new Command('fake-name')),
|
|
92
|
+
function (err) {
|
|
93
|
+
return err instanceof error.UnknownCommandError
|
|
94
|
+
&& 'Unrecognized command: fake-name' === err.message;
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('rejects promise if client fails to send request', function() {
|
|
99
|
+
let error = new Error('boom');
|
|
100
|
+
send.returns(Promise.reject(error));
|
|
101
|
+
return assertFailsToSend(new Command(CommandName.NEW_SESSION))
|
|
102
|
+
.then(function(e) {
|
|
103
|
+
assert.strictEqual(error, e);
|
|
104
|
+
assertSent(
|
|
105
|
+
'POST', '/session', {},
|
|
106
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('can execute commands with no URL parameters', function() {
|
|
111
|
+
var resp = JSON.stringify({sessionId: 'abc123'});
|
|
112
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, resp)));
|
|
113
|
+
|
|
114
|
+
let command = new Command(CommandName.NEW_SESSION);
|
|
115
|
+
return assertSendsSuccessfully(command).then(function(response) {
|
|
116
|
+
assertSent(
|
|
117
|
+
'POST', '/session', {},
|
|
118
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('rejects commands missing URL parameters', function() {
|
|
123
|
+
let command =
|
|
124
|
+
new Command(CommandName.FIND_CHILD_ELEMENT).
|
|
125
|
+
setParameter('sessionId', 's123').
|
|
126
|
+
// Let this be missing: setParameter('id', {'ELEMENT': 'e456'}).
|
|
127
|
+
setParameter('using', 'id').
|
|
128
|
+
setParameter('value', 'foo');
|
|
129
|
+
|
|
130
|
+
assert.throws(
|
|
131
|
+
() => executor.execute(command),
|
|
132
|
+
function(err) {
|
|
133
|
+
return err instanceof error.InvalidArgumentError
|
|
134
|
+
&& 'Missing required parameter: id' === err.message;
|
|
135
|
+
});
|
|
136
|
+
assert.ok(!send.called);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('replaces URL parameters with command parameters', function() {
|
|
140
|
+
var command = new Command(CommandName.GET).
|
|
141
|
+
setParameter('sessionId', 's123').
|
|
142
|
+
setParameter('url', 'http://www.google.com');
|
|
143
|
+
|
|
144
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, '')));
|
|
145
|
+
|
|
146
|
+
return assertSendsSuccessfully(command).then(function(response) {
|
|
147
|
+
assertSent(
|
|
148
|
+
'POST', '/session/s123/url', {'url': 'http://www.google.com'},
|
|
149
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe('uses correct URL', function() {
|
|
154
|
+
beforeEach(() => executor = new Executor(client));
|
|
155
|
+
|
|
156
|
+
describe('in legacy mode', function() {
|
|
157
|
+
test(CommandName.GET_WINDOW_SIZE, {sessionId:'s123'}, false,
|
|
158
|
+
'GET', '/session/s123/window/current/size');
|
|
159
|
+
|
|
160
|
+
test(CommandName.SET_WINDOW_SIZE,
|
|
161
|
+
{sessionId:'s123', width: 1, height: 1}, false,
|
|
162
|
+
'POST', '/session/s123/window/current/size',
|
|
163
|
+
{width: 1, height: 1});
|
|
164
|
+
|
|
165
|
+
test(CommandName.MAXIMIZE_WINDOW, {sessionId:'s123'}, false,
|
|
166
|
+
'POST', '/session/s123/window/current/maximize');
|
|
167
|
+
|
|
168
|
+
// This is consistent b/w legacy and W3C, just making sure.
|
|
169
|
+
test(CommandName.GET,
|
|
170
|
+
{sessionId:'s123', url: 'http://www.example.com'}, false,
|
|
171
|
+
'POST', '/session/s123/url', {url: 'http://www.example.com'});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe('in W3C mode', function() {
|
|
175
|
+
test(CommandName.GET_WINDOW_SIZE,
|
|
176
|
+
{sessionId:'s123'}, true,
|
|
177
|
+
'GET', '/session/s123/window/size');
|
|
178
|
+
|
|
179
|
+
test(CommandName.SET_WINDOW_SIZE,
|
|
180
|
+
{sessionId:'s123', width: 1, height: 1}, true,
|
|
181
|
+
'POST', '/session/s123/window/size', {width: 1, height: 1});
|
|
182
|
+
|
|
183
|
+
test(CommandName.MAXIMIZE_WINDOW, {sessionId:'s123'}, true,
|
|
184
|
+
'POST', '/session/s123/window/maximize');
|
|
185
|
+
|
|
186
|
+
// This is consistent b/w legacy and W3C, just making sure.
|
|
187
|
+
test(CommandName.GET,
|
|
188
|
+
{sessionId:'s123', url: 'http://www.example.com'}, true,
|
|
189
|
+
'POST', '/session/s123/url', {url: 'http://www.example.com'});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
function test(command, parameters, w3c,
|
|
193
|
+
expectedMethod, expectedUrl, opt_expectedParams) {
|
|
194
|
+
it(`command=${command}`, function() {
|
|
195
|
+
var resp = JSON.stringify({sessionId: 'abc123'});
|
|
196
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, resp)));
|
|
197
|
+
|
|
198
|
+
let cmd = new Command(command).setParameters(parameters);
|
|
199
|
+
executor.w3c = w3c;
|
|
200
|
+
return executor.execute(cmd).then(function() {
|
|
201
|
+
assertSent(
|
|
202
|
+
expectedMethod, expectedUrl, opt_expectedParams || {},
|
|
203
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('response parsing', function() {
|
|
211
|
+
it('extracts value from JSON response', function() {
|
|
212
|
+
var responseObj = {
|
|
213
|
+
'status': error.ErrorCode.SUCCESS,
|
|
214
|
+
'value': 'http://www.google.com'
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
218
|
+
.setParameter('sessionId', 's123');
|
|
219
|
+
|
|
220
|
+
send.returns(Promise.resolve(
|
|
221
|
+
new HttpResponse(200, {}, JSON.stringify(responseObj))));
|
|
222
|
+
|
|
223
|
+
return executor.execute(command).then(function(response) {
|
|
224
|
+
assertSent('GET', '/session/s123/url', {},
|
|
225
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
226
|
+
assert.strictEqual(response, 'http://www.google.com');
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('extracts Session from NEW_SESSION response', function() {
|
|
231
|
+
beforeEach(() => executor = new Executor(client));
|
|
232
|
+
|
|
233
|
+
const command = new Command(CommandName.NEW_SESSION);
|
|
234
|
+
|
|
235
|
+
describe('fails if server returns invalid response', function() {
|
|
236
|
+
describe('(empty response)', function() {
|
|
237
|
+
test(true);
|
|
238
|
+
test(false);
|
|
239
|
+
|
|
240
|
+
function test(w3c) {
|
|
241
|
+
it('w3c === ' + w3c, function() {
|
|
242
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, '')));
|
|
243
|
+
executor.w3c = w3c;
|
|
244
|
+
return executor.execute(command).then(
|
|
245
|
+
() => assert.fail('expected to fail'),
|
|
246
|
+
(e) => {
|
|
247
|
+
if (!e.message.startsWith('Unable to parse')) {
|
|
248
|
+
throw e;
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe('(no session ID)', function() {
|
|
256
|
+
test(true);
|
|
257
|
+
test(false);
|
|
258
|
+
|
|
259
|
+
function test(w3c) {
|
|
260
|
+
it('w3c === ' + w3c, function() {
|
|
261
|
+
let resp = {value:{name: 'Bob'}};
|
|
262
|
+
send.returns(Promise.resolve(
|
|
263
|
+
new HttpResponse(200, {}, JSON.stringify(resp))));
|
|
264
|
+
executor.w3c = w3c;
|
|
265
|
+
return executor.execute(command).then(
|
|
266
|
+
() => assert.fail('expected to fail'),
|
|
267
|
+
(e) => {
|
|
268
|
+
if (!e.message.startsWith('Unable to parse')) {
|
|
269
|
+
throw e;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('handles legacy response', function() {
|
|
278
|
+
var rawResponse = {sessionId: 's123', status: 0, value: {name: 'Bob'}};
|
|
279
|
+
|
|
280
|
+
send.returns(Promise.resolve(
|
|
281
|
+
new HttpResponse(200, {}, JSON.stringify(rawResponse))));
|
|
282
|
+
|
|
283
|
+
assert.ok(!executor.w3c);
|
|
284
|
+
return executor.execute(command).then(function(response) {
|
|
285
|
+
assert.ok(response instanceof Session);
|
|
286
|
+
assert.equal(response.getId(), 's123');
|
|
287
|
+
|
|
288
|
+
let caps = response.getCapabilities();
|
|
289
|
+
assert.ok(caps instanceof Capabilities);
|
|
290
|
+
assert.equal(caps.get('name'), 'Bob');
|
|
291
|
+
|
|
292
|
+
assert.ok(!executor.w3c);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('auto-upgrades on W3C response', function() {
|
|
297
|
+
var rawResponse = {sessionId: 's123', value: {name: 'Bob'}};
|
|
298
|
+
|
|
299
|
+
send.returns(Promise.resolve(
|
|
300
|
+
new HttpResponse(200, {}, JSON.stringify(rawResponse))));
|
|
301
|
+
|
|
302
|
+
assert.ok(!executor.w3c);
|
|
303
|
+
return executor.execute(command).then(function(response) {
|
|
304
|
+
assert.ok(response instanceof Session);
|
|
305
|
+
assert.equal(response.getId(), 's123');
|
|
306
|
+
|
|
307
|
+
let caps = response.getCapabilities();
|
|
308
|
+
assert.ok(caps instanceof Capabilities);
|
|
309
|
+
assert.equal(caps.get('name'), 'Bob');
|
|
310
|
+
|
|
311
|
+
assert.ok(executor.w3c);
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('if w3c, does not downgrade on legacy response', function() {
|
|
316
|
+
var rawResponse = {sessionId: 's123', status: 0, value: null};
|
|
317
|
+
|
|
318
|
+
send.returns(Promise.resolve(
|
|
319
|
+
new HttpResponse(200, {}, JSON.stringify(rawResponse))));
|
|
320
|
+
|
|
321
|
+
executor.w3c = true;
|
|
322
|
+
return executor.execute(command).then(function(response) {
|
|
323
|
+
assert.ok(response instanceof Session);
|
|
324
|
+
assert.equal(response.getId(), 's123');
|
|
325
|
+
assert.equal(response.getCapabilities().size, 0);
|
|
326
|
+
assert.ok(executor.w3c, 'should never downgrade');
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
describe('extracts Session from DESCRIBE_SESSION response', function() {
|
|
332
|
+
let command;
|
|
333
|
+
|
|
334
|
+
beforeEach(function() {
|
|
335
|
+
executor = new Executor(client);
|
|
336
|
+
command = new Command(CommandName.DESCRIBE_SESSION)
|
|
337
|
+
.setParameter('sessionId', 'foo');
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
describe('fails if server returns invalid response', function() {
|
|
341
|
+
describe('(empty response)', function() {
|
|
342
|
+
test(true);
|
|
343
|
+
test(false);
|
|
344
|
+
|
|
345
|
+
function test(w3c) {
|
|
346
|
+
it('w3c === ' + w3c, function() {
|
|
347
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, '')));
|
|
348
|
+
executor.w3c = w3c;
|
|
349
|
+
return executor.execute(command).then(
|
|
350
|
+
() => assert.fail('expected to fail'),
|
|
351
|
+
(e) => {
|
|
352
|
+
if (!e.message.startsWith('Unable to parse')) {
|
|
353
|
+
throw e;
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
describe('(no session ID)', function() {
|
|
361
|
+
test(true);
|
|
362
|
+
test(false);
|
|
363
|
+
|
|
364
|
+
function test(w3c) {
|
|
365
|
+
it('w3c === ' + w3c, function() {
|
|
366
|
+
let resp = {value:{name: 'Bob'}};
|
|
367
|
+
send.returns(Promise.resolve(
|
|
368
|
+
new HttpResponse(200, {}, JSON.stringify(resp))));
|
|
369
|
+
executor.w3c = w3c;
|
|
370
|
+
return executor.execute(command).then(
|
|
371
|
+
() => assert.fail('expected to fail'),
|
|
372
|
+
(e) => {
|
|
373
|
+
if (!e.message.startsWith('Unable to parse')) {
|
|
374
|
+
throw e;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('handles legacy response', function() {
|
|
383
|
+
var rawResponse = {sessionId: 's123', status: 0, value: {name: 'Bob'}};
|
|
384
|
+
|
|
385
|
+
send.returns(Promise.resolve(
|
|
386
|
+
new HttpResponse(200, {}, JSON.stringify(rawResponse))));
|
|
387
|
+
|
|
388
|
+
assert.ok(!executor.w3c);
|
|
389
|
+
return executor.execute(command).then(function(response) {
|
|
390
|
+
assert.ok(response instanceof Session);
|
|
391
|
+
assert.equal(response.getId(), 's123');
|
|
392
|
+
|
|
393
|
+
let caps = response.getCapabilities();
|
|
394
|
+
assert.ok(caps instanceof Capabilities);
|
|
395
|
+
assert.equal(caps.get('name'), 'Bob');
|
|
396
|
+
|
|
397
|
+
assert.ok(!executor.w3c);
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it('does not auto-upgrade on W3C response', function() {
|
|
402
|
+
var rawResponse = {sessionId: 's123', value: {name: 'Bob'}};
|
|
403
|
+
|
|
404
|
+
send.returns(Promise.resolve(
|
|
405
|
+
new HttpResponse(200, {}, JSON.stringify(rawResponse))));
|
|
406
|
+
|
|
407
|
+
assert.ok(!executor.w3c);
|
|
408
|
+
return executor.execute(command).then(function(response) {
|
|
409
|
+
assert.ok(response instanceof Session);
|
|
410
|
+
assert.equal(response.getId(), 's123');
|
|
411
|
+
|
|
412
|
+
let caps = response.getCapabilities();
|
|
413
|
+
assert.ok(caps instanceof Capabilities);
|
|
414
|
+
assert.equal(caps.get('name'), 'Bob');
|
|
415
|
+
|
|
416
|
+
assert.ok(!executor.w3c);
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('if w3c, does not downgrade on legacy response', function() {
|
|
421
|
+
var rawResponse = {sessionId: 's123', status: 0, value: null};
|
|
422
|
+
|
|
423
|
+
send.returns(Promise.resolve(
|
|
424
|
+
new HttpResponse(200, {}, JSON.stringify(rawResponse))));
|
|
425
|
+
|
|
426
|
+
executor.w3c = true;
|
|
427
|
+
return executor.execute(command).then(function(response) {
|
|
428
|
+
assert.ok(response instanceof Session);
|
|
429
|
+
assert.equal(response.getId(), 's123');
|
|
430
|
+
assert.equal(response.getCapabilities().size, 0);
|
|
431
|
+
assert.ok(executor.w3c, 'should never downgrade');
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
it('handles JSON null', function() {
|
|
437
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
438
|
+
.setParameter('sessionId', 's123');
|
|
439
|
+
|
|
440
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, 'null')));
|
|
441
|
+
|
|
442
|
+
return executor.execute(command).then(function(response) {
|
|
443
|
+
assertSent('GET', '/session/s123/url', {},
|
|
444
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
445
|
+
assert.strictEqual(response, null);
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
describe('falsy values', function() {
|
|
450
|
+
test(0);
|
|
451
|
+
test(false);
|
|
452
|
+
test('');
|
|
453
|
+
|
|
454
|
+
function test(value) {
|
|
455
|
+
it(`value=${value}`, function() {
|
|
456
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
457
|
+
.setParameter('sessionId', 's123');
|
|
458
|
+
|
|
459
|
+
send.returns(Promise.resolve(
|
|
460
|
+
new HttpResponse(200, {},
|
|
461
|
+
JSON.stringify({status: 0, value: value}))));
|
|
462
|
+
|
|
463
|
+
return executor.execute(command).then(function(response) {
|
|
464
|
+
assertSent('GET', '/session/s123/url', {},
|
|
465
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
466
|
+
assert.strictEqual(response, value);
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
it('handles non-object JSON', function() {
|
|
473
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
474
|
+
.setParameter('sessionId', 's123');
|
|
475
|
+
|
|
476
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, '123')));
|
|
477
|
+
|
|
478
|
+
return executor.execute(command).then(function(response) {
|
|
479
|
+
assertSent('GET', '/session/s123/url', {},
|
|
480
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
481
|
+
assert.strictEqual(response, 123);
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it('returns body text when 2xx but not JSON', function() {
|
|
486
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
487
|
+
.setParameter('sessionId', 's123');
|
|
488
|
+
|
|
489
|
+
send.returns(Promise.resolve(
|
|
490
|
+
new HttpResponse(200, {}, 'hello, world\r\ngoodbye, world!')));
|
|
491
|
+
|
|
492
|
+
return executor.execute(command).then(function(response) {
|
|
493
|
+
assertSent('GET', '/session/s123/url', {},
|
|
494
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
495
|
+
assert.strictEqual(response, 'hello, world\ngoodbye, world!');
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
it('returns body text when 2xx but invalid JSON', function() {
|
|
500
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
501
|
+
.setParameter('sessionId', 's123');
|
|
502
|
+
|
|
503
|
+
send.returns(Promise.resolve(
|
|
504
|
+
new HttpResponse(200, {}, '[')));
|
|
505
|
+
|
|
506
|
+
return executor.execute(command).then(function(response) {
|
|
507
|
+
assertSent('GET', '/session/s123/url', {},
|
|
508
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
509
|
+
assert.strictEqual(response, '[');
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
it('returns null if no body text and 2xx', function() {
|
|
514
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
515
|
+
.setParameter('sessionId', 's123');
|
|
516
|
+
|
|
517
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, '')));
|
|
518
|
+
|
|
519
|
+
return executor.execute(command).then(function(response) {
|
|
520
|
+
assertSent('GET', '/session/s123/url', {},
|
|
521
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
522
|
+
assert.strictEqual(response, null);
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it('returns normalized body text when 2xx but not JSON', function() {
|
|
527
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
528
|
+
.setParameter('sessionId', 's123');
|
|
529
|
+
|
|
530
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, '\r\n\n\n\r\n')));
|
|
531
|
+
|
|
532
|
+
return executor.execute(command).then(function(response) {
|
|
533
|
+
assertSent('GET', '/session/s123/url', {},
|
|
534
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
535
|
+
assert.strictEqual(response, '\n\n\n\n');
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
it('throws UnsupportedOperationError for 404 and body not JSON',
|
|
540
|
+
function() {
|
|
541
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
542
|
+
.setParameter('sessionId', 's123');
|
|
543
|
+
|
|
544
|
+
send.returns(Promise.resolve(
|
|
545
|
+
new HttpResponse(404, {}, 'hello, world\r\ngoodbye, world!')));
|
|
546
|
+
|
|
547
|
+
return executor.execute(command)
|
|
548
|
+
.then(
|
|
549
|
+
() => assert.fail('should have failed'),
|
|
550
|
+
checkError(
|
|
551
|
+
error.UnsupportedOperationError,
|
|
552
|
+
'hello, world\ngoodbye, world!'));
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
it('throws WebDriverError for generic 4xx when body not JSON',
|
|
556
|
+
function() {
|
|
557
|
+
var command = new Command(CommandName.GET_CURRENT_URL)
|
|
558
|
+
.setParameter('sessionId', 's123');
|
|
559
|
+
|
|
560
|
+
send.returns(Promise.resolve(
|
|
561
|
+
new HttpResponse(500, {}, 'hello, world\r\ngoodbye, world!')));
|
|
562
|
+
|
|
563
|
+
return executor.execute(command)
|
|
564
|
+
.then(
|
|
565
|
+
() => assert.fail('should have failed'),
|
|
566
|
+
checkError(
|
|
567
|
+
error.WebDriverError,
|
|
568
|
+
'hello, world\ngoodbye, world!'))
|
|
569
|
+
.then(function() {
|
|
570
|
+
assertSent('GET', '/session/s123/url', {},
|
|
571
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
572
|
+
});
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
it('canDefineNewCommands', function() {
|
|
577
|
+
executor.defineCommand('greet', 'GET', '/person/:name');
|
|
578
|
+
|
|
579
|
+
var command = new Command('greet').
|
|
580
|
+
setParameter('name', 'Bob');
|
|
581
|
+
|
|
582
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, '')));
|
|
583
|
+
|
|
584
|
+
return assertSendsSuccessfully(command).then(function(response) {
|
|
585
|
+
assertSent('GET', '/person/Bob', {},
|
|
586
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
it('canRedefineStandardCommands', function() {
|
|
591
|
+
executor.defineCommand(CommandName.GO_BACK, 'POST', '/custom/back');
|
|
592
|
+
|
|
593
|
+
var command = new Command(CommandName.GO_BACK).
|
|
594
|
+
setParameter('times', 3);
|
|
595
|
+
|
|
596
|
+
send.returns(Promise.resolve(new HttpResponse(200, {}, '')));
|
|
597
|
+
|
|
598
|
+
return assertSendsSuccessfully(command).then(function(response) {
|
|
599
|
+
assertSent('POST', '/custom/back', {'times': 3},
|
|
600
|
+
[['Accept', 'application/json; charset=utf-8']]);
|
|
601
|
+
});
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
function entries(map) {
|
|
605
|
+
let entries = [];
|
|
606
|
+
for (let e of map.entries()) {
|
|
607
|
+
entries.push(e);
|
|
608
|
+
}
|
|
609
|
+
return entries;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function checkError(type, message) {
|
|
613
|
+
return function(e) {
|
|
614
|
+
if (e instanceof type) {
|
|
615
|
+
assert.strictEqual(e.message, message);
|
|
616
|
+
} else {
|
|
617
|
+
throw e;
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function assertSent(method, path, data, headers) {
|
|
623
|
+
assert.ok(send.calledWith(sinon.match(function(value) {
|
|
624
|
+
assert.equal(value.method, method);
|
|
625
|
+
assert.equal(value.path, path);
|
|
626
|
+
assert.deepEqual(value.data, data);
|
|
627
|
+
assert.deepEqual(entries(value.headers), headers);
|
|
628
|
+
return true;
|
|
629
|
+
})));
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function assertSendsSuccessfully(command) {
|
|
633
|
+
return executor.execute(command).then(function(response) {
|
|
634
|
+
return response;
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function assertFailsToSend(command, opt_onError) {
|
|
639
|
+
return executor.execute(command).then(
|
|
640
|
+
() => {throw Error('should have failed')},
|
|
641
|
+
(e) => {return e});
|
|
642
|
+
}
|
|
643
|
+
});
|
|
27
644
|
|
|
28
645
|
describe('HttpClient', function() {
|
|
29
646
|
this.timeout(4 * 1000);
|
|
@@ -83,99 +700,92 @@ describe('HttpClient', function() {
|
|
|
83
700
|
}
|
|
84
701
|
});
|
|
85
702
|
|
|
86
|
-
|
|
703
|
+
before(function() {
|
|
87
704
|
return server.start();
|
|
88
705
|
});
|
|
89
706
|
|
|
90
|
-
|
|
707
|
+
after(function() {
|
|
91
708
|
return server.stop();
|
|
92
709
|
});
|
|
93
710
|
|
|
94
|
-
|
|
711
|
+
it('can send a basic HTTP request', function() {
|
|
95
712
|
var request = new HttpRequest('GET', '/echo');
|
|
96
|
-
request.headers
|
|
713
|
+
request.headers.set('Foo', 'Bar');
|
|
97
714
|
|
|
98
715
|
var agent = new http.Agent();
|
|
99
716
|
agent.maxSockets = 1; // Only making 1 request.
|
|
100
717
|
|
|
101
718
|
var client = new HttpClient(server.url(), agent);
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
719
|
+
return client.send(request).then(function(response) {
|
|
720
|
+
assert.equal(200, response.status);
|
|
721
|
+
assert.equal(response.headers.get('content-length'), '0');
|
|
722
|
+
assert.equal(response.headers.get('connection'), 'keep-alive');
|
|
723
|
+
assert.equal(response.headers.get('host'), server.host());
|
|
724
|
+
|
|
725
|
+
assert.equal(request.headers.get('Foo'), 'Bar');
|
|
726
|
+
assert.equal(
|
|
727
|
+
request.headers.get('Accept'), 'application/json; charset=utf-8');
|
|
728
|
+
});
|
|
112
729
|
});
|
|
113
730
|
|
|
114
|
-
|
|
731
|
+
it('can use basic auth', function() {
|
|
115
732
|
var parsed = url.parse(server.url());
|
|
116
733
|
parsed.auth = 'genie:bottle';
|
|
117
734
|
|
|
118
735
|
var client = new HttpClient(url.format(parsed));
|
|
119
736
|
var request = new HttpRequest('GET', '/protected');
|
|
120
|
-
return
|
|
121
|
-
.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
737
|
+
return client.send(request).then(function(response) {
|
|
738
|
+
assert.equal(200, response.status);
|
|
739
|
+
assert.equal(response.headers.get('content-type'), 'text/plain');
|
|
740
|
+
assert.equal(response.body, 'Access granted!');
|
|
741
|
+
});
|
|
126
742
|
});
|
|
127
743
|
|
|
128
|
-
|
|
744
|
+
it('fails requests missing required basic auth', function() {
|
|
129
745
|
var client = new HttpClient(server.url());
|
|
130
746
|
var request = new HttpRequest('GET', '/protected');
|
|
131
|
-
return
|
|
132
|
-
.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
});
|
|
747
|
+
return client.send(request).then(function(response) {
|
|
748
|
+
assert.equal(401, response.status);
|
|
749
|
+
assert.equal(response.body, 'Access denied');
|
|
750
|
+
});
|
|
136
751
|
});
|
|
137
752
|
|
|
138
|
-
|
|
753
|
+
it('automatically follows redirects', function() {
|
|
139
754
|
var request = new HttpRequest('GET', '/redirect');
|
|
140
755
|
var client = new HttpClient(server.url());
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
});
|
|
756
|
+
return client.send(request).then(function(response) {
|
|
757
|
+
assert.equal(200, response.status);
|
|
758
|
+
assert.equal(response.headers.get('content-type'), 'text/plain');
|
|
759
|
+
assert.equal(response.body, 'hello, world!');
|
|
760
|
+
});
|
|
147
761
|
});
|
|
148
762
|
|
|
149
|
-
|
|
763
|
+
it('handles malformed redirect responses', function() {
|
|
150
764
|
var request = new HttpRequest('GET', '/badredirect');
|
|
151
765
|
var client = new HttpClient(server.url());
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
});
|
|
766
|
+
return client.send(request).then(assert.fail, function(err) {
|
|
767
|
+
assert.ok(/Failed to parse "Location"/.test(err.message),
|
|
768
|
+
'Not the expected error: ' + err.message);
|
|
769
|
+
});
|
|
157
770
|
});
|
|
158
771
|
|
|
159
|
-
|
|
772
|
+
it('proxies requests through the webdriver proxy', function() {
|
|
160
773
|
var request = new HttpRequest('GET', '/proxy');
|
|
161
774
|
var client = new HttpClient(
|
|
162
775
|
'http://another.server.com', undefined, server.url());
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
776
|
+
return client.send(request).then(function(response) {
|
|
777
|
+
assert.equal(200, response.status);
|
|
778
|
+
assert.equal(response.headers.get('host'), 'another.server.com');
|
|
779
|
+
});
|
|
168
780
|
});
|
|
169
781
|
|
|
170
|
-
|
|
171
|
-
'proxies requests through the webdriver proxy on redirect', function() {
|
|
782
|
+
it('proxies requests through the webdriver proxy on redirect', function() {
|
|
172
783
|
var request = new HttpRequest('GET', '/proxy/redirect');
|
|
173
784
|
var client = new HttpClient(
|
|
174
785
|
'http://another.server.com', undefined, server.url());
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
786
|
+
return client.send(request).then(function(response) {
|
|
787
|
+
assert.equal(200, response.status);
|
|
788
|
+
assert.equal(response.headers.get('host'), 'another.server.com');
|
|
789
|
+
});
|
|
180
790
|
});
|
|
181
791
|
});
|