From 2fa6443e479a3b86967309e88c9cf357b1381f62 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Wed, 29 Jan 2014 13:12:04 -0500 Subject: [PATCH] Escape single quotes for iOS id search Fixes: Selenium::WebDriver::Error::JavascriptError: Unable to parse the format string --- lib/devices/ios/ios-controller.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/devices/ios/ios-controller.js b/lib/devices/ios/ios-controller.js index 752e34dcc0d..f9d86185f07 100644 --- a/lib/devices/ios/ios-controller.js +++ b/lib/devices/ios/ios-controller.js @@ -48,6 +48,7 @@ iOSController.findUIElementOrElements = function(strategy, selector, ctx, many, } else if (strategy === "xpath") { command = ["au.getElement", ext, "ByXpath('", selector, "'", ctx, ")"].join(''); } else if (strategy === "id") { + selector = selector.replace(/'/g, "\\\\'"); // must escape single quotes command = ["var exact = au.mainApp.getFirstWithPredicateWeighted(\"name == '", selector, "' || label == '", selector, "' || value == '", selector, "'\");"].join(''); command += ["exact && exact.status == 0 ? exact : au.mainApp.getFirstWith",