Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #309 from bootstraponline/android_back

Add back button for Android
  • Loading branch information...
commit 7fefd941c67bfdc93a014562d327d35d5ab8ca99 2 parents 0c1a7ca + ff463c7
@jlipps jlipps authored
View
9 app/android.js
@@ -352,6 +352,15 @@ Android.prototype.getWindowSize = function(windowHandle, cb) {
this.proxy(["getDeviceSize"], cb);
};
+Android.prototype.back = function(cb) {
+ this.adb.back(function() {
+ cb(null, {
+ status: status.codes.Success.code
+ , value: null
+ });
+ });
+};
+
Android.prototype.getPageIndex = function(elementId, cb) {
cb(new NotYetImplementedError(), null);
};
View
4 app/controller.js
@@ -349,6 +349,10 @@ exports.keyevent = function(req, res) {
req.device.keyevent(keycode, getResponseHandler(req, res));
};
+exports.back = function(req, res) {
+ req.device.back(getResponseHandler(req, res));
+};
+
exports.keys = function(req, res) {
var keys = req.body.value.join('');
View
4 app/ios.js
@@ -900,6 +900,10 @@ IOS.prototype.getWindowSize = function(windowHandle, cb) {
}
};
+IOS.prototype.back = function(cb) {
+ cb(new NotImplementedError(), null);
+};
+
IOS.prototype.getPageIndex = function(elementId, cb) {
if (this.curWindowHandle) {
cb(new NotImplementedError(), null);
View
2  app/routing.js
@@ -65,6 +65,7 @@ module.exports = function(appium) {
rest.post('/wd/hub/session/:sessionId?/element/:elementId?/submit', controller.submit);
rest.post('/wd/hub/session/:sessionId?/moveto', controller.moveTo);
rest.post('/wd/hub/session/:sessionId?/click', controller.clickCurrent);
+ rest.post('/wd/hub/session/:sessionId?/back', controller.back);
// these are for testing purposes only
rest.post('/wd/hub/produce_error', controller.produceError);
@@ -96,7 +97,6 @@ var routeNotYetImplemented = function(rest) {
rest.post('/wd/hub/session/:sessionId?/execute_async', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/timeouts/async_script', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/forward', controller.notYetImplemented);
- rest.post('/wd/hub/session/:sessionId?/back', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/refresh', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/ime/available_engines', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/ime/active_engine', controller.notYetImplemented);
View
9 uiautomator/adb.js
@@ -801,6 +801,15 @@ ADB.prototype.installApp = function(cb) {
}
};
+ADB.prototype.back = function(cb) {
+ this.requireDeviceId();
+ this.debug("Pressing the BACK button");
+ var cmd = this.adbCmd + " shell input keyevent 4";
+ exec(cmd, function() {
+ cb();
+ });
+};
+
ADB.prototype.goToHome = function(cb) {
this.requireDeviceId();
this.debug("Pressing the HOME button");
Please sign in to comment.
Something went wrong with that request. Please try again.