From f7c8f9e6cbd2fa7ffe6f6a48a9c07a2fb4967be6 Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Fri, 18 Oct 2013 14:41:39 -0700 Subject: [PATCH] we don't use webatoms for android now that we use chrome --- lib/devices/android/android-controller.js | 54 +++-------------------- lib/devices/android/android.js | 23 ---------- 2 files changed, 6 insertions(+), 71 deletions(-) diff --git a/lib/devices/android/android-controller.js b/lib/devices/android/android-controller.js index cd21b355f..eefdd8a38 100644 --- a/lib/devices/android/android-controller.js +++ b/lib/devices/android/android-controller.js @@ -20,34 +20,13 @@ androidController.keyevent = function(keycode, metastate, cb) { }; androidController.findElement = function(strategy, selector, cb) { - if (this.inWebView()) { - this.findWebElementOrElements(strategy, selector, false, "", cb); - } else { - this.findUIElementOrElements(strategy, selector, false, "", cb); - } + this.findUIElementOrElements(strategy, selector, false, "", cb); }; androidController.findElements = function(strategy, selector, cb) { - if (this.inWebView()) { - this.findWebElementOrElements(strategy, selector, true, "", cb); - } else { - this.findUIElementOrElements(strategy, selector, true, "", cb); - } + this.findUIElementOrElements(strategy, selector, true, "", cb); }; -androidController.findWebElementOrElements = function(strategy, selector, many, ctx, cb) { - var ext = many ? 's' : ''; - var atomsElement = this.getAtomsElement(ctx); - var doFind = function(findCb) { - this.executeAtom('find_element' + ext, [strategy, selector, atomsElement], function(err, res) { - this.handleFindCb(err, res, many, findCb); - }.bind(this)); - }.bind(this); - this.waitForCondition(this.implicitWaitMs, doFind, cb); -}; - -androidController.getAtomsElement = deviceCommon.getAtomsElement; - androidController.findUIElementOrElements = function(strategy, selector, many, context, cb) { var params = { strategy: strategy @@ -101,19 +80,11 @@ androidController.handleFindCb = function(err, res, many, findCb) { }; androidController.findElementFromElement = function(element, strategy, selector, cb) { - if (this.inWebView()) { - this.findWebElementOrElements(strategy, selector, false, element, cb); - } else { - this.findUIElementOrElements(strategy, selector, false, element, cb); - } + this.findUIElementOrElements(strategy, selector, false, element, cb); }; androidController.findElementsFromElement = function(element, strategy, selector, cb) { - if (this.inWebView()) { - this.findWebElementOrElements(strategy, selector, true, element, cb); - } else { - this.findUIElementOrElements(strategy, selector, true, element, cb); - } + this.findUIElementOrElements(strategy, selector, true, element, cb); }; androidController.setValueImmediate = function(elementId, value, cb) { @@ -129,13 +100,7 @@ androidController.setValue = function(elementId, value, cb) { }; androidController.click = function(elementId, cb) { - if (this.inWebView()) { - this.useAtomsElement(elementId, cb, function(atomsElement) { - this.executeAtom('tap', [atomsElement], cb); - }.bind(this)); - } else { - this.proxy(["element:click", {elementId: elementId}], cb); - } + this.proxy(["element:click", {elementId: elementId}], cb); }; androidController.touchLongClick = function(elementId, cb) { @@ -623,14 +588,7 @@ androidController.clearWebView = function(cb) { }; androidController.execute = function(script, args, cb) { - if (this.inWebView()) { - this.convertElementForAtoms(args, function(err, res) { - if (err) return cb(null, res); - this.executeAtom('execute_script', [script, res], cb); - }.bind(this)); - } else { - cb(new NotYetImplementedError(), null); - } + cb(new NotYetImplementedError(), null); }; androidController.convertElementForAtoms = deviceCommon.convertElementForAtoms; diff --git a/lib/devices/android/android.js b/lib/devices/android/android.js index 992337db3..15b979fdd 100644 --- a/lib/devices/android/android.js +++ b/lib/devices/android/android.js @@ -39,7 +39,6 @@ Android.prototype.initialize = function(opts) { this.swipeStepsPerSec = 28; this.asyncWaitMs = 0; this.remote = null; - this.webElementIds = []; this.curWindowHandle = null; this.capabilities = { platform: 'LINUX' @@ -52,10 +51,6 @@ Android.prototype.initialize = function(opts) { }; }; -Android.prototype.inWebView = function() { - return this.curWindowHandle !== null; -}; - // Clear data, close app, then start app. Android.prototype.fastReset = function(cb) { async.series([ @@ -260,24 +255,6 @@ Android.prototype.push = function(elem) { Android.prototype.waitForCondition = deviceCommon.waitForCondition; -Android.prototype.executeAtom = function(atom, args, cb, alwaysDefaultFrame) { - var frames = alwaysDefaultFrame === true ? [] : this.curWebFrames; - this.returnedFromExecuteAtom = false; - this.processingRemoteCmd = true; - this.remote.executeAtom(atom, args, frames, function(err, res) { - this.processingRemoteCmd = false; - if (!this.returnedFromExecuteAtom) { - this.returnedFromExecuteAtom = true; - res = this.parseExecuteResponse(res); - cb(err, res); - } - }.bind(this)); -}; - -Android.prototype.parseExecuteResponse = deviceCommon.parseExecuteResponse; -Android.prototype.parseElementResponse = deviceCommon.parseElementResponse; -Android.prototype.useAtomsElement = deviceCommon.useAtomsElement; - Android.prototype.setCommandTimeout = function(secs, cb) { logger.info("Setting command timeout for android to " + secs + " secs"); this.origCommandTimeoutMs = this.commandTimeoutMs;