Skip to content

Commit

Permalink
feat: add getProperty method
Browse files Browse the repository at this point in the history
  • Loading branch information
ziczhu committed Jul 20, 2016
1 parent 07803b9 commit e6cd13d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "macaca-wd",
"version": "1.0.5",
"version": "1.0.6",
"description": "macaca wd client",
"keywords": [
"macaca",
Expand Down
20 changes: 20 additions & 0 deletions wd/lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,26 @@ commands.getAttribute = function() {
});
};

/**
* getProperty(element, propertyName, cb) -> cb(err, value)
*
* @jsonWire GET /session/:sessionId/element/:id/property/:name
* @docOrder 1
*/
commands.getProperty = function() {
var fargs = utils.varargs(arguments);
var cb = fargs.callback,
element = fargs.all[0],
propertyName = fargs.all[1];
if(!element) { throw new Error('Missing element.'); }
if(!propertyName) { throw new Error('Missing property name.'); }
this._jsonWireCall({
method: 'GET'
, relPath: '/element/' + element + '/property/' + propertyName
, cb: callbackWithData(cb, this)
});
};

/**
* isDisplayed(element, cb) -> cb(err, displayed)
*
Expand Down
14 changes: 12 additions & 2 deletions wd/lib/element-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var _ = require("./lodash")
elementCallback = callbacks.elementCallback,
elementsCallback = callbacks.elementsCallback,
commands = require('./commands');

var elementCommands = {};

/**
Expand Down Expand Up @@ -178,6 +178,16 @@ elementCommands.getAttribute = function(name, cb) {
commands.getAttribute.apply(this.browser, [this, name, cb]);
};

/**
* element.getProperty(propertyName, cb) -> cb(err, value)
*
* @jsonWire GET /session/:sessionId/element/:id/property/:name
* @docOrder 2
*/
elementCommands.getProperty = function(name, cb) {
commands.getProperty.apply(this.browser, [this, name, cb]);
};

/**
* element.getTagName(cb) -> cb(err, name)
*
Expand Down Expand Up @@ -408,7 +418,7 @@ elementCommands.performMultiAction = function (actions, cb) {
* element.rotate(opts, cb) -> cb(err)
* opts is like the following:
* {x: 114, y: 198, duration: 5, radius: 3, rotation: 220, touchCount: 2}
*
*
* @jsonWire POST /session/:sessionId/appium/device/rotate
*/
elementCommands.rotate = function(opts, cb) {
Expand Down

0 comments on commit e6cd13d

Please sign in to comment.