From c482736b41d7f1568cbef574b4ed94e8593dcae6 Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Wed, 27 Mar 2013 11:46:25 -0700 Subject: [PATCH] add refresh() and a weak test for it --- app/android.js | 4 ++++ app/controller.js | 4 ++++ app/hybrid/ios/remote-debugger.js | 4 +++- app/ios.js | 10 +++++++++- app/routing.js | 2 +- test/helpers/webview.js | 11 +++++++++++ 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/android.js b/app/android.js index 614bdf0fa..26ce18085 100644 --- a/app/android.js +++ b/app/android.js @@ -356,6 +356,10 @@ Android.prototype.forward = function(cb) { cb(new NotYetImplementedError(), null); }; +Android.prototype.refresh = function(cb) { + cb(new NotYetImplementedError(), null); +}; + Android.prototype.getPageIndex = function(elementId, cb) { cb(new NotYetImplementedError(), null); }; diff --git a/app/controller.js b/app/controller.js index 80dd70f3e..5e1d5ca23 100644 --- a/app/controller.js +++ b/app/controller.js @@ -367,6 +367,10 @@ exports.forward = function(req, res) { req.device.forward(getResponseHandler(req, res)); }; +exports.refresh = function(req, res) { + req.device.refresh(getResponseHandler(req, res)); +}; + exports.keys = function(req, res) { var keys = req.body.value.join(''); diff --git a/app/hybrid/ios/remote-debugger.js b/app/hybrid/ios/remote-debugger.js index 984337207..ba06110b5 100644 --- a/app/hybrid/ios/remote-debugger.js +++ b/app/hybrid/ios/remote-debugger.js @@ -194,7 +194,9 @@ RemoteDebugger.prototype.executeAtom = function(atom, args, frames, cb) { if (atom === "title") { atomSrc = "function(){return JSON.stringify({status: 0, value: document.title});}"; } else if (atom === "element_equals_element") { - var atomSrc = this.wrapElementEqualsElementAtom(args); + atomSrc = this.wrapElementEqualsElementAtom(args); + } else if (atom === "refresh") { + atomSrc = "function(){return JSON.stringify({status: 0, value: window.location.reload()});}"; } else { atomSrc = atoms.get(atom); } diff --git a/app/ios.js b/app/ios.js index 8b2a90ff2..13db3649e 100644 --- a/app/ios.js +++ b/app/ios.js @@ -1000,6 +1000,14 @@ IOS.prototype.forward = function(cb) { } }; +IOS.prototype.refresh = function(cb) { + if (this.curWindowHandle === null) { + cb(new NotImplementedError(), null); + } else { + this.executeAtom('refresh', [], cb); + } +}; + IOS.prototype.getPageIndex = function(elementId, cb) { if (this.curWindowHandle) { cb(new NotImplementedError(), null); @@ -1552,7 +1560,7 @@ IOS.prototype.equalsWebElement = function(element, other, cb) { // ...otherwise let the browser tell us. this.executeAtom('element_equals_element', [ctxElem.ELEMENT, otherElem.ELEMENT], cb); } - + cb(null, { status: retStatus , value: retValue diff --git a/app/routing.js b/app/routing.js index 2d71f18c8..b27f0a2be 100644 --- a/app/routing.js +++ b/app/routing.js @@ -69,6 +69,7 @@ module.exports = function(appium) { rest.post('/wd/hub/session/:sessionId?/click', controller.clickCurrent); rest.post('/wd/hub/session/:sessionId?/back', controller.back); rest.post('/wd/hub/session/:sessionId?/forward', controller.forward); + rest.post('/wd/hub/session/:sessionId?/refresh', controller.refresh); // these are for testing purposes only rest.post('/wd/hub/produce_error', controller.produceError); @@ -99,7 +100,6 @@ var routeNotYetImplemented = function(rest) { rest.post('/wd/hub/session/:sessionId?/timeouts', controller.notYetImplemented); 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?/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); rest.get('/wd/hub/session/:sessionId?/ime/activated', controller.notYetImplemented); diff --git a/test/helpers/webview.js b/test/helpers/webview.js index c8edaed5f..fb0f1407f 100644 --- a/test/helpers/webview.js +++ b/test/helpers/webview.js @@ -959,5 +959,16 @@ module.exports.buildTests = function(webviewType) { }); }); }); + + desc('refresh', function(h) { + it('should be able to refresh', function(done) { + loadWebView(h.driver, function() { + h.driver.refresh(function(err) { + should.not.exist(err); + done(); + }); + }); + }); + }); };