add rest endpoints to handle mobile: methods in addition to executeScript

This commit is contained in:
Jonathan Lipps
2014-04-02 12:15:34 -07:00
parent e9bd1403d1
commit bf4dcae4f1
3 changed files with 44 additions and 10 deletions
+2 -2
View File
@@ -1272,10 +1272,10 @@ iOSController.scrollTo = function (elementId, text, direction, cb) {
iOSController.scroll = function (elementId, direction, cb) {
direction = direction.charAt(0).toUpperCase() + direction.slice(1);
// By default, scroll the first scrollview.
// By default, scroll the first scrollview.
var command = "au.scrollFirstView('" + direction + "')";
if (elementId) {
// if elementId is defined, call scrollLeft, scrollRight, scrollUp, and scrollDown on the element.
// if elementId is defined, call scrollLeft, scrollRight, scrollUp, and scrollDown on the element.
command = ["au.getElement('", elementId, "').scroll", direction, "()"].join('');
}
this.proxy(command, cb);
+21 -2
View File
@@ -87,8 +87,9 @@ exports.installApp = function (req, res) {
};
exports.removeApp = function (req, res) {
if (checkMissingParams(res, {bundleId: req.body.bundleId}, true)) {
req.device.removeApp(req.body.bundleId, function (error, response) {
req.body.appId = req.body.appId || req.body.bundleId;
if (checkMissingParams(res, {appId: req.body.appId}, true)) {
req.device.removeApp(req.body.appId, function (error, response) {
if (error !== null) {
respondError(req, res, response);
} else {
@@ -687,6 +688,24 @@ exports.asyncScriptTimeout = function (req, res) {
req.device.asyncScriptTimeout(ms, getResponseHandler(req, res));
};
exports.timeouts = function (req, res) {
var timeoutType = req.body.type
, ms = req.body.ms;
if (checkMissingParams(res, {type: timeoutType, ms: ms})) {
if (timeoutType === "implicit") {
exports.implicitWait(req, res);
} else if (timeoutType === "script") {
exports.asyncScriptTimeout(req, res);
} else if (timeoutType === "command") {
var secs = parseInt(ms, 10) / 1000;
req.appium.setCommandTimeout(secs, getResponseHandler(req, res));
} else {
respondError(req, res, status.codes.UnknownCommand.code,
new Error("Invalid timeout '" + timeoutType + "'"));
}
}
};
exports.setOrientation = function (req, res) {
var orientation = req.body.orientation;
req.device.setOrientation(orientation, getResponseHandler(req, res));
+21 -6
View File
@@ -78,6 +78,7 @@ module.exports = function (appium) {
rest.delete('/wd/hub/session/:sessionId?/cookie/:name', controller.deleteCookie);
rest.post('/wd/hub/session/:sessionId?/log', controller.getLog);
rest.get('/wd/hub/session/:sessionId?/log/types', controller.getLogTypes);
rest.post('/wd/hub/session/:sessionId?/timeouts', controller.timeouts);
// allow appium to receive async response
rest.post('/wd/hub/session/:sessionId?/receive_async_response', controller.receiveAsyncResponse);
@@ -87,11 +88,26 @@ module.exports = function (appium) {
rest.all('/test/guinea-pig', controller.guineaPig);
// appium-specific extensions to JSONWP
// these aren't part of JSONWP but we want them or something like them to be
rest.post('/wd/hub/session/:sessionId/touch/tap', controller.mobileTap);
rest.post('/wd/hub/session/:sessionId/touch/flick_precise', controller.mobileFlick);
rest.post('/wd/hub/session/:sessionId/touch/swipe', controller.mobileSwipe);
rest.post('/wd/hub/session/:sessionId/touch/drag', controller.mobileDrag);
rest.post('/wd/hub/session/:sessionId?/appium/device/shake', controller.mobileShake);
rest.post('/wd/hub/session/:sessionId?/appium/device/lock', controller.lock);
rest.post('/wd/hub/session/:sessionId?/appium/device/keyevent', controller.keyevent);
rest.post('/wd/hub/session/:sessionId?/appium/device/rotate', controller.mobileRotation);
rest.get('/wd/hub/session/:sessionId?/appium/device/current_activity', controller.getCurrentActivity);
rest.post('/wd/hub/session/:sessionId?/appium/device/install_app', controller.installApp);
rest.post('/wd/hub/session/:sessionId?/appium/device/remove_app', controller.removeApp);
rest.get('/wd/hub/session/:sessionId?/appium/device/app_installed', controller.isAppInstalled);
rest.post('/wd/hub/session/:sessionId?/appium/device/push_file', controller.pushFile);
rest.get('/wd/hub/session/:sessionId?/appium/device/pull_file', controller.pullFile);
rest.post('/wd/hub/session/:sessionId?/appium/app/launch', controller.launchApp);
rest.post('/wd/hub/session/:sessionId?/appium/app/close', controller.closeApp);
rest.post('/wd/hub/session/:sessionId?/appium/app/reset', controller.reset);
rest.post('/wd/hub/session/:sessionId?/appium/app/background', controller.background);
rest.post('/wd/hub/session/:sessionId?/appium/app/end_test_coverage', controller.endCoverage);
rest.post('/wd/hub/session/:sessionId?/appium/app/complex_find', controller.find);
rest.get('/wd/hub/session/:sessionId?/appium/app/strings', controller.getStrings);
rest.post('/wd/hub/session/:sessionId?/appium/element/:elementId?/value', controller.setValue);
// keep this at the very end!
rest.all('/*', controller.unknownCommand);
@@ -104,7 +120,6 @@ var routeNotYetImplemented = function (rest) {
rest.get('/wd/hub/session/:sessionId?/local_storage/key/:key', controller.notYetImplemented);
rest.delete('/wd/hub/session/:sessionId?/local_storage/key/:key', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/local_storage/size', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/timeouts', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/ime/available_engines', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/ime/active_engine', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/ime/activated', controller.notYetImplemented);