diff --git a/app/helpers.js b/app/helpers.js index 057b34fe..b9f5e2e5 100644 --- a/app/helpers.js +++ b/app/helpers.js @@ -142,3 +142,19 @@ exports.timeWarp = function(period, warp) { exports.stopTimeWarp = function() { inTimeWarp = false; }; + +exports.escapeSpecialChars = function(str) { + if (typeof str !== "string") { + return str; + } + return str + .replace(/[\\]/g, '\\\\') + .replace(/[\/]/g, '\\/') + .replace(/[\b]/g, '\\b') + .replace(/[\f]/g, '\\f') + .replace(/[\n]/g, '\\n') + .replace(/[\r]/g, '\\r') + .replace(/[\t]/g, '\\t') + .replace(/[\"]/g, '\\"') + .replace(/\\'/g, "\\'"); +}; diff --git a/app/ios.js b/app/ios.js index 0c4ca958..772b1a12 100644 --- a/app/ios.js +++ b/app/ios.js @@ -10,6 +10,7 @@ var path = require('path') , uuid = require('uuid-js') , timeWarp = require('../warp.js').timeWarp , stopTimeWarp = require('../warp.js').stopTimeWarp + , escapeSpecialChars = require('./helpers.js').escapeSpecialChars , rd = require('./hybrid/ios/remote-debugger') , status = require("./uiauto/lib/status"); @@ -364,6 +365,7 @@ IOS.prototype.findElementsFromElement = function(element, strategy, selector, cb }; IOS.prototype.setValue = function(elementId, value, cb) { + value = escapeSpecialChars(value); var command = ["au.getElement('", elementId, "').setValue('", value, "')"].join(''); this.proxy(command, cb); }; @@ -492,6 +494,7 @@ IOS.prototype.getPageIndex = function(elementId, cb) { }; IOS.prototype.keys = function(elementId, keys, cb) { + keys = escapeSpecialChars(keys); var command = ["au.sendKeysToActiveElement('", keys ,"')"].join(''); this.proxy(command, cb); }; diff --git a/app/uiauto/appium/app.js b/app/uiauto/appium/app.js index 489f7f21..0132eaa9 100644 --- a/app/uiauto/appium/app.js +++ b/app/uiauto/appium/app.js @@ -393,7 +393,7 @@ $.extend(au, { if (k === '\uE003') { // DELETE this.keyboard().keys().Delete.tap(); } else if (k === '\uE006' || k === '\uE007') {// RETURN ENTER - this.keyboard().buttons().Go.tap(); + this.keyboard().typeString("\n"); } else { this.keyboard().typeString(String(k)); // regular key } diff --git a/test/functional/appium/appiumutils.js b/test/functional/appium/appiumutils.js index 4dd211b1..06abe6ff 100644 --- a/test/functional/appium/appiumutils.js +++ b/test/functional/appium/appiumutils.js @@ -114,19 +114,4 @@ describe("appiumutils", function() { done(); }); }); - - //it.only('should test uiwebview', function(done) { - //device.proxy("au.getElementByName('Web, Use of UIWebView')", function(err, res) { - //var elId = res.value.ELEMENT; - //device.proxy("au.cache["+elId+"].tap()", function(err, res) { - //device.proxy("au.getElementByType('webview')", function(err, res) { - //var wvId = res.value.ELEMENT; - //device.proxy("au.cache["+wvId+"].type()", function(err, res) { - //console.log(res.value); - //done(); - //}); - //}); - //}); - //}); - //}); }); diff --git a/test/functional/uicatalog/execute.js b/test/functional/uicatalog/execute.js index addc60a2..5308be97 100644 --- a/test/functional/uicatalog/execute.js +++ b/test/functional/uicatalog/execute.js @@ -137,7 +137,7 @@ var loadWebView = function(driver, cb) { driver.elementByTagName('textField', function(err, elem) { elem.sendKeys("http://www.saucelabs.com/test/guinea-pig", function(err) { should.not.exist(err); - driver.keys("\\uE007", function(err) { + driver.keys("\n", function(err) { should.not.exist(err); driver.window(handles[0], function(err) { should.not.exist(err);