From 897e0bbd9701e0e6311293d9712199f8babf4dd5 Mon Sep 17 00:00:00 2001 From: Isaac Murchie Date: Fri, 2 May 2014 14:40:47 -0700 Subject: [PATCH] Fix context change --- lib/devices/ios/ios-controller.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/devices/ios/ios-controller.js b/lib/devices/ios/ios-controller.js index 0dba52d85..eefef8c1a 100644 --- a/lib/devices/ios/ios-controller.js +++ b/lib/devices/ios/ios-controller.js @@ -1497,7 +1497,7 @@ iOSController.setContext = function (name, cb, skipReadyCheck) { // allow user to pass in "WEBVIEW" without an index idx = '1'; } - this.getContexts(function () { + var pickContext = function () { if (_.contains(this.contexts, idx)) { var pageIdKey = parseInt(idx, 10); var next = function () { @@ -1538,7 +1538,16 @@ iOSController.setContext = function (name, cb, skipReadyCheck) { , value: "Context '" + name + "' does not exist" }); } - }.bind(this)); + }.bind(this); + + // only get contexts if they haven't already been gotten + if (typeof this.contexts === 'undefined') { + this.getContexts(function () { + pickContext(); + }.bind(this)); + } else { + pickContext(); + } } };