testdriverai 4.1.24 → 4.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/commander.js CHANGED
@@ -72,14 +72,13 @@ commands:
72
72
  response = await commands.wait(object.timeout);
73
73
  break;
74
74
  case "click":
75
- speak(`${object.button} ${object.click} click`);
75
+ speak(`${object.action}`);
76
76
  log("info", generator.jsonToManual(object));
77
77
  notify(generator.jsonToManual(object, false));
78
78
  response = await commands["click"](
79
79
  object.x,
80
80
  object.y,
81
- object.button,
82
- object.click,
81
+ object.action,
83
82
  );
84
83
  break;
85
84
  case "hover":
@@ -112,9 +111,7 @@ commands:
112
111
  notify(generator.jsonToManual(object, false));
113
112
  response = await commands["match-image"](
114
113
  object.path,
115
- object.action,
116
- object.button,
117
- object.click,
114
+ object.action
118
115
  );
119
116
  break;
120
117
  case "wait-for-image":
package/lib/commands.js CHANGED
@@ -188,19 +188,43 @@ const scroll = async (direction = "down", amount = 300) => {
188
188
  };
189
189
 
190
190
  // perform a mouse click
191
- const click = async (x, y, button = "left", click = "single") => {
191
+ // click, right-click, double-click, hover
192
+ const click = async (x, y, action = "click") => {
192
193
  await redraw.start();
193
194
 
195
+ let button = 'left';
196
+ let double = false;
197
+
198
+ if (action === "right-click" && process.platform !== "darwin" ) {
199
+ button = "right";
200
+ }
201
+ if (action === "double-click") {
202
+ double = true;
203
+ }
204
+
194
205
  log("debug", chalk.dim(`${click} ${button} clicking at ${x}, ${y}...`), true);
195
206
 
196
207
  x = parseInt(x);
197
208
  y = parseInt(y);
198
209
 
199
- let double = click == "double" ? true : false;
200
210
  robot.moveMouseSmooth(x, y, 0.1);
211
+
201
212
  await delay(1000); // wait for the mouse to move
202
- robot.mouseClick(button, double);
203
- emitter.emit(events.mouseClick, { x, y, button, click });
213
+
214
+ if (process.platform === "darwin" && action === "right-click") {
215
+ robot.keyToggle('control', 'down', 'control');
216
+ await delay(250);
217
+ }
218
+
219
+ if (action !== "hover") {
220
+ robot.mouseClick(button, double);
221
+ emitter.emit(events.mouseClick, { x, y, button, click });
222
+ }
223
+
224
+ if (process.platform === "darwin" && action === "right-click") {
225
+ await delay(250);
226
+ robot.keyToggle('control', 'up', 'control');
227
+ }
204
228
 
205
229
  await redraw.wait(5000);
206
230
  return;
@@ -231,8 +255,6 @@ let commands = {
231
255
  text,
232
256
  description = null,
233
257
  action = "click",
234
- button = "left",
235
- clickType = "single",
236
258
  method = "turbo",
237
259
  ) => {
238
260
  text = text ? text.toString() : null;
@@ -250,8 +272,6 @@ let commands = {
250
272
  method,
251
273
  image: await captureScreenBase64(),
252
274
  intent: action,
253
- button,
254
- clickType,
255
275
  description,
256
276
  displayMultiple: 1,
257
277
  },
@@ -275,8 +295,6 @@ let commands = {
275
295
  "hover-image": async (
276
296
  description,
277
297
  action = "click",
278
- button = "left",
279
- clickType = "single",
280
298
  ) => {
281
299
  // take a screenshot
282
300
  log("info", "");
@@ -290,8 +308,6 @@ let commands = {
290
308
  needle: description,
291
309
  image: await captureScreenBase64(),
292
310
  intent: action,
293
- button,
294
- clickType,
295
311
  displayMultiple: 1,
296
312
  },
297
313
  (chunk) => {
@@ -312,9 +328,7 @@ let commands = {
312
328
  },
313
329
  "match-image": async (
314
330
  relativePath,
315
- action = "click",
316
- button = "left",
317
- clickType = "single",
331
+ action = "click"
318
332
  ) => {
319
333
  let image = await captureScreenPNG();
320
334
 
@@ -324,7 +338,7 @@ let commands = {
324
338
  throw new AiError(`Image not found: ${relativePath}`);
325
339
  } else {
326
340
  if (action === "click") {
327
- await click(result.centerX, result.centerY, button, clickType);
341
+ await click(result.centerX, result.centerY, action);
328
342
  } else if (action === "hover") {
329
343
  await hover(result.centerX, result.centerY);
330
344
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.1.24",
3
+ "version": "4.1.26",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {