mirror of
https://github.com/appium/appium.git
synced 2026-10-23 17:19:04 +08:00
mobile: reset
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
"use strict";
|
||||
var status = require('./uiauto/lib/status')
|
||||
, logger = require('../logger.js').get('appium')
|
||||
, glob = require('glob')
|
||||
, rimraf = require('rimraf')
|
||||
, _s = require("underscore.string")
|
||||
, _ = require('underscore');
|
||||
|
||||
@@ -119,7 +121,12 @@ exports.getStatus = function(req, res) {
|
||||
};
|
||||
|
||||
exports.createSession = function(req, res) {
|
||||
if (typeof req.body === 'string') {
|
||||
req.body = JSON.parse(req.body);
|
||||
}
|
||||
|
||||
var desired = req.body.desiredCapabilities;
|
||||
|
||||
var next = function(sessionId, device, preLaunched) {
|
||||
var redirect = function() {
|
||||
res.set('Location', "/wd/hub/session/" + sessionId);
|
||||
@@ -159,6 +166,37 @@ exports.getSessions = function(req, res) {
|
||||
[{id: req.appium.sessionId , capabilities: req.device.capabilities}]);
|
||||
};
|
||||
|
||||
exports.reset = function(req, res) {
|
||||
logger.info("Reset. Closing App.");
|
||||
var oldId = req.appium.sessionId;
|
||||
|
||||
req.device.proxy('au.bundleId()', function(err, bId) {
|
||||
var bundleId = bId.value;
|
||||
var user = process.env.USER;
|
||||
logger.info("Deleting plist for bundle: " + bundleId);
|
||||
logger.info("User is: " + user);
|
||||
|
||||
req.appium.stop(function(){
|
||||
glob("/Users/" + user + "/Library/Application Support/iPhone Simulator/**/" +
|
||||
bundleId + ".plist", {}, function(err, files) {
|
||||
if (err) {
|
||||
logger.error("Could not remove plist: " + err.message);
|
||||
} else {
|
||||
_.each(files, function(file) {
|
||||
rimraf(file, function() {
|
||||
logger.info("Deleted " + file);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
logger.info("Starting app.");
|
||||
exports.createSession(req, res);
|
||||
req.appium.sessionId = oldId;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.deleteSession = function(req, res) {
|
||||
req.appium.stop(getResponseHandler(req, res));
|
||||
};
|
||||
@@ -541,6 +579,7 @@ var mobileCmdMap = {
|
||||
, 'setCommandTimeout': exports.setCommandTimeout
|
||||
, 'getCommandTimeout': exports.getCommandTimeout
|
||||
, 'setValue' : exports.setValueImmediate
|
||||
, 'reset' : exports.reset
|
||||
};
|
||||
|
||||
exports.produceError = function(req, res) {
|
||||
|
||||
Reference in New Issue
Block a user