Added setValue like a boss.

This commit is contained in:
Sebastian Tiedtke
2013-01-12 16:57:48 -08:00
parent 9e5d92c5e3
commit 6f638db3c5
3 changed files with 24 additions and 2 deletions

View File

@@ -89,8 +89,12 @@ Appium.prototype.push = function(elem) {
me.instruments.sendCommand(target[0], function(result) {
if (typeof target[1] === 'function') {
var jsonresult = JSON.parse(result);
target[1](jsonresult);
if (result === 'undefined') {
target[1]();
} else {
var jsonresult = JSON.parse(result);
target[1](jsonresult);
}
}
// maybe there's moar work to do

View File

@@ -102,3 +102,20 @@ exports.findElements = function(req, res) {
res.send(result);
});
};
exports.setValue = function(req, res) {
var sessionId = req.params.sessionId
, elementId = req.params.elementId
, body = req.body.value.join('')
, status = 0;
var command = ["elements['", elementId, "'].setValue('", body, "')"].join('');
req.appium.proxy(command, function(json) {
res.send({
sessionId: req.appium.sessionId
, status: status
, value: ''
});
});
};

View File

@@ -16,4 +16,5 @@ module.exports = function(appium) {
rest.delete('/wd/hub/session/:sessionId?', controller.deleteSession);
rest.post('/wd/hub/session/:sessionId?/execute', controller.executeScript);
rest.post('/wd/hub/session/:sessionId?/elements', controller.findElements);
rest.post('/wd/hub/session/:sessionId?/element/:elementId?/value', controller.setValue);
};