Skip to content

Commit

Permalink
Merge pull request #1829 from imurchie/isaac-accents
Browse files Browse the repository at this point in the history
Handle accented characters sent to text fields in iOS
  • Loading branch information
jlipps committed Jan 30, 2014
2 parents ba0ba4d + f4e74a7 commit c515951
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/devices/ios/uiauto/appium/element.js
Expand Up @@ -62,7 +62,11 @@ UIAElement.prototype.setValueByType = function (newValue) {
if (this.hasKeyboardFocus() === 0) {
this.tap();
}
au.sendKeysToActiveElement(newValue);
if (isAccented(newValue)) {
this.setValue(newValue);
} else {
au.sendKeysToActiveElement(newValue);
}
} else if (type === "UIAPickerWheel") {
this.selectValue(newValue);
} else if (type === "UIASlider") {
Expand All @@ -74,6 +78,18 @@ UIAElement.prototype.setValueByType = function (newValue) {
}
};

var isAccented = function (value) {
for (var i = 0; i < value.length; i++) {
var c = value.charCodeAt(i);
if (c > 127) {
// this is not simple ascii
return true;
}
}

return false;
};

UIAElement.prototype.type = function () {
var type = this.toString();
return type.substring(8, type.length - 1);
Expand Down
19 changes: 19 additions & 0 deletions test/functional/testapp/accents.js
@@ -0,0 +1,19 @@
"use strict";

var setup = require("../common/setup-base"),
desired = require('./desired');

describe('testapp - accented characters', function () {
var driver;
setup(this, desired).then(function (d) { driver = d; });

it('should send accented text', function (done) {
driver
.elementsByTagName('textField').then(function (elems) {
return elems[1];
}).then(function (elem) {
elem.sendKeys("é Œ ù ḍ");
elem.text().should.become("é Œ ù ḍ");
}).nodeify(done);
});
});

0 comments on commit c515951

Please sign in to comment.