askui 0.3.2 → 0.4.0

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 (52) hide show
  1. package/README.md +6 -12
  2. package/dist/cjs/core/annotation/annotation-writer.js +2 -4
  3. package/dist/cjs/core/annotation/annotation.d.ts +3 -4
  4. package/dist/cjs/core/annotation/annotation.js +5 -4
  5. package/dist/cjs/core/inference-response/inference-response.d.ts +15 -0
  6. package/dist/cjs/core/inference-response/inference-response.js +25 -0
  7. package/dist/cjs/core/model/annotation-result/boundary-box.d.ts +23 -0
  8. package/dist/cjs/core/model/annotation-result/boundary-box.js +27 -0
  9. package/dist/cjs/core/model/annotation-result/detected-element.d.ts +9 -3
  10. package/dist/cjs/core/model/annotation-result/detected-element.js +10 -4
  11. package/dist/cjs/core/ui-control-commands/control-command.d.ts +1 -1
  12. package/dist/cjs/core/ui-control-commands/control-command.js +2 -1
  13. package/dist/cjs/core/ui-control-commands/index.d.ts +1 -0
  14. package/dist/cjs/core/ui-control-commands/index.js +3 -1
  15. package/dist/cjs/execution/dsl.d.ts +691 -2
  16. package/dist/cjs/execution/dsl.js +968 -7
  17. package/dist/cjs/execution/dsl.spec.js +4 -4
  18. package/dist/cjs/execution/execution-runtime.d.ts +2 -0
  19. package/dist/cjs/execution/execution-runtime.js +11 -1
  20. package/dist/cjs/execution/inference-client.d.ts +3 -0
  21. package/dist/cjs/execution/inference-client.js +28 -12
  22. package/dist/cjs/execution/inference-response-error.d.ts +2 -0
  23. package/dist/cjs/execution/inference-response-error.js +6 -0
  24. package/dist/cjs/execution/ui-control-client.d.ts +5 -3
  25. package/dist/cjs/execution/ui-control-client.js +10 -2
  26. package/dist/cjs/utils/http/http-client-got.js +5 -1
  27. package/dist/esm/core/annotation/annotation-writer.js +2 -4
  28. package/dist/esm/core/annotation/annotation.d.ts +3 -4
  29. package/dist/esm/core/annotation/annotation.js +5 -4
  30. package/dist/esm/core/inference-response/inference-response.d.ts +15 -0
  31. package/dist/esm/core/inference-response/inference-response.js +21 -0
  32. package/dist/esm/core/model/annotation-result/boundary-box.d.ts +23 -0
  33. package/dist/esm/core/model/annotation-result/boundary-box.js +27 -0
  34. package/dist/esm/core/model/annotation-result/detected-element.d.ts +9 -3
  35. package/dist/esm/core/model/annotation-result/detected-element.js +10 -4
  36. package/dist/esm/core/ui-control-commands/control-command.d.ts +1 -1
  37. package/dist/esm/core/ui-control-commands/control-command.js +2 -1
  38. package/dist/esm/core/ui-control-commands/index.d.ts +1 -0
  39. package/dist/esm/core/ui-control-commands/index.js +1 -0
  40. package/dist/esm/execution/dsl.d.ts +691 -2
  41. package/dist/esm/execution/dsl.js +962 -6
  42. package/dist/esm/execution/dsl.spec.js +4 -4
  43. package/dist/esm/execution/execution-runtime.d.ts +2 -0
  44. package/dist/esm/execution/execution-runtime.js +11 -1
  45. package/dist/esm/execution/inference-client.d.ts +3 -0
  46. package/dist/esm/execution/inference-client.js +29 -13
  47. package/dist/esm/execution/inference-response-error.d.ts +2 -0
  48. package/dist/esm/execution/inference-response-error.js +2 -0
  49. package/dist/esm/execution/ui-control-client.d.ts +5 -3
  50. package/dist/esm/execution/ui-control-client.js +11 -3
  51. package/dist/esm/utils/http/http-client-got.js +5 -1
  52. package/package.json +1 -1
@@ -22,25 +22,38 @@ class FluentBase {
22
22
  });
23
23
  return paramsList;
24
24
  }
25
- commandStringBuilder(currentInstruction = '', paramsList = new Map()) {
25
+ fluentCommandStringBuilder(currentInstruction = '', paramsList = new Map()) {
26
26
  const newCurrentInstruction = `${this.textStr} ${currentInstruction}`;
27
27
  const newParamsList = FluentBase.addParams(paramsList, this._params);
28
28
  if (this instanceof FluentCommand) {
29
29
  const fluentCommand = this;
30
30
  const customElements = newParamsList.has('customElement') ? newParamsList.get('customElement') : [];
31
- return fluentCommand.exec(newCurrentInstruction.trim(), customElements);
31
+ return fluentCommand.fluentCommandExecutor(newCurrentInstruction.trim(), customElements);
32
32
  }
33
33
  if (!this.prev) {
34
34
  throw new Error('Prev element not defined');
35
35
  }
36
- return this.prev.commandStringBuilder(newCurrentInstruction, newParamsList);
36
+ return this.prev.fluentCommandStringBuilder(newCurrentInstruction, newParamsList);
37
+ }
38
+ getterStringBuilder(currentInstruction = '', paramsList = new Map()) {
39
+ const newCurrentInstruction = `${this.textStr} ${currentInstruction}`;
40
+ const newParamsList = FluentBase.addParams(paramsList, this._params);
41
+ if (this instanceof Getter) {
42
+ const getter = this;
43
+ const customElements = newParamsList.has('customElement') ? newParamsList.get('customElement') : [];
44
+ return getter.getterExecutor(newCurrentInstruction.trim(), customElements);
45
+ }
46
+ if (!this.prev) {
47
+ throw new Error('Prev element not defined');
48
+ }
49
+ return this.prev.getterStringBuilder(newCurrentInstruction, newParamsList);
37
50
  }
38
51
  get textStr() { return this._textStr; }
39
52
  get params() { return this._params; }
40
53
  }
41
54
  export class Exec extends FluentBase {
42
55
  exec() {
43
- return this.commandStringBuilder();
56
+ return this.fluentCommandStringBuilder();
44
57
  }
45
58
  }
46
59
  // Filters
@@ -950,7 +963,7 @@ export class FluentFiltersOrRelations extends FluentFilters {
950
963
  return new FluentFilters(this);
951
964
  }
952
965
  exec() {
953
- return this.commandStringBuilder();
966
+ return this.fluentCommandStringBuilder();
954
967
  }
955
968
  }
956
969
  // Filters
@@ -1993,7 +2006,7 @@ export class FluentCommand extends FluentBase {
1993
2006
  * @return {Exec}
1994
2007
  */
1995
2008
  moveMouse(x_coordinate, y_coordinate) {
1996
- this._textStr = `Move mouse to x ${x_coordinate} y ${y_coordinate}`;
2009
+ this._textStr = `Move mouse to x ${x_coordinate} y ${y_coordinate}`;
1997
2010
  return new Exec(this);
1998
2011
  }
1999
2012
  /**
@@ -2166,3 +2179,946 @@ export class FluentCommand extends FluentBase {
2166
2179
  return new Exec(this);
2167
2180
  }
2168
2181
  }
2182
+ export class ExecGetter extends FluentBase {
2183
+ exec() {
2184
+ return this.getterStringBuilder();
2185
+ }
2186
+ }
2187
+ // Filters
2188
+ export class FluentFiltersGetter extends FluentBase {
2189
+ /**
2190
+ * Filters for a UI element 'wizard item active'.
2191
+ *
2192
+ * @return {FluentFiltersOrRelationsGetter}
2193
+ */
2194
+ wizardItemActive() {
2195
+ this._textStr = 'wizard item active';
2196
+ return new FluentFiltersOrRelationsGetter(this);
2197
+ }
2198
+ /**
2199
+ * Filters for a UI element 'wizard item'.
2200
+ *
2201
+ * @return {FluentFiltersOrRelationsGetter}
2202
+ */
2203
+ wizardItem() {
2204
+ this._textStr = 'wizard item';
2205
+ return new FluentFiltersOrRelationsGetter(this);
2206
+ }
2207
+ /**
2208
+ * Filters for a UI element 'wizard'.
2209
+ *
2210
+ * @return {FluentFiltersOrRelationsGetter}
2211
+ */
2212
+ wizard() {
2213
+ this._textStr = 'wizard';
2214
+ return new FluentFiltersOrRelationsGetter(this);
2215
+ }
2216
+ /**
2217
+ * Filters for a UI element 'windows bar'.
2218
+ *
2219
+ * @return {FluentFiltersOrRelationsGetter}
2220
+ */
2221
+ windowsBar() {
2222
+ this._textStr = 'windows bar';
2223
+ return new FluentFiltersOrRelationsGetter(this);
2224
+ }
2225
+ /**
2226
+ * Filters for a UI element 'window'.
2227
+ *
2228
+ * @return {FluentFiltersOrRelationsGetter}
2229
+ */
2230
+ window() {
2231
+ this._textStr = 'window';
2232
+ return new FluentFiltersOrRelationsGetter(this);
2233
+ }
2234
+ /**
2235
+ * Filters for a UI element 'video'.
2236
+ *
2237
+ * @return {FluentFiltersOrRelationsGetter}
2238
+ */
2239
+ video() {
2240
+ this._textStr = 'video';
2241
+ return new FluentFiltersOrRelationsGetter(this);
2242
+ }
2243
+ /**
2244
+ * Filters for a UI element 'url'.
2245
+ *
2246
+ * @return {FluentFiltersOrRelationsGetter}
2247
+ */
2248
+ url() {
2249
+ this._textStr = 'url';
2250
+ return new FluentFiltersOrRelationsGetter(this);
2251
+ }
2252
+ /**
2253
+ * Filters for a UI element 'tooltip'.
2254
+ *
2255
+ * @return {FluentFiltersOrRelationsGetter}
2256
+ */
2257
+ tooltip() {
2258
+ this._textStr = 'tooltip';
2259
+ return new FluentFiltersOrRelationsGetter(this);
2260
+ }
2261
+ /**
2262
+ * Filters for a UI element 'textfield'.
2263
+ *
2264
+ * @return {FluentFiltersOrRelationsGetter}
2265
+ */
2266
+ textfield() {
2267
+ this._textStr = 'textfield';
2268
+ return new FluentFiltersOrRelationsGetter(this);
2269
+ }
2270
+ /**
2271
+ * Filters for a UI element 'textarea'.
2272
+ *
2273
+ * @return {FluentFiltersOrRelationsGetter}
2274
+ */
2275
+ textarea() {
2276
+ this._textStr = 'textarea';
2277
+ return new FluentFiltersOrRelationsGetter(this);
2278
+ }
2279
+ /**
2280
+ * Filters for a UI element 'table row'.
2281
+ *
2282
+ * @return {FluentFiltersOrRelationsGetter}
2283
+ */
2284
+ tableRow() {
2285
+ this._textStr = 'table row';
2286
+ return new FluentFiltersOrRelationsGetter(this);
2287
+ }
2288
+ /**
2289
+ * Filters for a UI element 'table header'.
2290
+ *
2291
+ * @return {FluentFiltersOrRelationsGetter}
2292
+ */
2293
+ tableHeader() {
2294
+ this._textStr = 'table header';
2295
+ return new FluentFiltersOrRelationsGetter(this);
2296
+ }
2297
+ /**
2298
+ * Filters for a UI element 'table column'.
2299
+ *
2300
+ * @return {FluentFiltersOrRelationsGetter}
2301
+ */
2302
+ tableColumn() {
2303
+ this._textStr = 'table column';
2304
+ return new FluentFiltersOrRelationsGetter(this);
2305
+ }
2306
+ /**
2307
+ * Filters for a UI element 'table'.
2308
+ *
2309
+ * @return {FluentFiltersOrRelationsGetter}
2310
+ */
2311
+ table() {
2312
+ this._textStr = 'table';
2313
+ return new FluentFiltersOrRelationsGetter(this);
2314
+ }
2315
+ /**
2316
+ * Filters for a UI element 'tab selected'.
2317
+ *
2318
+ * @return {FluentFiltersOrRelationsGetter}
2319
+ */
2320
+ tabSelected() {
2321
+ this._textStr = 'tab selected';
2322
+ return new FluentFiltersOrRelationsGetter(this);
2323
+ }
2324
+ /**
2325
+ * Filters for a UI element 'tab bar'.
2326
+ *
2327
+ * @return {FluentFiltersOrRelationsGetter}
2328
+ */
2329
+ tabBar() {
2330
+ this._textStr = 'tab bar';
2331
+ return new FluentFiltersOrRelationsGetter(this);
2332
+ }
2333
+ /**
2334
+ * Filters for a UI element 'tab active'.
2335
+ *
2336
+ * @return {FluentFiltersOrRelationsGetter}
2337
+ */
2338
+ tabActive() {
2339
+ this._textStr = 'tab active';
2340
+ return new FluentFiltersOrRelationsGetter(this);
2341
+ }
2342
+ /**
2343
+ * Filters for a UI element 'tab'.
2344
+ *
2345
+ * @return {FluentFiltersOrRelationsGetter}
2346
+ */
2347
+ tab() {
2348
+ this._textStr = 'tab';
2349
+ return new FluentFiltersOrRelationsGetter(this);
2350
+ }
2351
+ /**
2352
+ * Filters for a UI element 'switch enabled'.
2353
+ *
2354
+ * @return {FluentFiltersOrRelationsGetter}
2355
+ */
2356
+ switchEnabled() {
2357
+ this._textStr = 'switch enabled';
2358
+ return new FluentFiltersOrRelationsGetter(this);
2359
+ }
2360
+ /**
2361
+ * Filters for a UI element 'switch disabled'.
2362
+ *
2363
+ * @return {FluentFiltersOrRelationsGetter}
2364
+ */
2365
+ switchDisabled() {
2366
+ this._textStr = 'switch disabled';
2367
+ return new FluentFiltersOrRelationsGetter(this);
2368
+ }
2369
+ /**
2370
+ * Filters for a UI element 'status bar'.
2371
+ *
2372
+ * @return {FluentFiltersOrRelationsGetter}
2373
+ */
2374
+ statusBar() {
2375
+ this._textStr = 'status bar';
2376
+ return new FluentFiltersOrRelationsGetter(this);
2377
+ }
2378
+ /**
2379
+ * Filters for a UI element 'slider indicator'.
2380
+ *
2381
+ * @return {FluentFiltersOrRelationsGetter}
2382
+ */
2383
+ sliderIndicator() {
2384
+ this._textStr = 'slider indicator';
2385
+ return new FluentFiltersOrRelationsGetter(this);
2386
+ }
2387
+ /**
2388
+ * Filters for a UI element 'slider'.
2389
+ *
2390
+ * @return {FluentFiltersOrRelationsGetter}
2391
+ */
2392
+ slider() {
2393
+ this._textStr = 'slider';
2394
+ return new FluentFiltersOrRelationsGetter(this);
2395
+ }
2396
+ /**
2397
+ * Filters for a UI element 'sidebar'.
2398
+ *
2399
+ * @return {FluentFiltersOrRelationsGetter}
2400
+ */
2401
+ sidebar() {
2402
+ this._textStr = 'sidebar';
2403
+ return new FluentFiltersOrRelationsGetter(this);
2404
+ }
2405
+ /**
2406
+ * Filters for a UI element 'scroll bar'.
2407
+ *
2408
+ * @return {FluentFiltersOrRelationsGetter}
2409
+ */
2410
+ scrollBar() {
2411
+ this._textStr = 'scroll bar';
2412
+ return new FluentFiltersOrRelationsGetter(this);
2413
+ }
2414
+ /**
2415
+ * Filters for a UI element 'rect'.
2416
+ *
2417
+ * @return {FluentFiltersOrRelationsGetter}
2418
+ */
2419
+ rect() {
2420
+ this._textStr = 'rect';
2421
+ return new FluentFiltersOrRelationsGetter(this);
2422
+ }
2423
+ /**
2424
+ * Filters for a UI element 'recaptcha'.
2425
+ *
2426
+ * @return {FluentFiltersOrRelationsGetter}
2427
+ */
2428
+ recaptcha() {
2429
+ this._textStr = 'recaptcha';
2430
+ return new FluentFiltersOrRelationsGetter(this);
2431
+ }
2432
+ /**
2433
+ * Filters for a UI element 'rate'.
2434
+ *
2435
+ * @return {FluentFiltersOrRelationsGetter}
2436
+ */
2437
+ rate() {
2438
+ this._textStr = 'rate';
2439
+ return new FluentFiltersOrRelationsGetter(this);
2440
+ }
2441
+ /**
2442
+ * Filters for a UI element 'radio button unselected'.
2443
+ *
2444
+ * @return {FluentFiltersOrRelationsGetter}
2445
+ */
2446
+ radioButtonUnselected() {
2447
+ this._textStr = 'radio button unselected';
2448
+ return new FluentFiltersOrRelationsGetter(this);
2449
+ }
2450
+ /**
2451
+ * Filters for a UI element 'radio button selected'.
2452
+ *
2453
+ * @return {FluentFiltersOrRelationsGetter}
2454
+ */
2455
+ radioButtonSelected() {
2456
+ this._textStr = 'radio button selected';
2457
+ return new FluentFiltersOrRelationsGetter(this);
2458
+ }
2459
+ /**
2460
+ * Filters for a UI element 'progressbar'.
2461
+ *
2462
+ * @return {FluentFiltersOrRelationsGetter}
2463
+ */
2464
+ progressbar() {
2465
+ this._textStr = 'progressbar';
2466
+ return new FluentFiltersOrRelationsGetter(this);
2467
+ }
2468
+ /**
2469
+ * Filters for a UI element 'progress bar'.
2470
+ *
2471
+ * @return {FluentFiltersOrRelationsGetter}
2472
+ */
2473
+ progressBar() {
2474
+ this._textStr = 'progress bar';
2475
+ return new FluentFiltersOrRelationsGetter(this);
2476
+ }
2477
+ /**
2478
+ * Filters for a UI element 'popover'.
2479
+ *
2480
+ * @return {FluentFiltersOrRelationsGetter}
2481
+ */
2482
+ popover() {
2483
+ this._textStr = 'popover';
2484
+ return new FluentFiltersOrRelationsGetter(this);
2485
+ }
2486
+ /**
2487
+ * Filters for a UI element 'pil'.
2488
+ *
2489
+ * @return {FluentFiltersOrRelationsGetter}
2490
+ */
2491
+ pil() {
2492
+ this._textStr = 'pil';
2493
+ return new FluentFiltersOrRelationsGetter(this);
2494
+ }
2495
+ /**
2496
+ * Filters for a UI element 'password'.
2497
+ *
2498
+ * @return {FluentFiltersOrRelationsGetter}
2499
+ */
2500
+ password() {
2501
+ this._textStr = 'password';
2502
+ return new FluentFiltersOrRelationsGetter(this);
2503
+ }
2504
+ /**
2505
+ * Filters for a UI element 'pager'.
2506
+ *
2507
+ * @return {FluentFiltersOrRelationsGetter}
2508
+ */
2509
+ pager() {
2510
+ this._textStr = 'pager';
2511
+ return new FluentFiltersOrRelationsGetter(this);
2512
+ }
2513
+ /**
2514
+ * Filters for a UI element 'navigation bar'.
2515
+ *
2516
+ * @return {FluentFiltersOrRelationsGetter}
2517
+ */
2518
+ navigationBar() {
2519
+ this._textStr = 'navigation bar';
2520
+ return new FluentFiltersOrRelationsGetter(this);
2521
+ }
2522
+ /**
2523
+ * Filters for a UI element 'mouse text'.
2524
+ *
2525
+ * @return {FluentFiltersOrRelationsGetter}
2526
+ */
2527
+ mouseText() {
2528
+ this._textStr = 'mouse text';
2529
+ return new FluentFiltersOrRelationsGetter(this);
2530
+ }
2531
+ /**
2532
+ * Filters for a UI element 'mouse pointer'.
2533
+ *
2534
+ * @return {FluentFiltersOrRelationsGetter}
2535
+ */
2536
+ mousePointer() {
2537
+ this._textStr = 'mouse pointer';
2538
+ return new FluentFiltersOrRelationsGetter(this);
2539
+ }
2540
+ /**
2541
+ * Filters for a UI element 'mouse cursor'.
2542
+ *
2543
+ * @return {FluentFiltersOrRelationsGetter}
2544
+ */
2545
+ mouseCursor() {
2546
+ this._textStr = 'mouse cursor';
2547
+ return new FluentFiltersOrRelationsGetter(this);
2548
+ }
2549
+ /**
2550
+ * Filters for a UI element 'modal'.
2551
+ *
2552
+ * @return {FluentFiltersOrRelationsGetter}
2553
+ */
2554
+ modal() {
2555
+ this._textStr = 'modal';
2556
+ return new FluentFiltersOrRelationsGetter(this);
2557
+ }
2558
+ /**
2559
+ * Filters for a UI element 'message box'.
2560
+ *
2561
+ * @return {FluentFiltersOrRelationsGetter}
2562
+ */
2563
+ messageBox() {
2564
+ this._textStr = 'message box';
2565
+ return new FluentFiltersOrRelationsGetter(this);
2566
+ }
2567
+ /**
2568
+ * Filters for a UI element 'map'.
2569
+ *
2570
+ * @return {FluentFiltersOrRelationsGetter}
2571
+ */
2572
+ map() {
2573
+ this._textStr = 'map';
2574
+ return new FluentFiltersOrRelationsGetter(this);
2575
+ }
2576
+ /**
2577
+ * Filters for a UI element 'logo'.
2578
+ *
2579
+ * @return {FluentFiltersOrRelationsGetter}
2580
+ */
2581
+ logo() {
2582
+ this._textStr = 'logo';
2583
+ return new FluentFiltersOrRelationsGetter(this);
2584
+ }
2585
+ /**
2586
+ * Filters for a UI element 'link'.
2587
+ *
2588
+ * @return {FluentFiltersOrRelationsGetter}
2589
+ */
2590
+ link() {
2591
+ this._textStr = 'link';
2592
+ return new FluentFiltersOrRelationsGetter(this);
2593
+ }
2594
+ /**
2595
+ * Filters for a UI element 'keyboard'.
2596
+ *
2597
+ * @return {FluentFiltersOrRelationsGetter}
2598
+ */
2599
+ keyboard() {
2600
+ this._textStr = 'keyboard';
2601
+ return new FluentFiltersOrRelationsGetter(this);
2602
+ }
2603
+ /**
2604
+ * Filters for a UI element 'image'.
2605
+ *
2606
+ * @return {FluentFiltersOrRelationsGetter}
2607
+ */
2608
+ image() {
2609
+ this._textStr = 'image';
2610
+ return new FluentFiltersOrRelationsGetter(this);
2611
+ }
2612
+ /**
2613
+ * Filters for a UI element 'header'.
2614
+ *
2615
+ * @return {FluentFiltersOrRelationsGetter}
2616
+ */
2617
+ header() {
2618
+ this._textStr = 'header';
2619
+ return new FluentFiltersOrRelationsGetter(this);
2620
+ }
2621
+ /**
2622
+ * Filters for a UI element 'footer'.
2623
+ *
2624
+ * @return {FluentFiltersOrRelationsGetter}
2625
+ */
2626
+ footer() {
2627
+ this._textStr = 'footer';
2628
+ return new FluentFiltersOrRelationsGetter(this);
2629
+ }
2630
+ /**
2631
+ * Filters for a UI element 'flag'.
2632
+ *
2633
+ * @return {FluentFiltersOrRelationsGetter}
2634
+ */
2635
+ flag() {
2636
+ this._textStr = 'flag';
2637
+ return new FluentFiltersOrRelationsGetter(this);
2638
+ }
2639
+ /**
2640
+ * Filters for a UI element 'dropdown menu'.
2641
+ *
2642
+ * @return {FluentFiltersOrRelationsGetter}
2643
+ */
2644
+ dropdownMenu() {
2645
+ this._textStr = 'dropdown menu';
2646
+ return new FluentFiltersOrRelationsGetter(this);
2647
+ }
2648
+ /**
2649
+ * Filters for a UI element 'divider'.
2650
+ *
2651
+ * @return {FluentFiltersOrRelationsGetter}
2652
+ */
2653
+ divider() {
2654
+ this._textStr = 'divider';
2655
+ return new FluentFiltersOrRelationsGetter(this);
2656
+ }
2657
+ /**
2658
+ * Filters for a UI element 'circle'.
2659
+ *
2660
+ * @return {FluentFiltersOrRelationsGetter}
2661
+ */
2662
+ circle() {
2663
+ this._textStr = 'circle';
2664
+ return new FluentFiltersOrRelationsGetter(this);
2665
+ }
2666
+ /**
2667
+ * Filters for a UI element 'checkbox unchecked'.
2668
+ *
2669
+ * @return {FluentFiltersOrRelationsGetter}
2670
+ */
2671
+ checkboxUnchecked() {
2672
+ this._textStr = 'checkbox unchecked';
2673
+ return new FluentFiltersOrRelationsGetter(this);
2674
+ }
2675
+ /**
2676
+ * Filters for a UI element 'checkbox checked'.
2677
+ *
2678
+ * @return {FluentFiltersOrRelationsGetter}
2679
+ */
2680
+ checkboxChecked() {
2681
+ this._textStr = 'checkbox checked';
2682
+ return new FluentFiltersOrRelationsGetter(this);
2683
+ }
2684
+ /**
2685
+ * Filters for a UI element 'chart pie'.
2686
+ *
2687
+ * @return {FluentFiltersOrRelationsGetter}
2688
+ */
2689
+ chartPie() {
2690
+ this._textStr = 'chart pie';
2691
+ return new FluentFiltersOrRelationsGetter(this);
2692
+ }
2693
+ /**
2694
+ * Filters for a UI element 'chart'.
2695
+ *
2696
+ * @return {FluentFiltersOrRelationsGetter}
2697
+ */
2698
+ chart() {
2699
+ this._textStr = 'chart';
2700
+ return new FluentFiltersOrRelationsGetter(this);
2701
+ }
2702
+ /**
2703
+ * Filters for a UI element 'card'.
2704
+ *
2705
+ * @return {FluentFiltersOrRelationsGetter}
2706
+ */
2707
+ card() {
2708
+ this._textStr = 'card';
2709
+ return new FluentFiltersOrRelationsGetter(this);
2710
+ }
2711
+ /**
2712
+ * Filters for a UI element 'browser bar'.
2713
+ *
2714
+ * @return {FluentFiltersOrRelationsGetter}
2715
+ */
2716
+ browserBar() {
2717
+ this._textStr = 'browser bar';
2718
+ return new FluentFiltersOrRelationsGetter(this);
2719
+ }
2720
+ /**
2721
+ * Filters for a UI element 'breadcrumb'.
2722
+ *
2723
+ * @return {FluentFiltersOrRelationsGetter}
2724
+ */
2725
+ breadcrumb() {
2726
+ this._textStr = 'breadcrumb';
2727
+ return new FluentFiltersOrRelationsGetter(this);
2728
+ }
2729
+ /**
2730
+ * Filters for a UI element 'banner'.
2731
+ *
2732
+ * @return {FluentFiltersOrRelationsGetter}
2733
+ */
2734
+ banner() {
2735
+ this._textStr = 'banner';
2736
+ return new FluentFiltersOrRelationsGetter(this);
2737
+ }
2738
+ /**
2739
+ * Filters for a UI element 'badge'.
2740
+ *
2741
+ * @return {FluentFiltersOrRelationsGetter}
2742
+ */
2743
+ badge() {
2744
+ this._textStr = 'badge';
2745
+ return new FluentFiltersOrRelationsGetter(this);
2746
+ }
2747
+ /**
2748
+ * Filters for a UI element 'alert'.
2749
+ *
2750
+ * @return {FluentFiltersOrRelationsGetter}
2751
+ */
2752
+ alert() {
2753
+ this._textStr = 'alert';
2754
+ return new FluentFiltersOrRelationsGetter(this);
2755
+ }
2756
+ /**
2757
+ * Filters for a UI element 'unknown'.
2758
+ *
2759
+ * @return {FluentFiltersOrRelationsGetter}
2760
+ */
2761
+ unknown() {
2762
+ this._textStr = 'unknown';
2763
+ return new FluentFiltersOrRelationsGetter(this);
2764
+ }
2765
+ /**
2766
+ * Filters for an UI element 'button'.
2767
+ *
2768
+ * @return {FluentFiltersOrRelationsGetter}
2769
+ */
2770
+ button() {
2771
+ this._textStr = 'button';
2772
+ return new FluentFiltersOrRelationsGetter(this);
2773
+ }
2774
+ /**
2775
+ * Filters for an UI element 'text'.
2776
+ *
2777
+ * @return {FluentFiltersOrRelationsGetter}
2778
+ */
2779
+ text() {
2780
+ this._textStr = 'text';
2781
+ return new FluentFiltersOrRelationsGetter(this);
2782
+ }
2783
+ /**
2784
+ * Filters for an UI element 'dropdown'.
2785
+ *
2786
+ * @return {FluentFiltersOrRelationsGetter}
2787
+ */
2788
+ dropdown() {
2789
+ this._textStr = 'dropdown';
2790
+ return new FluentFiltersOrRelationsGetter(this);
2791
+ }
2792
+ /**
2793
+ * Filters for an UI element 'icon'.
2794
+ *
2795
+ * You can combine it with the 'withText' command to look for a specific icon.
2796
+ *
2797
+ * **Examples:**
2798
+ * ```typescript
2799
+ * icon().withText('plus')
2800
+ * ```
2801
+ *
2802
+ * Note: This is an alpha feature. The prediction of the icon name is sometimes unstable. Use custom elements as an alternative.
2803
+ *
2804
+ * @return {FluentFiltersOrRelationsGetter}
2805
+ */
2806
+ icon() {
2807
+ this._textStr = 'icon';
2808
+ return new FluentFiltersOrRelationsGetter(this);
2809
+ }
2810
+ /**
2811
+ * Filters for a custom UI element (see {@link CustomElementJson}).
2812
+ *
2813
+ * **Important**: This increases the runtime quite a bit. So
2814
+ * only use it when absolutely necessary.
2815
+ *
2816
+ * @param {CustomElementJson} customElement - The custom element to filter for.
2817
+ *
2818
+ * @return {FluentFiltersOrRelationsGetter}
2819
+ */
2820
+ customElement(customElement) {
2821
+ this._textStr = 'custom element';
2822
+ this._params.set('customElement', customElement);
2823
+ return new FluentFiltersOrRelationsGetter(this);
2824
+ }
2825
+ /**
2826
+ * Filters for a UI element 'checkbox' checked or unchecked.
2827
+ *
2828
+ * @return {FluentFiltersOrRelationsGetter}
2829
+ */
2830
+ checkbox() {
2831
+ this._textStr = 'checkbox';
2832
+ return new FluentFiltersOrRelationsGetter(this);
2833
+ }
2834
+ /**
2835
+ * Filters for similar (doesn't need to be a 100% equal) text.
2836
+ *
2837
+ * **Examples:**
2838
+ * ```typescript
2839
+ * 'text' === withText('text') => true
2840
+ * 'test' === withText('text') => true
2841
+ * 'other' === withText('text') => false
2842
+ * ```
2843
+ *
2844
+ * @param {string} text - A text to be matched.
2845
+ *
2846
+ * @return {FluentFiltersOrRelationsGetter}
2847
+ */
2848
+ withText(text) {
2849
+ this._textStr = `with text ${Separators.STRING}${text}${Separators.STRING}`;
2850
+ return new FluentFiltersOrRelationsGetter(this);
2851
+ }
2852
+ /**
2853
+ * Filters for texts, which match the regex pattern.
2854
+ *
2855
+ * **Examples:**
2856
+ *
2857
+ * ```typescript
2858
+ * 'The rain in Spain' === withTextRegex('\b[Ss]\w+') => true
2859
+ * 'The rain in Portugal' === withTextRegex('\b[Ss]\w+') => false
2860
+ * 'The rain in switzerland' === withTextRegex('\b[Ss]\w+') => true
2861
+ * ```
2862
+ *
2863
+ * @param {string} regex_pattern - An regex pattern
2864
+ *
2865
+ * @return {FluentFiltersOrRelationsGetter}
2866
+ */
2867
+ withTextRegex(regex_pattern) {
2868
+ this._textStr = `match regex pattern ${Separators.STRING}${regex_pattern}${Separators.STRING}`;
2869
+ return new FluentFiltersOrRelationsGetter(this);
2870
+ }
2871
+ /**
2872
+ * Filters for equal text.
2873
+ *
2874
+ * **Note:** This should be only used in cases where the similarity
2875
+ * comparison of {@link FluentFilters.withText()} allows not for
2876
+ * specific enough filtering (too many elements).
2877
+ *
2878
+ * **Examples:**
2879
+ * ```typescript
2880
+ * 'text' === withExactText('text') => true
2881
+ * 'test' === withExactText('text') => false
2882
+ * 'other' === withExactText('text') => false
2883
+ * ```
2884
+ *
2885
+ * @param {string} text - A text to be matched.
2886
+ *
2887
+ * @return {FluentFiltersOrRelationsGetter}
2888
+ */
2889
+ withExactText(text) {
2890
+ this._textStr = `equals text ${Separators.STRING}${text}${Separators.STRING}`;
2891
+ return new FluentFiltersOrRelationsGetter(this);
2892
+ }
2893
+ /**
2894
+ * Filters for text containing the text provided as an argument.
2895
+ *
2896
+ * **Examples:**
2897
+ * ```typescript
2898
+ * 'This is an text' === containsText('text') => true
2899
+ * 'This is an text' === containsText('other text') => false
2900
+ * 'This is an text' === containsText('other') => false
2901
+ * ```
2902
+ *
2903
+ * @param {string} text - A text to be matched.
2904
+ *
2905
+ * @return {FluentFiltersOrRelationsGetter}
2906
+ */
2907
+ containsText(text) {
2908
+ this._textStr = `contain text ${Separators.STRING}${text}${Separators.STRING}`;
2909
+ return new FluentFiltersOrRelationsGetter(this);
2910
+ }
2911
+ /**
2912
+ * Filters for elements having a specific color.
2913
+ *
2914
+ * @param {COLOR} color - A color to match
2915
+ *
2916
+ * @return {FluentFiltersOrRelationsGetter}
2917
+ */
2918
+ colored(color) {
2919
+ this._textStr = `with color ${color}`;
2920
+ return new FluentFiltersOrRelationsGetter(this);
2921
+ }
2922
+ }
2923
+ // Relations
2924
+ export class FluentFiltersOrRelationsGetter extends FluentFiltersGetter {
2925
+ /**
2926
+ * Filters for an element inside another element.
2927
+ *
2928
+ * **Examples:**
2929
+ * ```typescript
2930
+ * --------------------
2931
+ * | outerEl |
2932
+ * | -------------- |
2933
+ * | | innerEl | |
2934
+ * | -------------- |
2935
+ * | |
2936
+ * --------------------
2937
+ *
2938
+ * // Returns innerEl because innerEl is inside outerEl
2939
+ * ...innerEl().in().outerEl()
2940
+ * // Returns nothing because innerEl is not inside outerEl
2941
+ * ...outerEl().in().innerEl()
2942
+ * ```
2943
+ *
2944
+ * @return {FluentFiltersGetter}
2945
+ */
2946
+ in() {
2947
+ this._textStr = 'in';
2948
+ return new FluentFiltersGetter(this);
2949
+ }
2950
+ /**
2951
+ * Filters for an element right of another element.
2952
+ *
2953
+ * **Examples:**
2954
+ * ```typescript
2955
+ * -------------- --------------
2956
+ * | leftEl | | rightEl |
2957
+ * -------------- --------------
2958
+ *
2959
+ * // Returns rightEl because rightEl is right of leftEl
2960
+ * ...rightEl().rightOf().leftEl()
2961
+ * // Returns no element because leftEl is left of rightEl
2962
+ * ...leftEl().rightOf().rightEl()
2963
+ * ```
2964
+ *
2965
+ * @return {FluentFiltersGetter}
2966
+ */
2967
+ rightOf() {
2968
+ this._textStr = 'right of';
2969
+ return new FluentFiltersGetter(this);
2970
+ }
2971
+ /**
2972
+ * Filters for an element left of another element.
2973
+ *
2974
+ * **Examples:**
2975
+ * ```typescript
2976
+ * -------------- --------------
2977
+ * | leftEl | | rightEl |
2978
+ * -------------- --------------
2979
+ *
2980
+ * // Returns leftEl because leftEl is left of rightEl
2981
+ * ...leftEl().leftOf().rightEl()
2982
+ * // Returns no element because rightEl is left of leftEl
2983
+ * ...rightEl().leftOf().leftEl()
2984
+ * ```
2985
+ *
2986
+ * @return {FluentFiltersGetter}
2987
+ */
2988
+ leftOf() {
2989
+ this._textStr = 'left of';
2990
+ return new FluentFiltersGetter(this);
2991
+ }
2992
+ /**
2993
+ * Filters for an element below another element.
2994
+ *
2995
+ * **Examples:**
2996
+ * ```typescript
2997
+ * --------------
2998
+ * | text |
2999
+ * --------------
3000
+ * --------------
3001
+ * | button |
3002
+ * --------------
3003
+ *
3004
+ * // Returns button because button is below text
3005
+ * ...button().below().text()
3006
+ * // Returns no element because text is above button
3007
+ * ...text().below().button()
3008
+ * ```
3009
+ *
3010
+ * @return {FluentFiltersGetter}
3011
+ */
3012
+ below() {
3013
+ this._textStr = 'below';
3014
+ return new FluentFiltersGetter(this);
3015
+ }
3016
+ /**
3017
+ * Filters for an element above another element.
3018
+ *
3019
+ * **Examples:**
3020
+ * ```typescript
3021
+ * --------------
3022
+ * | text |
3023
+ * --------------
3024
+ * --------------
3025
+ * | button |
3026
+ * --------------
3027
+ *
3028
+ * // Returns text because text is above button
3029
+ * ...text().above().button()
3030
+ * // Returns no element because button is below text
3031
+ * ...button().above().text()
3032
+ * ```
3033
+ *
3034
+ * @return {FluentFiltersGetter}
3035
+ */
3036
+ above() {
3037
+ this._textStr = 'above';
3038
+ return new FluentFiltersGetter(this);
3039
+ }
3040
+ /**
3041
+ * Filters for an element nearest to another element.
3042
+ *
3043
+ * **Examples:**
3044
+ * ```typescript
3045
+ * --------------
3046
+ * | button 1 |
3047
+ * --------------
3048
+ * --------------
3049
+ * | text |
3050
+ * --------------
3051
+ *
3052
+ *
3053
+ *
3054
+ * --------------
3055
+ * | button 2 |
3056
+ * --------------
3057
+ *
3058
+ * // Returns button 1 because button 1 is nearer to the text than button 2
3059
+ * ...button().nearestTo().text()
3060
+ * ```
3061
+ *
3062
+ * @return {FluentFiltersGetter}
3063
+ */
3064
+ nearestTo() {
3065
+ this._textStr = 'nearest to';
3066
+ return new FluentFiltersGetter(this);
3067
+ }
3068
+ /**
3069
+ * Filters for an element containing another element.
3070
+ *
3071
+ * **Example:**
3072
+ * ```typescript
3073
+ * --------------------
3074
+ * | outerEl |
3075
+ * | -------------- |
3076
+ * | | innerEl | |
3077
+ * | -------------- |
3078
+ * | |
3079
+ * --------------------
3080
+ *
3081
+ * // Returns outerEl because outerEl contains innerEl
3082
+ * ...outerEl().contains().innerEl()
3083
+ * // Returns no element because innerEl contains no outerEl
3084
+ * ...innerEl().contains().outerEl()
3085
+ * ```
3086
+ *
3087
+ * @return {FluentFiltersGetter}
3088
+ */
3089
+ contains() {
3090
+ this._textStr = 'contains';
3091
+ return new FluentFiltersGetter(this);
3092
+ }
3093
+ /**
3094
+ * Returns a list of detected elements
3095
+ *
3096
+ * @return {DetectedElement[]}
3097
+ */
3098
+ exec() {
3099
+ return this.getterStringBuilder();
3100
+ }
3101
+ }
3102
+ // Commands
3103
+ export class Getter extends FluentCommand {
3104
+ /**
3105
+ * Returns the filtered element
3106
+ *
3107
+ * @return {FluentFiltersGetter}
3108
+ */
3109
+ get() {
3110
+ this._textStr = 'get element';
3111
+ return new FluentFiltersGetter(this);
3112
+ }
3113
+ /**
3114
+ * Returns all detected elements
3115
+ *
3116
+ * @return {ExecGetter}
3117
+ */
3118
+ getAll() {
3119
+ this._textStr = 'get all elements';
3120
+ return new ExecGetter(this);
3121
+ }
3122
+ }
3123
+ export class ApiCommands extends Getter {
3124
+ }