зеркало из https://github.com/microsoft/appium.git
Merge pull request #177 from jlipps/master
fix keyboard action-triggering behavior
This commit is contained in:
Коммит
2d00e09570
|
@ -142,3 +142,19 @@ exports.timeWarp = function(period, warp) {
|
||||||
exports.stopTimeWarp = function() {
|
exports.stopTimeWarp = function() {
|
||||||
inTimeWarp = false;
|
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, "\\'");
|
||||||
|
};
|
||||||
|
|
|
@ -10,6 +10,7 @@ var path = require('path')
|
||||||
, uuid = require('uuid-js')
|
, uuid = require('uuid-js')
|
||||||
, timeWarp = require('../warp.js').timeWarp
|
, timeWarp = require('../warp.js').timeWarp
|
||||||
, stopTimeWarp = require('../warp.js').stopTimeWarp
|
, stopTimeWarp = require('../warp.js').stopTimeWarp
|
||||||
|
, escapeSpecialChars = require('./helpers.js').escapeSpecialChars
|
||||||
, rd = require('./hybrid/ios/remote-debugger')
|
, rd = require('./hybrid/ios/remote-debugger')
|
||||||
, status = require("./uiauto/lib/status");
|
, status = require("./uiauto/lib/status");
|
||||||
|
|
||||||
|
@ -364,6 +365,7 @@ IOS.prototype.findElementsFromElement = function(element, strategy, selector, cb
|
||||||
};
|
};
|
||||||
|
|
||||||
IOS.prototype.setValue = function(elementId, value, cb) {
|
IOS.prototype.setValue = function(elementId, value, cb) {
|
||||||
|
value = escapeSpecialChars(value);
|
||||||
var command = ["au.getElement('", elementId, "').setValue('", value, "')"].join('');
|
var command = ["au.getElement('", elementId, "').setValue('", value, "')"].join('');
|
||||||
this.proxy(command, cb);
|
this.proxy(command, cb);
|
||||||
};
|
};
|
||||||
|
@ -492,6 +494,7 @@ IOS.prototype.getPageIndex = function(elementId, cb) {
|
||||||
};
|
};
|
||||||
|
|
||||||
IOS.prototype.keys = function(elementId, keys, cb) {
|
IOS.prototype.keys = function(elementId, keys, cb) {
|
||||||
|
keys = escapeSpecialChars(keys);
|
||||||
var command = ["au.sendKeysToActiveElement('", keys ,"')"].join('');
|
var command = ["au.sendKeysToActiveElement('", keys ,"')"].join('');
|
||||||
this.proxy(command, cb);
|
this.proxy(command, cb);
|
||||||
};
|
};
|
||||||
|
|
|
@ -382,7 +382,7 @@ $.extend(au, {
|
||||||
if (k === '\uE003') { // DELETE
|
if (k === '\uE003') { // DELETE
|
||||||
this.keyboard().keys().Delete.tap();
|
this.keyboard().keys().Delete.tap();
|
||||||
} else if (k === '\uE006' || k === '\uE007') {// RETURN ENTER
|
} else if (k === '\uE006' || k === '\uE007') {// RETURN ENTER
|
||||||
this.keyboard().buttons().Go.tap();
|
this.keyboard().typeString("\n");
|
||||||
} else {
|
} else {
|
||||||
this.keyboard().typeString(String(k)); // regular key
|
this.keyboard().typeString(String(k)); // regular key
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,19 +114,4 @@ describe("appiumutils", function() {
|
||||||
done();
|
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();
|
|
||||||
//});
|
|
||||||
//});
|
|
||||||
//});
|
|
||||||
//});
|
|
||||||
//});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -137,7 +137,7 @@ var loadWebView = function(driver, cb) {
|
||||||
driver.elementByTagName('textField', function(err, elem) {
|
driver.elementByTagName('textField', function(err, elem) {
|
||||||
elem.sendKeys("http://www.saucelabs.com/test/guinea-pig", function(err) {
|
elem.sendKeys("http://www.saucelabs.com/test/guinea-pig", function(err) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
driver.keys("\\uE007", function(err) {
|
driver.keys("\n", function(err) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
driver.window(handles[0], function(err) {
|
driver.window(handles[0], function(err) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче