askui 0.3.2 → 0.5.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 (60) 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 +1076 -2
  16. package/dist/cjs/execution/dsl.js +1371 -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/lib/copy-example-project.js +40 -4
  27. package/dist/cjs/utils/http/http-client-got.js +5 -1
  28. package/dist/esm/core/annotation/annotation-writer.js +2 -4
  29. package/dist/esm/core/annotation/annotation.d.ts +3 -4
  30. package/dist/esm/core/annotation/annotation.js +5 -4
  31. package/dist/esm/core/inference-response/inference-response.d.ts +15 -0
  32. package/dist/esm/core/inference-response/inference-response.js +21 -0
  33. package/dist/esm/core/model/annotation-result/boundary-box.d.ts +23 -0
  34. package/dist/esm/core/model/annotation-result/boundary-box.js +27 -0
  35. package/dist/esm/core/model/annotation-result/detected-element.d.ts +9 -3
  36. package/dist/esm/core/model/annotation-result/detected-element.js +10 -4
  37. package/dist/esm/core/ui-control-commands/control-command.d.ts +1 -1
  38. package/dist/esm/core/ui-control-commands/control-command.js +2 -1
  39. package/dist/esm/core/ui-control-commands/index.d.ts +1 -0
  40. package/dist/esm/core/ui-control-commands/index.js +1 -0
  41. package/dist/esm/execution/dsl.d.ts +1076 -2
  42. package/dist/esm/execution/dsl.js +1365 -6
  43. package/dist/esm/execution/dsl.spec.js +4 -4
  44. package/dist/esm/execution/execution-runtime.d.ts +2 -0
  45. package/dist/esm/execution/execution-runtime.js +11 -1
  46. package/dist/esm/execution/inference-client.d.ts +3 -0
  47. package/dist/esm/execution/inference-client.js +29 -13
  48. package/dist/esm/execution/inference-response-error.d.ts +2 -0
  49. package/dist/esm/execution/inference-response-error.js +2 -0
  50. package/dist/esm/execution/ui-control-client.d.ts +5 -3
  51. package/dist/esm/execution/ui-control-client.js +11 -3
  52. package/dist/esm/lib/copy-example-project.js +40 -4
  53. package/dist/esm/utils/http/http-client-got.js +5 -1
  54. package/dist/example_projects_templates/typescript_jest/test/helper/jest.setup.ts +6 -1
  55. package/dist/example_projects_templates/typescript_jest/test/my-first-askui-test-suite.test.ts +5 -0
  56. package/package.json +1 -1
  57. package/dist/cjs/core/annotation/annotation-json.d.ts +0 -5
  58. package/dist/cjs/core/annotation/annotation-json.js +0 -2
  59. package/dist/esm/core/annotation/annotation-json.d.ts +0 -5
  60. package/dist/esm/core/annotation/annotation-json.js +0 -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
@@ -781,6 +794,120 @@ export class FluentFilters extends FluentBase {
781
794
  }
782
795
  // Relations
783
796
  export class FluentFiltersOrRelations extends FluentFilters {
797
+ /**
798
+ * Logic or operator
799
+ *
800
+ * **Examples:**
801
+ * ```text
802
+ * scene 1
803
+ * -------------- ---------------
804
+ * | button | | icon |
805
+ * -------------- ---------------
806
+ *
807
+ * scene 2
808
+ * -------------- ---------------
809
+ * | button | | text |
810
+ * -------------- ---------------
811
+ *
812
+ * ```
813
+ * In case, that your reference element can have multiple values, in the following example, the element right of the button can be either icon or text.
814
+ * You can use **the `or()` relation**, so your teststep is valid for both scenes
815
+ * ```typescript
816
+ * const button = await aui.get().button().rightOf().icon().or().text().exec();
817
+ * console.log(button);
818
+ * ```
819
+ * Returns the same button for both cases
820
+ * ```text
821
+ * console output: [
822
+ * DetectedElement {
823
+ * name: 'BUTTON',
824
+ * text: 'button',
825
+ * colors: [ 'red', 'black', 'red' ],
826
+ * bndbox: BoundingBox {
827
+ * xmin: 900,
828
+ * ymin: 910,
829
+ * xmax: 920,
830
+ * ymax: 930
831
+ * }
832
+ * }
833
+ * ]
834
+ * ```
835
+ *
836
+ * @return {FluentFilters}
837
+ */
838
+ or() {
839
+ this._textStr = 'or';
840
+ return new FluentFilters(this);
841
+ }
842
+ /**
843
+ * Logic and operator
844
+ *
845
+ * **Examples:**
846
+ * ```text
847
+ * example scene:
848
+ * -------------------------- --------------------------
849
+ * | icon user colored black | | icon user colored red |
850
+ * -------------------------- --------------------------
851
+ * ```
852
+ * ```typescript
853
+ * const icons = await aui.get().icon().withText('user').exec();
854
+ * console.log(icons);
855
+ * ```
856
+ * Using only the filter withText, the get command will return both icons because they share the same text
857
+ * ```text
858
+ * console output: [
859
+ * DetectedElement {
860
+ * name: 'ICON',
861
+ * text: 'user',
862
+ * colors: [ 'black', 'black', 'black' ],
863
+ * bndbox: BoundingBox {
864
+ * xmin: 1000,
865
+ * ymin: 1010,
866
+ * xmax: 1020,
867
+ * ymax: 1030
868
+ * }
869
+ * },
870
+ * DetectedElement {
871
+ * name: 'ICON',
872
+ * text: 'user',
873
+ * colors: [ 'red', 'red', 'red' ],
874
+ * bndbox: BoundingBox {
875
+ * xmin: 900,
876
+ * ymin: 910,
877
+ * xmax: 920,
878
+ * ymax: 930
879
+ * }
880
+ * }
881
+ * ]
882
+ * ```
883
+ * You can combine filters with **the `and()` relation** and specify exactly which icon you want
884
+ * ```typescript
885
+ * const icons = await aui.get().icon().withText('user').and().colored('red').exec()
886
+ * console.log(icons)
887
+ * ```
888
+ * The get command returns only the red icon although both icons have the same text
889
+ * ```text
890
+ * console output: [
891
+ * DetectedElement {
892
+ * name: 'ICON',
893
+ * text: 'user',
894
+ * colors: [ 'red', 'red', 'red' ],
895
+ * bndbox: BoundingBox {
896
+ * xmin: 900,
897
+ * ymin: 910,
898
+ * xmax: 920,
899
+ * ymax: 930
900
+ * }
901
+ * }
902
+ * ]
903
+ * ```
904
+ *
905
+ * @return {FluentFilters}
906
+ */
907
+ and() {
908
+ this._textStr = 'and';
909
+ return new FluentFilters(this);
910
+ }
784
911
  /**
785
912
  * Filters for an element inside another element.
786
913
  *
@@ -950,7 +1077,7 @@ export class FluentFiltersOrRelations extends FluentFilters {
950
1077
  return new FluentFilters(this);
951
1078
  }
952
1079
  exec() {
953
- return this.commandStringBuilder();
1080
+ return this.fluentCommandStringBuilder();
954
1081
  }
955
1082
  }
956
1083
  // Filters
@@ -1691,6 +1818,120 @@ export class FluentFiltersCondition extends FluentBase {
1691
1818
  }
1692
1819
  // Relations
1693
1820
  export class FluentFiltersOrRelationsCondition extends FluentFiltersCondition {
1821
+ /**
1822
+ * Logic or operator
1823
+ *
1824
+ * **Examples:**
1825
+ * ```text
1826
+ * scene 1
1827
+ * -------------- ---------------
1828
+ * | button | | icon |
1829
+ * -------------- ---------------
1830
+ *
1831
+ * scene 2
1832
+ * -------------- ---------------
1833
+ * | button | | text |
1834
+ * -------------- ---------------
1835
+ *
1836
+ * ```
1837
+ * In case, that your reference element can have multiple values, in the following example, the element right of the button can be either icon or text.
1838
+ * You can use **the `or()` relation**, so your teststep is valid for both scenes
1839
+ * ```typescript
1840
+ * const button = await aui.get().button().rightOf().icon().or().text().exec();
1841
+ * console.log(button);
1842
+ * ```
1843
+ * Returns the same button for both cases
1844
+ * ```text
1845
+ * console output: [
1846
+ * DetectedElement {
1847
+ * name: 'BUTTON',
1848
+ * text: 'button',
1849
+ * colors: [ 'red', 'black', 'red' ],
1850
+ * bndbox: BoundingBox {
1851
+ * xmin: 900,
1852
+ * ymin: 910,
1853
+ * xmax: 920,
1854
+ * ymax: 930
1855
+ * }
1856
+ * }
1857
+ * ]
1858
+ * ```
1859
+ *
1860
+ * @return {FluentFiltersCondition}
1861
+ */
1862
+ or() {
1863
+ this._textStr = 'or';
1864
+ return new FluentFiltersCondition(this);
1865
+ }
1866
+ /**
1867
+ * Logic and operator
1868
+ *
1869
+ * **Examples:**
1870
+ * ```text
1871
+ * example scene:
1872
+ * -------------------------- --------------------------
1873
+ * | icon user colored black | | icon user colored red |
1874
+ * -------------------------- --------------------------
1875
+ * ```
1876
+ * ```typescript
1877
+ * const icons = await aui.get().icon().withText('user').exec();
1878
+ * console.log(icons);
1879
+ * ```
1880
+ * Using only the filter withText, the get command will return both icons because they share the same text
1881
+ * ```text
1882
+ * console output: [
1883
+ * DetectedElement {
1884
+ * name: 'ICON',
1885
+ * text: 'user',
1886
+ * colors: [ 'black', 'black', 'black' ],
1887
+ * bndbox: BoundingBox {
1888
+ * xmin: 1000,
1889
+ * ymin: 1010,
1890
+ * xmax: 1020,
1891
+ * ymax: 1030
1892
+ * }
1893
+ * },
1894
+ * DetectedElement {
1895
+ * name: 'ICON',
1896
+ * text: 'user',
1897
+ * colors: [ 'red', 'red', 'red' ],
1898
+ * bndbox: BoundingBox {
1899
+ * xmin: 900,
1900
+ * ymin: 910,
1901
+ * xmax: 920,
1902
+ * ymax: 930
1903
+ * }
1904
+ * }
1905
+ * ]
1906
+ * ```
1907
+ * You can combine filters with **the `and()` relation** and specify exactly which icon you want
1908
+ * ```typescript
1909
+ * const icons = await aui.get().icon().withText('user').and().colored('red').exec()
1910
+ * console.log(icons)
1911
+ * ```
1912
+ * The get command returns only the red icon although both icons have the same text
1913
+ * ```text
1914
+ * console output: [
1915
+ * DetectedElement {
1916
+ * name: 'ICON',
1917
+ * text: 'user',
1918
+ * colors: [ 'red', 'red', 'red' ],
1919
+ * bndbox: BoundingBox {
1920
+ * xmin: 900,
1921
+ * ymin: 910,
1922
+ * xmax: 920,
1923
+ * ymax: 930
1924
+ * }
1925
+ * }
1926
+ * ]
1927
+ * ```
1928
+ *
1929
+ * @return {FluentFiltersCondition}
1930
+ */
1931
+ and() {
1932
+ this._textStr = 'and';
1933
+ return new FluentFiltersCondition(this);
1934
+ }
1694
1935
  /**
1695
1936
  * Filters for an element inside another element.
1696
1937
  *
@@ -1993,7 +2234,7 @@ export class FluentCommand extends FluentBase {
1993
2234
  * @return {Exec}
1994
2235
  */
1995
2236
  moveMouse(x_coordinate, y_coordinate) {
1996
- this._textStr = `Move mouse to x ${x_coordinate} y ${y_coordinate}`;
2237
+ this._textStr = `Move mouse to x ${x_coordinate} y ${y_coordinate}`;
1997
2238
  return new Exec(this);
1998
2239
  }
1999
2240
  /**
@@ -2166,3 +2407,1121 @@ export class FluentCommand extends FluentBase {
2166
2407
  return new Exec(this);
2167
2408
  }
2168
2409
  }
2410
+ export class ExecGetter extends FluentBase {
2411
+ exec() {
2412
+ return this.getterStringBuilder();
2413
+ }
2414
+ }
2415
+ // Filters
2416
+ export class FluentFiltersGetter extends FluentBase {
2417
+ /**
2418
+ * Filters for a UI element 'wizard item active'.
2419
+ *
2420
+ * @return {FluentFiltersOrRelationsGetter}
2421
+ */
2422
+ wizardItemActive() {
2423
+ this._textStr = 'wizard item active';
2424
+ return new FluentFiltersOrRelationsGetter(this);
2425
+ }
2426
+ /**
2427
+ * Filters for a UI element 'wizard item'.
2428
+ *
2429
+ * @return {FluentFiltersOrRelationsGetter}
2430
+ */
2431
+ wizardItem() {
2432
+ this._textStr = 'wizard item';
2433
+ return new FluentFiltersOrRelationsGetter(this);
2434
+ }
2435
+ /**
2436
+ * Filters for a UI element 'wizard'.
2437
+ *
2438
+ * @return {FluentFiltersOrRelationsGetter}
2439
+ */
2440
+ wizard() {
2441
+ this._textStr = 'wizard';
2442
+ return new FluentFiltersOrRelationsGetter(this);
2443
+ }
2444
+ /**
2445
+ * Filters for a UI element 'windows bar'.
2446
+ *
2447
+ * @return {FluentFiltersOrRelationsGetter}
2448
+ */
2449
+ windowsBar() {
2450
+ this._textStr = 'windows bar';
2451
+ return new FluentFiltersOrRelationsGetter(this);
2452
+ }
2453
+ /**
2454
+ * Filters for a UI element 'window'.
2455
+ *
2456
+ * @return {FluentFiltersOrRelationsGetter}
2457
+ */
2458
+ window() {
2459
+ this._textStr = 'window';
2460
+ return new FluentFiltersOrRelationsGetter(this);
2461
+ }
2462
+ /**
2463
+ * Filters for a UI element 'video'.
2464
+ *
2465
+ * @return {FluentFiltersOrRelationsGetter}
2466
+ */
2467
+ video() {
2468
+ this._textStr = 'video';
2469
+ return new FluentFiltersOrRelationsGetter(this);
2470
+ }
2471
+ /**
2472
+ * Filters for a UI element 'url'.
2473
+ *
2474
+ * @return {FluentFiltersOrRelationsGetter}
2475
+ */
2476
+ url() {
2477
+ this._textStr = 'url';
2478
+ return new FluentFiltersOrRelationsGetter(this);
2479
+ }
2480
+ /**
2481
+ * Filters for a UI element 'tooltip'.
2482
+ *
2483
+ * @return {FluentFiltersOrRelationsGetter}
2484
+ */
2485
+ tooltip() {
2486
+ this._textStr = 'tooltip';
2487
+ return new FluentFiltersOrRelationsGetter(this);
2488
+ }
2489
+ /**
2490
+ * Filters for a UI element 'textfield'.
2491
+ *
2492
+ * @return {FluentFiltersOrRelationsGetter}
2493
+ */
2494
+ textfield() {
2495
+ this._textStr = 'textfield';
2496
+ return new FluentFiltersOrRelationsGetter(this);
2497
+ }
2498
+ /**
2499
+ * Filters for a UI element 'textarea'.
2500
+ *
2501
+ * @return {FluentFiltersOrRelationsGetter}
2502
+ */
2503
+ textarea() {
2504
+ this._textStr = 'textarea';
2505
+ return new FluentFiltersOrRelationsGetter(this);
2506
+ }
2507
+ /**
2508
+ * Filters for a UI element 'table row'.
2509
+ *
2510
+ * @return {FluentFiltersOrRelationsGetter}
2511
+ */
2512
+ tableRow() {
2513
+ this._textStr = 'table row';
2514
+ return new FluentFiltersOrRelationsGetter(this);
2515
+ }
2516
+ /**
2517
+ * Filters for a UI element 'table header'.
2518
+ *
2519
+ * @return {FluentFiltersOrRelationsGetter}
2520
+ */
2521
+ tableHeader() {
2522
+ this._textStr = 'table header';
2523
+ return new FluentFiltersOrRelationsGetter(this);
2524
+ }
2525
+ /**
2526
+ * Filters for a UI element 'table column'.
2527
+ *
2528
+ * @return {FluentFiltersOrRelationsGetter}
2529
+ */
2530
+ tableColumn() {
2531
+ this._textStr = 'table column';
2532
+ return new FluentFiltersOrRelationsGetter(this);
2533
+ }
2534
+ /**
2535
+ * Filters for a UI element 'table'.
2536
+ *
2537
+ * @return {FluentFiltersOrRelationsGetter}
2538
+ */
2539
+ table() {
2540
+ this._textStr = 'table';
2541
+ return new FluentFiltersOrRelationsGetter(this);
2542
+ }
2543
+ /**
2544
+ * Filters for a UI element 'tab selected'.
2545
+ *
2546
+ * @return {FluentFiltersOrRelationsGetter}
2547
+ */
2548
+ tabSelected() {
2549
+ this._textStr = 'tab selected';
2550
+ return new FluentFiltersOrRelationsGetter(this);
2551
+ }
2552
+ /**
2553
+ * Filters for a UI element 'tab bar'.
2554
+ *
2555
+ * @return {FluentFiltersOrRelationsGetter}
2556
+ */
2557
+ tabBar() {
2558
+ this._textStr = 'tab bar';
2559
+ return new FluentFiltersOrRelationsGetter(this);
2560
+ }
2561
+ /**
2562
+ * Filters for a UI element 'tab active'.
2563
+ *
2564
+ * @return {FluentFiltersOrRelationsGetter}
2565
+ */
2566
+ tabActive() {
2567
+ this._textStr = 'tab active';
2568
+ return new FluentFiltersOrRelationsGetter(this);
2569
+ }
2570
+ /**
2571
+ * Filters for a UI element 'tab'.
2572
+ *
2573
+ * @return {FluentFiltersOrRelationsGetter}
2574
+ */
2575
+ tab() {
2576
+ this._textStr = 'tab';
2577
+ return new FluentFiltersOrRelationsGetter(this);
2578
+ }
2579
+ /**
2580
+ * Filters for a UI element 'switch enabled'.
2581
+ *
2582
+ * @return {FluentFiltersOrRelationsGetter}
2583
+ */
2584
+ switchEnabled() {
2585
+ this._textStr = 'switch enabled';
2586
+ return new FluentFiltersOrRelationsGetter(this);
2587
+ }
2588
+ /**
2589
+ * Filters for a UI element 'switch disabled'.
2590
+ *
2591
+ * @return {FluentFiltersOrRelationsGetter}
2592
+ */
2593
+ switchDisabled() {
2594
+ this._textStr = 'switch disabled';
2595
+ return new FluentFiltersOrRelationsGetter(this);
2596
+ }
2597
+ /**
2598
+ * Filters for a UI element 'status bar'.
2599
+ *
2600
+ * @return {FluentFiltersOrRelationsGetter}
2601
+ */
2602
+ statusBar() {
2603
+ this._textStr = 'status bar';
2604
+ return new FluentFiltersOrRelationsGetter(this);
2605
+ }
2606
+ /**
2607
+ * Filters for a UI element 'slider indicator'.
2608
+ *
2609
+ * @return {FluentFiltersOrRelationsGetter}
2610
+ */
2611
+ sliderIndicator() {
2612
+ this._textStr = 'slider indicator';
2613
+ return new FluentFiltersOrRelationsGetter(this);
2614
+ }
2615
+ /**
2616
+ * Filters for a UI element 'slider'.
2617
+ *
2618
+ * @return {FluentFiltersOrRelationsGetter}
2619
+ */
2620
+ slider() {
2621
+ this._textStr = 'slider';
2622
+ return new FluentFiltersOrRelationsGetter(this);
2623
+ }
2624
+ /**
2625
+ * Filters for a UI element 'sidebar'.
2626
+ *
2627
+ * @return {FluentFiltersOrRelationsGetter}
2628
+ */
2629
+ sidebar() {
2630
+ this._textStr = 'sidebar';
2631
+ return new FluentFiltersOrRelationsGetter(this);
2632
+ }
2633
+ /**
2634
+ * Filters for a UI element 'scroll bar'.
2635
+ *
2636
+ * @return {FluentFiltersOrRelationsGetter}
2637
+ */
2638
+ scrollBar() {
2639
+ this._textStr = 'scroll bar';
2640
+ return new FluentFiltersOrRelationsGetter(this);
2641
+ }
2642
+ /**
2643
+ * Filters for a UI element 'rect'.
2644
+ *
2645
+ * @return {FluentFiltersOrRelationsGetter}
2646
+ */
2647
+ rect() {
2648
+ this._textStr = 'rect';
2649
+ return new FluentFiltersOrRelationsGetter(this);
2650
+ }
2651
+ /**
2652
+ * Filters for a UI element 'recaptcha'.
2653
+ *
2654
+ * @return {FluentFiltersOrRelationsGetter}
2655
+ */
2656
+ recaptcha() {
2657
+ this._textStr = 'recaptcha';
2658
+ return new FluentFiltersOrRelationsGetter(this);
2659
+ }
2660
+ /**
2661
+ * Filters for a UI element 'rate'.
2662
+ *
2663
+ * @return {FluentFiltersOrRelationsGetter}
2664
+ */
2665
+ rate() {
2666
+ this._textStr = 'rate';
2667
+ return new FluentFiltersOrRelationsGetter(this);
2668
+ }
2669
+ /**
2670
+ * Filters for a UI element 'radio button unselected'.
2671
+ *
2672
+ * @return {FluentFiltersOrRelationsGetter}
2673
+ */
2674
+ radioButtonUnselected() {
2675
+ this._textStr = 'radio button unselected';
2676
+ return new FluentFiltersOrRelationsGetter(this);
2677
+ }
2678
+ /**
2679
+ * Filters for a UI element 'radio button selected'.
2680
+ *
2681
+ * @return {FluentFiltersOrRelationsGetter}
2682
+ */
2683
+ radioButtonSelected() {
2684
+ this._textStr = 'radio button selected';
2685
+ return new FluentFiltersOrRelationsGetter(this);
2686
+ }
2687
+ /**
2688
+ * Filters for a UI element 'progressbar'.
2689
+ *
2690
+ * @return {FluentFiltersOrRelationsGetter}
2691
+ */
2692
+ progressbar() {
2693
+ this._textStr = 'progressbar';
2694
+ return new FluentFiltersOrRelationsGetter(this);
2695
+ }
2696
+ /**
2697
+ * Filters for a UI element 'progress bar'.
2698
+ *
2699
+ * @return {FluentFiltersOrRelationsGetter}
2700
+ */
2701
+ progressBar() {
2702
+ this._textStr = 'progress bar';
2703
+ return new FluentFiltersOrRelationsGetter(this);
2704
+ }
2705
+ /**
2706
+ * Filters for a UI element 'popover'.
2707
+ *
2708
+ * @return {FluentFiltersOrRelationsGetter}
2709
+ */
2710
+ popover() {
2711
+ this._textStr = 'popover';
2712
+ return new FluentFiltersOrRelationsGetter(this);
2713
+ }
2714
+ /**
2715
+ * Filters for a UI element 'pil'.
2716
+ *
2717
+ * @return {FluentFiltersOrRelationsGetter}
2718
+ */
2719
+ pil() {
2720
+ this._textStr = 'pil';
2721
+ return new FluentFiltersOrRelationsGetter(this);
2722
+ }
2723
+ /**
2724
+ * Filters for a UI element 'password'.
2725
+ *
2726
+ * @return {FluentFiltersOrRelationsGetter}
2727
+ */
2728
+ password() {
2729
+ this._textStr = 'password';
2730
+ return new FluentFiltersOrRelationsGetter(this);
2731
+ }
2732
+ /**
2733
+ * Filters for a UI element 'pager'.
2734
+ *
2735
+ * @return {FluentFiltersOrRelationsGetter}
2736
+ */
2737
+ pager() {
2738
+ this._textStr = 'pager';
2739
+ return new FluentFiltersOrRelationsGetter(this);
2740
+ }
2741
+ /**
2742
+ * Filters for a UI element 'navigation bar'.
2743
+ *
2744
+ * @return {FluentFiltersOrRelationsGetter}
2745
+ */
2746
+ navigationBar() {
2747
+ this._textStr = 'navigation bar';
2748
+ return new FluentFiltersOrRelationsGetter(this);
2749
+ }
2750
+ /**
2751
+ * Filters for a UI element 'mouse text'.
2752
+ *
2753
+ * @return {FluentFiltersOrRelationsGetter}
2754
+ */
2755
+ mouseText() {
2756
+ this._textStr = 'mouse text';
2757
+ return new FluentFiltersOrRelationsGetter(this);
2758
+ }
2759
+ /**
2760
+ * Filters for a UI element 'mouse pointer'.
2761
+ *
2762
+ * @return {FluentFiltersOrRelationsGetter}
2763
+ */
2764
+ mousePointer() {
2765
+ this._textStr = 'mouse pointer';
2766
+ return new FluentFiltersOrRelationsGetter(this);
2767
+ }
2768
+ /**
2769
+ * Filters for a UI element 'mouse cursor'.
2770
+ *
2771
+ * @return {FluentFiltersOrRelationsGetter}
2772
+ */
2773
+ mouseCursor() {
2774
+ this._textStr = 'mouse cursor';
2775
+ return new FluentFiltersOrRelationsGetter(this);
2776
+ }
2777
+ /**
2778
+ * Filters for a UI element 'modal'.
2779
+ *
2780
+ * @return {FluentFiltersOrRelationsGetter}
2781
+ */
2782
+ modal() {
2783
+ this._textStr = 'modal';
2784
+ return new FluentFiltersOrRelationsGetter(this);
2785
+ }
2786
+ /**
2787
+ * Filters for a UI element 'message box'.
2788
+ *
2789
+ * @return {FluentFiltersOrRelationsGetter}
2790
+ */
2791
+ messageBox() {
2792
+ this._textStr = 'message box';
2793
+ return new FluentFiltersOrRelationsGetter(this);
2794
+ }
2795
+ /**
2796
+ * Filters for a UI element 'map'.
2797
+ *
2798
+ * @return {FluentFiltersOrRelationsGetter}
2799
+ */
2800
+ map() {
2801
+ this._textStr = 'map';
2802
+ return new FluentFiltersOrRelationsGetter(this);
2803
+ }
2804
+ /**
2805
+ * Filters for a UI element 'logo'.
2806
+ *
2807
+ * @return {FluentFiltersOrRelationsGetter}
2808
+ */
2809
+ logo() {
2810
+ this._textStr = 'logo';
2811
+ return new FluentFiltersOrRelationsGetter(this);
2812
+ }
2813
+ /**
2814
+ * Filters for a UI element 'link'.
2815
+ *
2816
+ * @return {FluentFiltersOrRelationsGetter}
2817
+ */
2818
+ link() {
2819
+ this._textStr = 'link';
2820
+ return new FluentFiltersOrRelationsGetter(this);
2821
+ }
2822
+ /**
2823
+ * Filters for a UI element 'keyboard'.
2824
+ *
2825
+ * @return {FluentFiltersOrRelationsGetter}
2826
+ */
2827
+ keyboard() {
2828
+ this._textStr = 'keyboard';
2829
+ return new FluentFiltersOrRelationsGetter(this);
2830
+ }
2831
+ /**
2832
+ * Filters for a UI element 'image'.
2833
+ *
2834
+ * @return {FluentFiltersOrRelationsGetter}
2835
+ */
2836
+ image() {
2837
+ this._textStr = 'image';
2838
+ return new FluentFiltersOrRelationsGetter(this);
2839
+ }
2840
+ /**
2841
+ * Filters for a UI element 'header'.
2842
+ *
2843
+ * @return {FluentFiltersOrRelationsGetter}
2844
+ */
2845
+ header() {
2846
+ this._textStr = 'header';
2847
+ return new FluentFiltersOrRelationsGetter(this);
2848
+ }
2849
+ /**
2850
+ * Filters for a UI element 'footer'.
2851
+ *
2852
+ * @return {FluentFiltersOrRelationsGetter}
2853
+ */
2854
+ footer() {
2855
+ this._textStr = 'footer';
2856
+ return new FluentFiltersOrRelationsGetter(this);
2857
+ }
2858
+ /**
2859
+ * Filters for a UI element 'flag'.
2860
+ *
2861
+ * @return {FluentFiltersOrRelationsGetter}
2862
+ */
2863
+ flag() {
2864
+ this._textStr = 'flag';
2865
+ return new FluentFiltersOrRelationsGetter(this);
2866
+ }
2867
+ /**
2868
+ * Filters for a UI element 'dropdown menu'.
2869
+ *
2870
+ * @return {FluentFiltersOrRelationsGetter}
2871
+ */
2872
+ dropdownMenu() {
2873
+ this._textStr = 'dropdown menu';
2874
+ return new FluentFiltersOrRelationsGetter(this);
2875
+ }
2876
+ /**
2877
+ * Filters for a UI element 'divider'.
2878
+ *
2879
+ * @return {FluentFiltersOrRelationsGetter}
2880
+ */
2881
+ divider() {
2882
+ this._textStr = 'divider';
2883
+ return new FluentFiltersOrRelationsGetter(this);
2884
+ }
2885
+ /**
2886
+ * Filters for a UI element 'circle'.
2887
+ *
2888
+ * @return {FluentFiltersOrRelationsGetter}
2889
+ */
2890
+ circle() {
2891
+ this._textStr = 'circle';
2892
+ return new FluentFiltersOrRelationsGetter(this);
2893
+ }
2894
+ /**
2895
+ * Filters for a UI element 'checkbox unchecked'.
2896
+ *
2897
+ * @return {FluentFiltersOrRelationsGetter}
2898
+ */
2899
+ checkboxUnchecked() {
2900
+ this._textStr = 'checkbox unchecked';
2901
+ return new FluentFiltersOrRelationsGetter(this);
2902
+ }
2903
+ /**
2904
+ * Filters for a UI element 'checkbox checked'.
2905
+ *
2906
+ * @return {FluentFiltersOrRelationsGetter}
2907
+ */
2908
+ checkboxChecked() {
2909
+ this._textStr = 'checkbox checked';
2910
+ return new FluentFiltersOrRelationsGetter(this);
2911
+ }
2912
+ /**
2913
+ * Filters for a UI element 'chart pie'.
2914
+ *
2915
+ * @return {FluentFiltersOrRelationsGetter}
2916
+ */
2917
+ chartPie() {
2918
+ this._textStr = 'chart pie';
2919
+ return new FluentFiltersOrRelationsGetter(this);
2920
+ }
2921
+ /**
2922
+ * Filters for a UI element 'chart'.
2923
+ *
2924
+ * @return {FluentFiltersOrRelationsGetter}
2925
+ */
2926
+ chart() {
2927
+ this._textStr = 'chart';
2928
+ return new FluentFiltersOrRelationsGetter(this);
2929
+ }
2930
+ /**
2931
+ * Filters for a UI element 'card'.
2932
+ *
2933
+ * @return {FluentFiltersOrRelationsGetter}
2934
+ */
2935
+ card() {
2936
+ this._textStr = 'card';
2937
+ return new FluentFiltersOrRelationsGetter(this);
2938
+ }
2939
+ /**
2940
+ * Filters for a UI element 'browser bar'.
2941
+ *
2942
+ * @return {FluentFiltersOrRelationsGetter}
2943
+ */
2944
+ browserBar() {
2945
+ this._textStr = 'browser bar';
2946
+ return new FluentFiltersOrRelationsGetter(this);
2947
+ }
2948
+ /**
2949
+ * Filters for a UI element 'breadcrumb'.
2950
+ *
2951
+ * @return {FluentFiltersOrRelationsGetter}
2952
+ */
2953
+ breadcrumb() {
2954
+ this._textStr = 'breadcrumb';
2955
+ return new FluentFiltersOrRelationsGetter(this);
2956
+ }
2957
+ /**
2958
+ * Filters for a UI element 'banner'.
2959
+ *
2960
+ * @return {FluentFiltersOrRelationsGetter}
2961
+ */
2962
+ banner() {
2963
+ this._textStr = 'banner';
2964
+ return new FluentFiltersOrRelationsGetter(this);
2965
+ }
2966
+ /**
2967
+ * Filters for a UI element 'badge'.
2968
+ *
2969
+ * @return {FluentFiltersOrRelationsGetter}
2970
+ */
2971
+ badge() {
2972
+ this._textStr = 'badge';
2973
+ return new FluentFiltersOrRelationsGetter(this);
2974
+ }
2975
+ /**
2976
+ * Filters for a UI element 'alert'.
2977
+ *
2978
+ * @return {FluentFiltersOrRelationsGetter}
2979
+ */
2980
+ alert() {
2981
+ this._textStr = 'alert';
2982
+ return new FluentFiltersOrRelationsGetter(this);
2983
+ }
2984
+ /**
2985
+ * Filters for a UI element 'unknown'.
2986
+ *
2987
+ * @return {FluentFiltersOrRelationsGetter}
2988
+ */
2989
+ unknown() {
2990
+ this._textStr = 'unknown';
2991
+ return new FluentFiltersOrRelationsGetter(this);
2992
+ }
2993
+ /**
2994
+ * Filters for an UI element 'button'.
2995
+ *
2996
+ * @return {FluentFiltersOrRelationsGetter}
2997
+ */
2998
+ button() {
2999
+ this._textStr = 'button';
3000
+ return new FluentFiltersOrRelationsGetter(this);
3001
+ }
3002
+ /**
3003
+ * Filters for an UI element 'text'.
3004
+ *
3005
+ * @return {FluentFiltersOrRelationsGetter}
3006
+ */
3007
+ text() {
3008
+ this._textStr = 'text';
3009
+ return new FluentFiltersOrRelationsGetter(this);
3010
+ }
3011
+ /**
3012
+ * Filters for an UI element 'dropdown'.
3013
+ *
3014
+ * @return {FluentFiltersOrRelationsGetter}
3015
+ */
3016
+ dropdown() {
3017
+ this._textStr = 'dropdown';
3018
+ return new FluentFiltersOrRelationsGetter(this);
3019
+ }
3020
+ /**
3021
+ * Filters for an UI element 'icon'.
3022
+ *
3023
+ * You can combine it with the 'withText' command to look for a specific icon.
3024
+ *
3025
+ * **Examples:**
3026
+ * ```typescript
3027
+ * icon().withText('plus')
3028
+ * ```
3029
+ *
3030
+ * Note: This is an alpha feature. The prediction of the icon name is sometimes unstable. Use custom elements as an alternative.
3031
+ *
3032
+ * @return {FluentFiltersOrRelationsGetter}
3033
+ */
3034
+ icon() {
3035
+ this._textStr = 'icon';
3036
+ return new FluentFiltersOrRelationsGetter(this);
3037
+ }
3038
+ /**
3039
+ * Filters for a custom UI element (see {@link CustomElementJson}).
3040
+ *
3041
+ * **Important**: This increases the runtime quite a bit. So
3042
+ * only use it when absolutely necessary.
3043
+ *
3044
+ * @param {CustomElementJson} customElement - The custom element to filter for.
3045
+ *
3046
+ * @return {FluentFiltersOrRelationsGetter}
3047
+ */
3048
+ customElement(customElement) {
3049
+ this._textStr = 'custom element';
3050
+ this._params.set('customElement', customElement);
3051
+ return new FluentFiltersOrRelationsGetter(this);
3052
+ }
3053
+ /**
3054
+ * Filters for a UI element 'checkbox' checked or unchecked.
3055
+ *
3056
+ * @return {FluentFiltersOrRelationsGetter}
3057
+ */
3058
+ checkbox() {
3059
+ this._textStr = 'checkbox';
3060
+ return new FluentFiltersOrRelationsGetter(this);
3061
+ }
3062
+ /**
3063
+ * Filters for similar (doesn't need to be a 100% equal) text.
3064
+ *
3065
+ * **Examples:**
3066
+ * ```typescript
3067
+ * 'text' === withText('text') => true
3068
+ * 'test' === withText('text') => true
3069
+ * 'other' === withText('text') => false
3070
+ * ```
3071
+ *
3072
+ * @param {string} text - A text to be matched.
3073
+ *
3074
+ * @return {FluentFiltersOrRelationsGetter}
3075
+ */
3076
+ withText(text) {
3077
+ this._textStr = `with text ${Separators.STRING}${text}${Separators.STRING}`;
3078
+ return new FluentFiltersOrRelationsGetter(this);
3079
+ }
3080
+ /**
3081
+ * Filters for texts, which match the regex pattern.
3082
+ *
3083
+ * **Examples:**
3084
+ *
3085
+ * ```typescript
3086
+ * 'The rain in Spain' === withTextRegex('\b[Ss]\w+') => true
3087
+ * 'The rain in Portugal' === withTextRegex('\b[Ss]\w+') => false
3088
+ * 'The rain in switzerland' === withTextRegex('\b[Ss]\w+') => true
3089
+ * ```
3090
+ *
3091
+ * @param {string} regex_pattern - An regex pattern
3092
+ *
3093
+ * @return {FluentFiltersOrRelationsGetter}
3094
+ */
3095
+ withTextRegex(regex_pattern) {
3096
+ this._textStr = `match regex pattern ${Separators.STRING}${regex_pattern}${Separators.STRING}`;
3097
+ return new FluentFiltersOrRelationsGetter(this);
3098
+ }
3099
+ /**
3100
+ * Filters for equal text.
3101
+ *
3102
+ * **Note:** This should be only used in cases where the similarity
3103
+ * comparison of {@link FluentFilters.withText()} allows not for
3104
+ * specific enough filtering (too many elements).
3105
+ *
3106
+ * **Examples:**
3107
+ * ```typescript
3108
+ * 'text' === withExactText('text') => true
3109
+ * 'test' === withExactText('text') => false
3110
+ * 'other' === withExactText('text') => false
3111
+ * ```
3112
+ *
3113
+ * @param {string} text - A text to be matched.
3114
+ *
3115
+ * @return {FluentFiltersOrRelationsGetter}
3116
+ */
3117
+ withExactText(text) {
3118
+ this._textStr = `equals text ${Separators.STRING}${text}${Separators.STRING}`;
3119
+ return new FluentFiltersOrRelationsGetter(this);
3120
+ }
3121
+ /**
3122
+ * Filters for text containing the text provided as an argument.
3123
+ *
3124
+ * **Examples:**
3125
+ * ```typescript
3126
+ * 'This is an text' === containsText('text') => true
3127
+ * 'This is an text' === containsText('other text') => false
3128
+ * 'This is an text' === containsText('other') => false
3129
+ * ```
3130
+ *
3131
+ * @param {string} text - A text to be matched.
3132
+ *
3133
+ * @return {FluentFiltersOrRelationsGetter}
3134
+ */
3135
+ containsText(text) {
3136
+ this._textStr = `contain text ${Separators.STRING}${text}${Separators.STRING}`;
3137
+ return new FluentFiltersOrRelationsGetter(this);
3138
+ }
3139
+ /**
3140
+ * Filters for elements having a specific color.
3141
+ *
3142
+ * @param {COLOR} color - A color to match
3143
+ *
3144
+ * @return {FluentFiltersOrRelationsGetter}
3145
+ */
3146
+ colored(color) {
3147
+ this._textStr = `with color ${color}`;
3148
+ return new FluentFiltersOrRelationsGetter(this);
3149
+ }
3150
+ }
3151
+ // Relations
3152
+ export class FluentFiltersOrRelationsGetter extends FluentFiltersGetter {
3153
+ /**
3154
+ * Logic or operator
3155
+ *
3156
+ * **Examples:**
3157
+ * ```text
3158
+ * scene 1
3159
+ * -------------- ---------------
3160
+ * | button | | icon |
3161
+ * -------------- ---------------
3162
+ *
3163
+ * scene 2
3164
+ * -------------- ---------------
3165
+ * | button | | text |
3166
+ * -------------- ---------------
3167
+ *
3168
+ * ```
3169
+ * In case, that your reference element can have multiple values, in the following example, the element right of the button can be either icon or text.
3170
+ * You can use **the `or()` relation**, so your teststep is valid for both scenes
3171
+ * ```typescript
3172
+ * const button = await aui.get().button().rightOf().icon().or().text().exec();
3173
+ * console.log(button);
3174
+ * ```
3175
+ * Returns the same button for both cases
3176
+ * ```text
3177
+ * console output: [
3178
+ * DetectedElement {
3179
+ * name: 'BUTTON',
3180
+ * text: 'button',
3181
+ * colors: [ 'red', 'black', 'red' ],
3182
+ * bndbox: BoundingBox {
3183
+ * xmin: 900,
3184
+ * ymin: 910,
3185
+ * xmax: 920,
3186
+ * ymax: 930
3187
+ * }
3188
+ * }
3189
+ * ]
3190
+ * ```
3191
+ *
3192
+ * @return {FluentFiltersGetter}
3193
+ */
3194
+ or() {
3195
+ this._textStr = 'or';
3196
+ return new FluentFiltersGetter(this);
3197
+ }
3198
+ /**
3199
+ * Logic and operator
3200
+ *
3201
+ * **Examples:**
3202
+ * ```text
3203
+ * example scene:
3204
+ * -------------------------- --------------------------
3205
+ * | icon user colored black | | icon user colored red |
3206
+ * -------------------------- --------------------------
3207
+ * ```
3208
+ * ```typescript
3209
+ * const icons = await aui.get().icon().withText('user').exec();
3210
+ * console.log(icons);
3211
+ * ```
3212
+ * Using only the filter withText, the get command will return both icons because they share the same text
3213
+ * ```text
3214
+ * console output: [
3215
+ * DetectedElement {
3216
+ * name: 'ICON',
3217
+ * text: 'user',
3218
+ * colors: [ 'black', 'black', 'black' ],
3219
+ * bndbox: BoundingBox {
3220
+ * xmin: 1000,
3221
+ * ymin: 1010,
3222
+ * xmax: 1020,
3223
+ * ymax: 1030
3224
+ * }
3225
+ * },
3226
+ * DetectedElement {
3227
+ * name: 'ICON',
3228
+ * text: 'user',
3229
+ * colors: [ 'red', 'red', 'red' ],
3230
+ * bndbox: BoundingBox {
3231
+ * xmin: 900,
3232
+ * ymin: 910,
3233
+ * xmax: 920,
3234
+ * ymax: 930
3235
+ * }
3236
+ * }
3237
+ * ]
3238
+ * ```
3239
+ * You can combine filters with **the `and()` relation** and specify exactly which icon you want
3240
+ * ```typescript
3241
+ * const icons = await aui.get().icon().withText('user').and().colored('red').exec()
3242
+ * console.log(icons)
3243
+ * ```
3244
+ * The get command returns only the red icon although both icons have the same text
3245
+ * ```text
3246
+ * console output: [
3247
+ * DetectedElement {
3248
+ * name: 'ICON',
3249
+ * text: 'user',
3250
+ * colors: [ 'red', 'red', 'red' ],
3251
+ * bndbox: BoundingBox {
3252
+ * xmin: 900,
3253
+ * ymin: 910,
3254
+ * xmax: 920,
3255
+ * ymax: 930
3256
+ * }
3257
+ * }
3258
+ * ]
3259
+ * ```
3260
+ *
3261
+ * @return {FluentFiltersGetter}
3262
+ */
3263
+ and() {
3264
+ this._textStr = 'and';
3265
+ return new FluentFiltersGetter(this);
3266
+ }
3267
+ /**
3268
+ * Filters for an element inside another element.
3269
+ *
3270
+ * **Examples:**
3271
+ * ```typescript
3272
+ * --------------------
3273
+ * | outerEl |
3274
+ * | -------------- |
3275
+ * | | innerEl | |
3276
+ * | -------------- |
3277
+ * | |
3278
+ * --------------------
3279
+ *
3280
+ * // Returns innerEl because innerEl is inside outerEl
3281
+ * ...innerEl().in().outerEl()
3282
+ * // Returns nothing because innerEl is not inside outerEl
3283
+ * ...outerEl().in().innerEl()
3284
+ * ```
3285
+ *
3286
+ * @return {FluentFiltersGetter}
3287
+ */
3288
+ in() {
3289
+ this._textStr = 'in';
3290
+ return new FluentFiltersGetter(this);
3291
+ }
3292
+ /**
3293
+ * Filters for an element right of another element.
3294
+ *
3295
+ * **Examples:**
3296
+ * ```typescript
3297
+ * -------------- --------------
3298
+ * | leftEl | | rightEl |
3299
+ * -------------- --------------
3300
+ *
3301
+ * // Returns rightEl because rightEl is right of leftEl
3302
+ * ...rightEl().rightOf().leftEl()
3303
+ * // Returns no element because leftEl is left of rightEl
3304
+ * ...leftEl().rightOf().rightEl()
3305
+ * ```
3306
+ *
3307
+ * @return {FluentFiltersGetter}
3308
+ */
3309
+ rightOf() {
3310
+ this._textStr = 'right of';
3311
+ return new FluentFiltersGetter(this);
3312
+ }
3313
+ /**
3314
+ * Filters for an element left of another element.
3315
+ *
3316
+ * **Examples:**
3317
+ * ```typescript
3318
+ * -------------- --------------
3319
+ * | leftEl | | rightEl |
3320
+ * -------------- --------------
3321
+ *
3322
+ * // Returns leftEl because leftEl is left of rightEl
3323
+ * ...leftEl().leftOf().rightEl()
3324
+ * // Returns no element because rightEl is left of leftEl
3325
+ * ...rightEl().leftOf().leftEl()
3326
+ * ```
3327
+ *
3328
+ * @return {FluentFiltersGetter}
3329
+ */
3330
+ leftOf() {
3331
+ this._textStr = 'left of';
3332
+ return new FluentFiltersGetter(this);
3333
+ }
3334
+ /**
3335
+ * Filters for an element below another element.
3336
+ *
3337
+ * **Examples:**
3338
+ * ```typescript
3339
+ * --------------
3340
+ * | text |
3341
+ * --------------
3342
+ * --------------
3343
+ * | button |
3344
+ * --------------
3345
+ *
3346
+ * // Returns button because button is below text
3347
+ * ...button().below().text()
3348
+ * // Returns no element because text is above button
3349
+ * ...text().below().button()
3350
+ * ```
3351
+ *
3352
+ * @return {FluentFiltersGetter}
3353
+ */
3354
+ below() {
3355
+ this._textStr = 'below';
3356
+ return new FluentFiltersGetter(this);
3357
+ }
3358
+ /**
3359
+ * Filters for an element above another element.
3360
+ *
3361
+ * **Examples:**
3362
+ * ```typescript
3363
+ * --------------
3364
+ * | text |
3365
+ * --------------
3366
+ * --------------
3367
+ * | button |
3368
+ * --------------
3369
+ *
3370
+ * // Returns text because text is above button
3371
+ * ...text().above().button()
3372
+ * // Returns no element because button is below text
3373
+ * ...button().above().text()
3374
+ * ```
3375
+ *
3376
+ * @return {FluentFiltersGetter}
3377
+ */
3378
+ above() {
3379
+ this._textStr = 'above';
3380
+ return new FluentFiltersGetter(this);
3381
+ }
3382
+ /**
3383
+ * Filters for an element nearest to another element.
3384
+ *
3385
+ * **Examples:**
3386
+ * ```typescript
3387
+ * --------------
3388
+ * | button 1 |
3389
+ * --------------
3390
+ * --------------
3391
+ * | text |
3392
+ * --------------
3393
+ *
3394
+ *
3395
+ *
3396
+ * --------------
3397
+ * | button 2 |
3398
+ * --------------
3399
+ *
3400
+ * // Returns button 1 because button 1 is nearer to the text than button 2
3401
+ * ...button().nearestTo().text()
3402
+ * ```
3403
+ *
3404
+ * @return {FluentFiltersGetter}
3405
+ */
3406
+ nearestTo() {
3407
+ this._textStr = 'nearest to';
3408
+ return new FluentFiltersGetter(this);
3409
+ }
3410
+ /**
3411
+ * Filters for an element containing another element.
3412
+ *
3413
+ * **Example:**
3414
+ * ```typescript
3415
+ * --------------------
3416
+ * | outerEl |
3417
+ * | -------------- |
3418
+ * | | innerEl | |
3419
+ * | -------------- |
3420
+ * | |
3421
+ * --------------------
3422
+ *
3423
+ * // Returns outerEl because outerEl contains innerEl
3424
+ * ...outerEl().contains().innerEl()
3425
+ * // Returns no element because innerEl contains no outerEl
3426
+ * ...innerEl().contains().outerEl()
3427
+ * ```
3428
+ *
3429
+ * @return {FluentFiltersGetter}
3430
+ */
3431
+ contains() {
3432
+ this._textStr = 'contains';
3433
+ return new FluentFiltersGetter(this);
3434
+ }
3435
+ /**
3436
+ * Returns a list of detected elements
3437
+ *
3438
+ * @return {DetectedElement[]}
3439
+ */
3440
+ exec() {
3441
+ return this.getterStringBuilder();
3442
+ }
3443
+ }
3444
+ // Commands
3445
+ export class Getter extends FluentCommand {
3446
+ /**
3447
+ * Returns an array with all filtered elements.
3448
+ * A detected element has the following properties:
3449
+ * - `name` of the element
3450
+ * - `text` content of element
3451
+ * - `colors` of element
3452
+ * - `bndbox`: location of element described with coordinates of a bounding box
3453
+ * **Examples:**
3454
+ * ```typescript
3455
+ * const text = await aui.get().text().withText('Sign').exec();
3456
+ * console.log(text);
3457
+ * ```
3458
+ * ```text
3459
+ * console output: [
3460
+ * DetectedElement {
3461
+ * name: 'TEXT',
3462
+ * text: 'Sign In',
3463
+ * colors: [ 'black', 'gray', 'gray' ],
3464
+ * bndbox: BoundingBox {
3465
+ * xmin: 1128.2720982142857,
3466
+ * ymin: 160.21332310267857,
3467
+ * xmax: 1178.8204241071428,
3468
+ * ymax: 180.83512834821428
3469
+ * }
3470
+ * }
3471
+ * ]
3472
+ * ```
3473
+ *
3474
+ * @return {FluentFiltersGetter}
3475
+ */
3476
+ get() {
3477
+ this._textStr = 'get element';
3478
+ return new FluentFiltersGetter(this);
3479
+ }
3480
+ /**
3481
+ * Returns an array with all detected elements.
3482
+ * A detected element has the following properties:
3483
+ * - `name` of the element
3484
+ * - `text` content of element
3485
+ * - `colors` of element
3486
+ * - `bndbox`: location of element described with coordinates of a bounding box
3487
+ * **Examples:**
3488
+ * ```typescript
3489
+ * const detectedElements = await aui.getAll().exec();
3490
+ * console.log(detectedElements);
3491
+ * ```
3492
+ * ```text
3493
+ * console output: [
3494
+ * DetectedElement {
3495
+ * name: 'TEXT',
3496
+ * text: 'Sign In',
3497
+ * colors: [ 'black', 'gray', 'gray' ],
3498
+ * bndbox: BoundingBox {
3499
+ * xmin: 1128.2720982142857,
3500
+ * ymin: 160.21332310267857,
3501
+ * xmax: 1178.8204241071428,
3502
+ * ymax: 180.83512834821428
3503
+ * },
3504
+ * DetectedElement {
3505
+ * name: 'ICON',
3506
+ * text: 'search',
3507
+ * colors: [ 'black', 'red', 'gray' ],
3508
+ * bndbox: BoundingBox {
3509
+ * xmin: 250.8204241071428,
3510
+ * ymin: 300.21332310267857,
3511
+ * xmax: 450.6304241071428,
3512
+ * ymax: 950.47812834821428
3513
+ * },
3514
+ * ... 381 more items
3515
+ * }
3516
+ * ]
3517
+ * ```
3518
+ *
3519
+ * @return {ExecGetter}
3520
+ */
3521
+ getAll() {
3522
+ this._textStr = 'get all elements';
3523
+ return new ExecGetter(this);
3524
+ }
3525
+ }
3526
+ export class ApiCommands extends Getter {
3527
+ }