testdriverai 4.0.29 → 4.0.31

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.
Files changed (2) hide show
  1. package/lib/commands.js +39 -31
  2. package/package.json +1 -1
package/lib/commands.js CHANGED
@@ -190,7 +190,41 @@ const scroll = async(direction = 'down', amount = 300) => {
190
190
  }
191
191
  }
192
192
 
193
+ // perform a mouse click
194
+ const click = async(x, y, button = 'left', click = 'single') => {
195
+
196
+ await redraw.start();
197
+
198
+ log('debug', chalk.dim(`${click} ${button} clicking at ${x}, ${y}...`), true)
199
+
200
+ x = parseInt(x);
201
+ y = parseInt(y);
202
+
203
+ let double = click == 'double' ? true : false;
204
+ robot.moveMouseSmooth(x, y, .1);
205
+ await delay(1000); // wait for the mouse to move
206
+ robot.mouseClick(button, double);
207
+ await redraw.wait(2000);
208
+ return;
209
+ };
210
+
211
+ const hover = async(x, y) => {
212
+
213
+ await redraw.start();
214
+
215
+ x = parseInt(x);
216
+ y = parseInt(y);
217
+
218
+ await robot.moveMouseSmooth(x, y, .1);
219
+ await redraw.wait(2000);
220
+
221
+ return;
222
+ }
223
+
193
224
  let commands = {
225
+ scroll: scroll,
226
+ click: click,
227
+ hover: hover,
194
228
  // method, levenshein, dice, or combined
195
229
  // leven = this is turbo, all around good for text similarity
196
230
  // dice = this is good for short strings, but not as good for long strings
@@ -248,35 +282,6 @@ let commands = {
248
282
  }
249
283
 
250
284
  },
251
- // perform a mouse click
252
- click: async(x, y, button = 'left', click = 'single') => {
253
-
254
- await redraw.start();
255
-
256
- log('debug', chalk.dim(`${click} ${button} clicking at ${x}, ${y}...`), true)
257
-
258
- x = parseInt(x);
259
- y = parseInt(y);
260
-
261
- let double = click == 'double' ? true : false;
262
- robot.moveMouseSmooth(x, y, .1);
263
- await delay(1000); // wait for the mouse to move
264
- robot.mouseClick(button, double);
265
- await redraw.wait(2000);
266
- return;
267
- },
268
- hover: async(x, y) => {
269
-
270
- await redraw.start();
271
-
272
- x = parseInt(x);
273
- y = parseInt(y);
274
-
275
- await robot.moveMouseSmooth(x, y, .1);
276
- await redraw.wait(2000);
277
-
278
- return;
279
- },
280
285
  "match-image": async(relativePath, action = 'click', button = 'left', clickType = 'single') => {
281
286
 
282
287
  let image = await captureScreenPNG()
@@ -289,7 +294,11 @@ let commands = {
289
294
  throw new AiError(`Image not found: ${relativePath}`)
290
295
  } else {
291
296
 
292
- await routeClick(result.centerX * displayMultiple, result.centerY * displayMultiple, action, button, clickType);
297
+ if (action === 'click') {
298
+ await click(result.centerX * displayMultiple, result.centerY * displayMultiple, button, clickType);
299
+ } else if (action === 'hover') {
300
+ await hover(result.centerX * displayMultiple, result.centerY * displayMultiple);
301
+ }
293
302
  }
294
303
 
295
304
  },
@@ -435,7 +444,6 @@ let commands = {
435
444
  }
436
445
 
437
446
  },
438
- scroll,
439
447
  "scroll-until-text": async(text, direction = 'down', maxDistance = 1200, method = 'ai') => {
440
448
 
441
449
  await redraw.start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.0.29",
3
+ "version": "4.0.31",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {