From ba7170aed16d7351a7596e7d36ad9a6309c82bc7 Mon Sep 17 00:00:00 2001 From: Andrei Rusu Date: Fri, 17 Jul 2015 16:14:30 +0200 Subject: [PATCH] updated api docs --- lib/api/protocol.js | 28 ++++++++++++++++++---------- tests/src/testProtocolActions.js | 10 +++------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/api/protocol.js b/lib/api/protocol.js index 7e124fb063..55f01e395d 100644 --- a/lib/api/protocol.js +++ b/lib/api/protocol.js @@ -496,10 +496,13 @@ module.exports = function(Nightwatch) { ////////////////////////////////////////////////////////////////// /** - * Get a list of the available contexts. + * Get a list of the available contexts. * - * @param {function} [callback] Optional callback function to be called when the command finishes. - * @jsonWire GET /session/:sessionId/contexts + * Used by Appium when testing hybrid mobile web apps. More info here: https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/hybrid.md. + * + * @param {function} callback Callback function to be called when the command finishes. + * @returns {Array} an array of strings representing available contexts, e.g 'WEBVIEW', or 'NATIVE' + * @api protocol */ Actions.contexts = function(callback) { return getRequest('/contexts', callback); @@ -508,21 +511,26 @@ module.exports = function(Nightwatch) { /** * * Get current context. - * - * @jsonWire GET /session/:sessionId/contexts + * + * @param {function} callback Callback function to be called when the command finishes. + * @returns {string|null} a string representing the current context or `null`, representing "no context" + * @api protocol */ Actions.currentContext = function(callback) { return getRequest('/context', callback); }; /** - * Set context. + * Sets the context. * - * @param {string} context name switch to - * @jsonWire POST /session/:sessionId/context + * @param {string} context context name to switch to - a string representing an available context. + * @param {function} [callback] Optional callback function to be called when the command finishes. + * @api protocol */ - Actions.setContext = function (contextRef, callback) { - var data = { name: contextRef }; + Actions.setContext = function (context, callback) { + var data = { + name: context + }; return postRequest('/context', data, callback); }; diff --git a/tests/src/testProtocolActions.js b/tests/src/testProtocolActions.js index 6e81487057..6b91304a1f 100644 --- a/tests/src/testProtocolActions.js +++ b/tests/src/testProtocolActions.js @@ -1066,8 +1066,6 @@ module.exports = { test.equal(command.request.path, '/wd/hub/session/1352110219202/log/types'); }); }, -///////////////////////////// - testContexts: function (test) { var protocol = this.protocol; @@ -1095,22 +1093,20 @@ module.exports = { }); }, - testSetContext: function (test) { var protocol = this.protocol; this.client.on('selenium:session_create', function (sessionId) { - var command = protocol.setContext('Context text',function callback() { + var command = protocol.setContext('NATIVE',function callback() { test.done(); }); test.equal(command.request.method, 'POST'); - test.equal(command.data, '{"name":"Context text"}'); + test.equal(command.data, '{"name":"NATIVE"}'); test.equal(command.request.path, '/wd/hub/session/1352110219202/context'); }); }, - - + tearDown : function(callback) { this.client = null; // clean up