testdriverai 4.0.29 → 4.0.30

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 +36 -30
  2. package/package.json +1 -1
package/lib/commands.js CHANGED
@@ -190,6 +190,37 @@ 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 = {
194
225
  // method, levenshein, dice, or combined
195
226
  // leven = this is turbo, all around good for text similarity
@@ -248,35 +279,6 @@ let commands = {
248
279
  }
249
280
 
250
281
  },
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
282
  "match-image": async(relativePath, action = 'click', button = 'left', clickType = 'single') => {
281
283
 
282
284
  let image = await captureScreenPNG()
@@ -289,7 +291,11 @@ let commands = {
289
291
  throw new AiError(`Image not found: ${relativePath}`)
290
292
  } else {
291
293
 
292
- await routeClick(result.centerX * displayMultiple, result.centerY * displayMultiple, action, button, clickType);
294
+ if (action === 'click') {
295
+ await click(result.centerX * displayMultiple, result.centerY * displayMultiple, button, clickType);
296
+ } else if (action === 'hover') {
297
+ await hover(result.centerX * displayMultiple, result.centerY * displayMultiple);
298
+ }
293
299
  }
294
300
 
295
301
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "4.0.29",
3
+ "version": "4.0.30",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {