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