Skip to content
This repository
Browse code

Merge pull request #309 from bootstraponline/android_back

Add back button for Android
  • Loading branch information...
commit 7fefd941c67bfdc93a014562d327d35d5ab8ca99 2 parents 0c1a7ca + ff463c7
Jonathan Lipps jlipps authored
9 app/android.js
@@ -352,6 +352,15 @@ Android.prototype.getWindowSize = function(windowHandle, cb) {
352 352 this.proxy(["getDeviceSize"], cb);
353 353 };
354 354
  355 +Android.prototype.back = function(cb) {
  356 + this.adb.back(function() {
  357 + cb(null, {
  358 + status: status.codes.Success.code
  359 + , value: null
  360 + });
  361 + });
  362 +};
  363 +
355 364 Android.prototype.getPageIndex = function(elementId, cb) {
356 365 cb(new NotYetImplementedError(), null);
357 366 };
4 app/controller.js
@@ -349,6 +349,10 @@ exports.keyevent = function(req, res) {
349 349 req.device.keyevent(keycode, getResponseHandler(req, res));
350 350 };
351 351
  352 +exports.back = function(req, res) {
  353 + req.device.back(getResponseHandler(req, res));
  354 +};
  355 +
352 356 exports.keys = function(req, res) {
353 357 var keys = req.body.value.join('');
354 358
4 app/ios.js
@@ -900,6 +900,10 @@ IOS.prototype.getWindowSize = function(windowHandle, cb) {
900 900 }
901 901 };
902 902
  903 +IOS.prototype.back = function(cb) {
  904 + cb(new NotImplementedError(), null);
  905 +};
  906 +
903 907 IOS.prototype.getPageIndex = function(elementId, cb) {
904 908 if (this.curWindowHandle) {
905 909 cb(new NotImplementedError(), null);
2  app/routing.js
@@ -65,6 +65,7 @@ module.exports = function(appium) {
65 65 rest.post('/wd/hub/session/:sessionId?/element/:elementId?/submit', controller.submit);
66 66 rest.post('/wd/hub/session/:sessionId?/moveto', controller.moveTo);
67 67 rest.post('/wd/hub/session/:sessionId?/click', controller.clickCurrent);
  68 + rest.post('/wd/hub/session/:sessionId?/back', controller.back);
68 69
69 70 // these are for testing purposes only
70 71 rest.post('/wd/hub/produce_error', controller.produceError);
@@ -96,7 +97,6 @@ var routeNotYetImplemented = function(rest) {
96 97 rest.post('/wd/hub/session/:sessionId?/execute_async', controller.notYetImplemented);
97 98 rest.post('/wd/hub/session/:sessionId?/timeouts/async_script', controller.notYetImplemented);
98 99 rest.post('/wd/hub/session/:sessionId?/forward', controller.notYetImplemented);
99   - rest.post('/wd/hub/session/:sessionId?/back', controller.notYetImplemented);
100 100 rest.post('/wd/hub/session/:sessionId?/refresh', controller.notYetImplemented);
101 101 rest.get('/wd/hub/session/:sessionId?/ime/available_engines', controller.notYetImplemented);
102 102 rest.get('/wd/hub/session/:sessionId?/ime/active_engine', controller.notYetImplemented);
9 uiautomator/adb.js
@@ -801,6 +801,15 @@ ADB.prototype.installApp = function(cb) {
801 801 }
802 802 };
803 803
  804 +ADB.prototype.back = function(cb) {
  805 + this.requireDeviceId();
  806 + this.debug("Pressing the BACK button");
  807 + var cmd = this.adbCmd + " shell input keyevent 4";
  808 + exec(cmd, function() {
  809 + cb();
  810 + });
  811 +};
  812 +
804 813 ADB.prototype.goToHome = function(cb) {
805 814 this.requireDeviceId();
806 815 this.debug("Pressing the HOME button");

0 comments on commit 7fefd94

Please sign in to comment.
Something went wrong with that request. Please try again.