зеркало из https://github.com/microsoft/appium.git
Merge branch 'master' of github.com:appium/appium
This commit is contained in:
Коммит
f0c438809e
|
@ -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, "\\'");
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
//});
|
||||
//});
|
||||
//});
|
||||
//});
|
||||
//});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче