Skip to content

Commit

Permalink
Enhance click (#113)
Browse files Browse the repository at this point in the history
* feat: click支持更多参数

---------

Co-authored-by: xudafeng <[email protected]>
  • Loading branch information
yihuineng and xudafeng authored Sep 16, 2023
1 parent 2c23fec commit a9d5eff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 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": "4.1.0",
"version": "4.2.0",
"description": "Macaca webdirver API for Node.js",
"keywords": [
"macaca",
Expand Down
8 changes: 6 additions & 2 deletions wd/lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -1616,11 +1616,15 @@ commands.getValue = function() {
*
* @jsonWire POST /session/:sessionId/element/:id/click
*/
commands.clickElement = function(element) {
const cb = findCallback(arguments);
commands.clickElement = function() {
const fargs = utils.varargs(arguments);
const cb = fargs.callback;
const element = fargs.all[0];
const params = fargs.all[1] || {};
this._jsonWireCall({
method: 'POST',
relPath: '/element/' + element + '/click',
data: { clickOpts: params },
cb: simpleCallback(cb)
});
};
Expand Down
7 changes: 5 additions & 2 deletions wd/lib/element-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ elementCommands.replaceKeys = function (keys, cb) {
*
* @jsonWire POST /session/:sessionId/element/:id/click
*/
elementCommands.click = function (cb) {
commands.clickElement.apply(this.browser, [this, cb]);
elementCommands.click = function () {
const fargs = utils.varargs(arguments);
const cb = fargs.callback;
const clickOpts = fargs.all[0] || {};
commands.clickElement.apply(this.browser, [this, clickOpts, cb]);
};

/**
Expand Down

0 comments on commit a9d5eff

Please sign in to comment.