Skip to content

Instantly share code, notes, and snippets.

@thu2004
Created November 27, 2014 20:53
Show Gist options
  • Save thu2004/1980155888eb677a37bd to your computer and use it in GitHub Desktop.
Save thu2004/1980155888eb677a37bd to your computer and use it in GitHub Desktop.
Selendroid.prototype.pinchClose = function (startX, startY, endX, endY, duration,
percent, steps, elId, cb) {
var command;
var fromPointObject = {'x' : startX, 'y' : startY};
var toPointObject = {'x' : endX, 'y' : endY};
var moveX = (endX - startX)/4
var moveY = (endY - startY)/4
if (elId) {
return cb(new NotYetImplementedError(), null);
}
var reqUrl = this.proxyHost + ':' + this.proxyPort +
'/wd/hub/session/' + this.proxySessionId +
'/actions/';
var json_v =
{"payload":[
{"id":"","inputDevice":"touch",
"actions":[
{"name":"pointerDown","y":startY,"x":startX},
{"name":"pause","ms":1000},
{"name":"pointerMove","y":startY,"x":startX+moveX},
{"name":"pointerUp"}
]},
{"id":"","inputDevice":"touch",
"actions":[
{"name":"pointerDown","y":endY,"x":endX},
{"name":"pause","ms":1000},
{"name":"pointerMove","y":endY,"x":endX-moveX},
{"name":"pointerUp"}
]}
]};
doRequest(reqUrl, 'POST', json_v, null, function (err) {
if (err) return cb(err);
cb(null, {
status: status.codes.Success.code,
value: ''
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment