alttester-robotframework-library 0.0.1__py3-none-any.whl

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.
@@ -0,0 +1,1639 @@
1
+ """
2
+ Copyright(C) 2023 Altom Consulting
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ """
17
+
18
+ from alttester import AltDriver, AltObject, AltReversePortForwarding
19
+ from alttester import By, AltKeyCode, PlayerPrefKeyType, AltLogger, AltLogLevel
20
+
21
+
22
+ class AltTesterKeywords(object):
23
+ DEFAULT_WAIT = 20
24
+
25
+ def __init__(self):
26
+ self._driver = None
27
+
28
+ def initialize_altdriver(
29
+ self,
30
+ host="127.0.0.1",
31
+ port=13000,
32
+ app_name="__default__",
33
+ enable_logging=False,
34
+ timeout=60,
35
+ platform="unknown",
36
+ platform_version="unknown",
37
+ device_instance_id="unknown",
38
+ app_id="unknown"
39
+ ):
40
+ """Initialize AltDriver and return it.
41
+
42
+ `host` : The host to connect to. The default value is "127.0.0.1".
43
+
44
+ `port` : The port to connect to. The default value is 13000.
45
+
46
+ `app_name` : The name of the Unity application. The default value is ``__default__``.
47
+
48
+ `enable_logging` : If set to ``True`` will turn on logging, by default logging is disabled.
49
+
50
+ `timeout` : The connect timeout in seconds. The default value is 60.
51
+
52
+ `platform` : The platform of the device. The default value is ``unknown``.
53
+
54
+ `platform_version` : The version of the platform. The default value is ``unknown``.
55
+
56
+ `device_instance_id` : The id of the device. The default value is ``unknown``.
57
+
58
+ `app_id` : The id of the application. The default value is ``unknown``.
59
+
60
+ Example:
61
+
62
+ | ${altDriver}= | Initialize AltDriver | 127.0.0.1 | 15001
63
+
64
+ | ${altDriver}= | Initialize AltDriver | platform="Android"
65
+
66
+ """
67
+ self._driver = AltDriver(
68
+ host=host,
69
+ port=port,
70
+ app_name=app_name,
71
+ enable_logging=enable_logging,
72
+ timeout=timeout,
73
+ platform=platform,
74
+ platform_version=platform_version,
75
+ device_instance_id=device_instance_id,
76
+ app_id=app_id
77
+ )
78
+ return self._driver
79
+
80
+ def stop_altdriver(self):
81
+ """Close the connection to AltTester.
82
+
83
+ Example:
84
+
85
+ Stop AltDriver
86
+ """
87
+ self._driver.stop()
88
+
89
+ def get_command_response_timeout(self):
90
+ """Gets the current command response timeout for the AltTester® connection.
91
+
92
+ Example:
93
+
94
+ ${timeout}= | Get Command Response Timeout
95
+ """
96
+ return self._driver.get_command_response_timeout()
97
+
98
+ def set_command_response_timeout(self, timeout):
99
+ """Sets the command response timeout for the AltTester® connection.
100
+
101
+ timeout : The new command response timeout in seconds.
102
+
103
+ Example:
104
+
105
+ Set Command Response Timeout | 30
106
+ """
107
+ self._driver.set_command_response_timeout(timeout)
108
+
109
+ def reverse_port_forwarding_android(self, device_port=13000, local_port=13000):
110
+ """This method calls adb reverse [-s {deviceId}] tcp:{remotePort} tcp:{localPort}.
111
+
112
+ device_port : The id of the device. The default value is ``1300``.
113
+
114
+ local_port : The local port to do reverse port forwarding to. The default value is ``1300``.
115
+
116
+ Example:
117
+
118
+ Reverse Port Forwarding Android device_port=15500
119
+ """
120
+ AltReversePortForwarding.reverse_port_forwarding_android(
121
+ device_port, local_port)
122
+
123
+ def remove_reverse_port_forwarding_android(device_port=13000):
124
+ """This method calls adb reverse --remove [-s {deviceId}] tcp:{devicePort} or adb reverse --remove-all if no port is provided.
125
+
126
+ device_port : The device port to be removed. The default value is ``1300``.
127
+
128
+ Example:
129
+
130
+ Remove Reverse Port Forwarding Android device_port=15500
131
+ """
132
+ AltReversePortForwarding.remove_reverse_port_forwarding_android(
133
+ device_port)
134
+
135
+ def remove_all_reverse_port_forwardings_android():
136
+ """This method calls adb reverse --remove-all.
137
+
138
+ Example:
139
+
140
+ Remove All Reverse Port Forwarding Android
141
+ """
142
+ AltReversePortForwarding.remove_all_reverse_port_forwardings_android()
143
+
144
+ def find_object(self, locator_strategy,
145
+ locator, camera_by="NAME", camera_value="", enabled=True):
146
+ """Finds the first object in the scene that respects the given criteria.
147
+
148
+ `locator_strategy` one of the following: ID, NAME, PATH, LAYER,
149
+ COMPONENT, TAG, TEXT.
150
+
151
+ `locator` : The actual locator value.
152
+
153
+ `camera_by` one of the following: ID, NAME, PATH, LAYER,
154
+ COMPONENT, TAG, TEXT. The default value is ``NAME``
155
+
156
+ `camera_value` : The actual camera value.The default value is ``""``
157
+
158
+ `enabled` : If true will match only objects that are active in hierarchy. If false will match all objects.The default value is ``True``
159
+
160
+ Example:
161
+
162
+ Find Object by PATH
163
+
164
+ | ${logo}= | Find Object | PATH | //Canvas//Logo | enabled=${False}
165
+ """
166
+ return self._driver.find_object(self.get_by_enum(locator_strategy), locator,
167
+ camera_by=self.get_by_enum(camera_by),
168
+ camera_value=camera_value, enabled=enabled)
169
+
170
+ def find_objects(self, locator_strategy,
171
+ locator, camera_by="NAME", camera_value="", enabled=True):
172
+ """Finds all objects in the scene that respects the given criteria.
173
+
174
+ `locator_strategy` one of the following: ID, NAME, PATH, LAYER,
175
+ COMPONENT, TAG, TEXT.
176
+
177
+ `locator` : The actual locator value.
178
+
179
+ `camera_by` one of the following: ID, NAME, PATH, LAYER,
180
+ COMPONENT, TAG, TEXT.The default value is ``NAME``
181
+
182
+ `camera_value` : The actual camera value. The default value is ``""``
183
+
184
+ `enabled` : If true will match only objects that are active in hierarchy. If false will match all objects.The default value is ``True``
185
+
186
+ Example:
187
+
188
+ Find Objects by PATH
189
+
190
+ | ${logo}= | Find Objects | PATH | //Canvas//Logo | enabled=${False}
191
+ """
192
+ return self._driver.find_objects(self.get_by_enum(locator_strategy), locator,
193
+ camera_by=self.get_by_enum(camera_by),
194
+ camera_value=camera_value, enabled=enabled)
195
+
196
+ def find_object_which_contains(self, locator_strategy,
197
+ locator, camera_by="NAME", camera_value="", enabled=True):
198
+ """Finds the first object in the scene that respects the given criteria.
199
+
200
+ `locator_strategy` one of the following: ID, NAME, PATH, LAYER,
201
+ COMPONENT, TAG, TEXT.
202
+
203
+ `locator` : The actual locator value.
204
+
205
+ `camera_by` one of the following: ID, NAME, PATH, LAYER,
206
+ COMPONENT, TAG, TEXT.The default value is ``NAME``
207
+
208
+ `camera_value` : The actual camera value.The default value is ``""``
209
+
210
+ `enabled` : If true will match only objects that are active in hierarchy. If false will match all objects.The default value is ``True``
211
+
212
+ Example:
213
+
214
+ Find Object Which Contains in Text
215
+
216
+ | ${logo}= | Find Object Which Contains | TEXT | Logo | enabled=${False}
217
+ """
218
+ return self._driver.find_object_which_contains(self.get_by_enum(locator_strategy), locator,
219
+ camera_by=self.get_by_enum(
220
+ camera_by),
221
+ camera_value=camera_value, enabled=enabled)
222
+
223
+ def find_objects_which_contain(self, locator_strategy,
224
+ locator, camera_by="NAME", camera_value="", enabled=True):
225
+ """Finds all objects in the scene that respects the given criteria.
226
+
227
+ `locator_strategy` one of the following: ID, NAME, PATH, LAYER,
228
+ COMPONENT, TAG, TEXT.
229
+
230
+ `locator` : The actual locator value.
231
+
232
+ `camera_by` one of the following: ID, NAME, PATH, LAYER,
233
+ COMPONENT, TAG, TEXT. The default value is ``NAME``
234
+
235
+ `camera_value` : The actual camera value.The default value is ``""``
236
+
237
+ `enabled` : If true will match only objects that are active in hierarchy. If false will match all objects.The default value is ``True``
238
+
239
+ Example:
240
+
241
+ Find Objects Which Contain in Text
242
+
243
+ | ${logo}= | Find Objects Which Contain | TEXT | Logo | enabled=${False}
244
+ """
245
+ return self._driver.find_objects_which_contain(self.get_by_enum(locator_strategy), locator,
246
+ camera_by=self.get_by_enum(
247
+ camera_by),
248
+ camera_value=camera_value, enabled=enabled)
249
+
250
+ def find_object_at_coordinates(self, coordinates):
251
+ """Retrieves the Unity object at given coordinates or ``None`` otherwise.
252
+
253
+ `coordinates` : The screen coordinates.
254
+
255
+ Example:
256
+
257
+ Find Object at coordinates [20, 20].
258
+
259
+ | ${coordinates} | = | Create List ${20} ${20}
260
+
261
+ | ${object}= | Find Object At Coordinates | ${coordinates}
262
+ """
263
+ return self._driver.find_object_at_coordinates(coordinates)
264
+
265
+ def get_all_elements(self, camera_by="NAME", camera_value="", enabled=True):
266
+ """Returns information about every objects loaded in the currently loaded scenes. This also means objects that
267
+ are set as DontDestroyOnLoad.
268
+
269
+ `camera_by` one of the following: ID, NAME, PATH, LAYER,
270
+ COMPONENT, TAG, TEXT. The default value is ``NAME``
271
+
272
+ `camera_value` : The actual camera value. The default value is ``""``
273
+
274
+ `enable` : If true will match only objects that are active in hierarchy. If false will match all objects.The default value is ``True``
275
+
276
+ Example:
277
+
278
+ Get All Elements
279
+
280
+ | ${elements}= | Get All Elements | enabled=${False}
281
+ """
282
+ return self._driver.get_all_elements(self.get_by_enum(camera_by), camera_value=camera_value, enabled=enabled)
283
+
284
+ def wait_for_object(self, locator_strategy,
285
+ locator, camera_by="NAME", camera_value="", timeout=DEFAULT_WAIT, interval=0.5, enabled=True):
286
+ """Wait for an object using a locator strategy and locator value, then return it.
287
+
288
+ `locator_strategy` one of the following: ID, NAME, PATH, LAYER,
289
+ COMPONENT, TAG, TEXT
290
+
291
+ `locator` the actual locator value
292
+
293
+ `camera_by` one of the following: ID, NAME, PATH, LAYER,
294
+ COMPONENT, TAG, TEXT. The default value is ``NAME``
295
+
296
+ `camera_value` : The actual camera value. The default value is ``""``
297
+
298
+ `timeout` : How long to wait for the object to appear. The default value is 20 seconds.
299
+
300
+ `interval` : : The number of seconds after which it will try to find the object again. The interval should be smaller than the timeout. The default value is 0.5.
301
+
302
+ `enabled` : If true will match only objects that are active in hierarchy. If false will match all objects.The default value is ``True``
303
+
304
+ Example:
305
+
306
+ Wait For Object by PATH
307
+
308
+ | ${logo}= | Wait for Object | PATH | //Canvas//Logo | timeout=5
309
+
310
+ """
311
+ return self._driver.wait_for_object(self.get_by_enum(locator_strategy), locator,
312
+ camera_by=self.get_by_enum(camera_by), camera_value=camera_value,
313
+ timeout=timeout, interval=interval, enabled=enabled)
314
+
315
+ def wait_for_object_which_contains(self, locator_strategy,
316
+ locator, camera_by="NAME", camera_value="", timeout=DEFAULT_WAIT, interval=0.5, enabled=True):
317
+ """Wait for an object using a locator strategy and locator value, then return it.
318
+
319
+ `locator_strategy` one of the following: ID, NAME, PATH, LAYER,
320
+ COMPONENT, TAG, TEXT
321
+
322
+ `locator` : the actual locator value
323
+
324
+ `camera_by` one of the following: ID, NAME, PATH, LAYER,
325
+ COMPONENT, TAG, TEXT. The default value is ``NAME``
326
+
327
+ `camera_value` : The actual camera value. The default value is ``""``
328
+
329
+ `timeout` : How long to wait for the object to appear. The default value is 20 seconds.
330
+
331
+ `interval` : The number of seconds after which it will try to find the object again. The interval should be smaller than the timeout. The default value is 0.5.
332
+
333
+ `enabled` : If true will match only objects that are active in hierarchy. If false will match all objects. The default value is ``True``
334
+
335
+ Example:
336
+
337
+ Wait For Object Which Contains TEXT
338
+
339
+ | ${logo}= | Wait for object Which Contains | TEXT | Logo | timeout=5 | enabled=${False}
340
+ """
341
+ return self._driver.wait_for_object_which_contains(self.get_by_enum(locator_strategy), locator,
342
+ camera_by=self.get_by_enum(camera_by), camera_value=camera_value,
343
+ timeout=timeout, interval=interval, enabled=enabled)
344
+
345
+ def wait_for_object_to_not_be_present(self, locator_strategy,
346
+ locator, camera_by="NAME", camera_value="", timeout=DEFAULT_WAIT, interval=0.5, enabled=True):
347
+ """Waits until the object in the scene that respects the given criteria is no longer in the scene or until
348
+ timeout limit is reached.
349
+
350
+ `locator_strategy` one of the following: ID, NAME, PATH, LAYER,
351
+ COMPONENT, TAG, TEXT
352
+
353
+ `locator` : the actual locator value
354
+
355
+ `camera_by` one of the following: ID, NAME, PATH, LAYER,
356
+ COMPONENT, TAG, TEXT. The default value is ``NAME``
357
+
358
+ `camera_value` : The actual camera value. The default value is ``""``
359
+
360
+ `timeout` : How long to wait for the object to appear. The default value is 20 seconds.
361
+
362
+ `interval` : The number of seconds after which it will try to find the object again. The interval should be smaller than the timeout. The default value is 0.5.
363
+
364
+ `enabled` : If true will match only objects that are active in hierarchy. If false will match all objects. The default value is ``True``
365
+
366
+ Example:
367
+
368
+ Wait For Object To Not Be Present with TEXT
369
+
370
+ | ${logo}= | Wait For Object To Not Be Present | TEXT | Logo | timeout=5
371
+ """
372
+ self._driver.wait_for_object_to_not_be_present(self.get_by_enum(locator_strategy), locator,
373
+ camera_by=self.get_by_enum(camera_by), camera_value=camera_value,
374
+ timeout=timeout, interval=interval, enabled=enabled)
375
+
376
+ def set_command_response_timeout(self, timeout):
377
+ """Sets the command response timeout for the AltTester® connection.
378
+
379
+ timeout: The new command response timeout in seconds.
380
+
381
+ Example:
382
+
383
+ Set Command Response Timeout to 30 seconds.
384
+
385
+ | Set Command Response Timeout | 30
386
+ """
387
+ self._driver.set_command_response_timeout(timeout)
388
+
389
+ def get_delay_after_command(self):
390
+ """Gets the current delay after a command.
391
+
392
+ Example:
393
+
394
+ Get Delay After Command
395
+
396
+ | ${delay}= | Get Delay After Command
397
+ """
398
+ return self._driver.get_delay_after_command()
399
+
400
+ def set_delay_after_command(self, delay):
401
+ """Sets the delay after a command.
402
+
403
+ Example:
404
+
405
+ Set Delay After Command to 10 seconds.
406
+
407
+ | Set Delay After Command | 10
408
+ """
409
+ self._driver.set_delay_after_command(delay)
410
+
411
+ def key_down(self, key_code, power=1):
412
+ """Simulates that a specific key was pressed without taking into consideration the duration of the press.
413
+
414
+ key_code : The key code of the key simulated to be pressed.
415
+
416
+ power : A value between [-1,1] used for joysticks to indicate how hard the button
417
+ was pressed. Default value is ``1``.
418
+
419
+ Example:
420
+
421
+ Press Key A Down
422
+
423
+ | Key Down | A
424
+ """
425
+ try:
426
+ self._driver.key_down(getattr(AltKeyCode, key_code), power=power)
427
+ except AttributeError:
428
+ raise ValueError(
429
+ "Invalid kay code for: {code}".format(code=key_code))
430
+
431
+ def keys_down(self, key_codes, power=1):
432
+ """Simulates that multiple keys were pressed without taking into consideration the duration of the press.
433
+
434
+ key_codes : The key codes of the keys simulated to be pressed.
435
+
436
+ power : A value between [-1,1] used for joysticks to indicate how hard the button
437
+ was pressed. Default value is ``1``.
438
+
439
+ Example:
440
+
441
+ Press Keys A and B Down
442
+
443
+ | ${keys} | = | Create List | A | B
444
+
445
+ | Keys Down | ${keys}
446
+ """
447
+ list = []
448
+ for key in key_codes:
449
+ try:
450
+ list.append(getattr(AltKeyCode, key))
451
+ except AttributeError:
452
+ raise ValueError(
453
+ "Invalid kay code for: {code}".format(code=key))
454
+ self._driver.keys_down(list, power=power)
455
+
456
+ def key_up(self, key_code):
457
+ """Simulates a key up.
458
+
459
+ key_code : The keyCode of the key simulated to be released.
460
+
461
+ Example:
462
+
463
+ Press Key A Up
464
+
465
+ Key Up | A
466
+ """
467
+ try:
468
+ self._driver.key_up(getattr(AltKeyCode, key_code))
469
+ except AttributeError:
470
+ raise ValueError(
471
+ "Invalid kay code for: {code}".format(code=key_code))
472
+
473
+ def keys_up(self, key_codes):
474
+ """Simulates that multiple keys were released.
475
+
476
+ key_codes : The key codes of the keys simulated to be released.
477
+
478
+ Example:
479
+
480
+ Press Key A and B Up
481
+
482
+ | ${keys} | = | Create List | A | B
483
+
484
+ Keys Up | ${keys}
485
+ """
486
+ list = []
487
+ for key in key_codes:
488
+ try:
489
+ list.append(getattr(AltKeyCode, key))
490
+ except AttributeError:
491
+ raise ValueError(
492
+ "Invalid kay code for: {code}".format(code=key))
493
+ self._driver.keys_up(list)
494
+
495
+ def hold_button(self, coordinates, duration=0.1, wait=True):
496
+ """Simulates holding left click button down for a specified amount of time at given coordinates.
497
+
498
+ coordinates : The coordinates where the button is held down.
499
+
500
+ duration : The time measured in seconds to keep the button down. Default value is``0.1``.
501
+
502
+ wait : If set wait for command to finish. Default value is ``True``.
503
+
504
+ Example:
505
+
506
+ Hold Button for 1 second
507
+
508
+ | ${coordinates} | = | Create List | 20 | 20
509
+
510
+ | Hold Button | ${coordinates} | duration=1
511
+ """
512
+ self._driver.hold_button(coordinates, duration=duration, wait=wait)
513
+
514
+ def move_mouse(self, coordinates, duration=0.1, wait=True):
515
+ """Simulates mouse movement in your application.
516
+
517
+ coordinates : The screen coordinates.
518
+
519
+ duration : The time measured in seconds to move the mouse from current position to the set location. Default value is``0.1``
520
+
521
+ wait : If set wait for command to finish. Default value is ``True``.
522
+
523
+ Example:
524
+
525
+ Move Mouse for 1 second and don't wait to finish.
526
+
527
+ | ${coordinates} | = | Create List | 100 | 100
528
+
529
+ | Move Mouse | ${coordinates} | duration=1 | wait=${False}
530
+ """
531
+ self._driver.move_mouse(coordinates, duration=duration, wait=wait)
532
+
533
+ def press_key(self, key_code, power=1, duration=0.1, wait=True):
534
+ """Simulates key press action in your application.
535
+
536
+ key_code : The key code of the key simulated to be pressed.
537
+
538
+ power : A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Default value is ``1``.
539
+
540
+ duration : The time measured in seconds from the key press to the key release. Default value is ``0.1``
541
+
542
+ wait : If set wait for command to finish. Default value is ``True``.
543
+
544
+ Example:
545
+
546
+ Press Key Mouse0 for 1 second.
547
+
548
+ | Press Key | Mouse0 | duration=1
549
+ """
550
+ try:
551
+ self._driver.press_key(getattr(AltKeyCode, key_code), power=power,
552
+ duration=duration, wait=wait)
553
+ except AttributeError:
554
+ raise ValueError(
555
+ "Invalid kay code for: {code}".format(code=key_code))
556
+
557
+ def press_keys(self, key_codes, power=1, duration=0.1, wait=True):
558
+ """Simulates multiple keypress action in your application.
559
+
560
+ key_codes : The key codes of the keys simulated to be pressed.
561
+
562
+ power : A value between [-1,1] used for joysticks to indicate how hard the button was pressed. Default value is ``1``.
563
+
564
+ duration : The time measured in seconds from the key press to the key release. Default value is ``0.1``
565
+
566
+ wait : If set wait for command to finish. Default value is ``True``.
567
+
568
+ Example:
569
+
570
+ Press Keys Mouse0 and Mouse1 for 1 second.
571
+
572
+ | ${keys} | = | Create List | Mouse0 | Mouse1
573
+
574
+ | Press Keys | ${keys} | duration=1
575
+ """
576
+ list = []
577
+ for key in key_codes:
578
+ try:
579
+ list.append(getattr(AltKeyCode, key))
580
+ except AttributeError:
581
+ raise ValueError(
582
+ "Invalid kay code for: {code}".format(code=key))
583
+ self._driver.press_keys(list, power=power,
584
+ duration=duration, wait=wait)
585
+
586
+ def scroll(self, speed_vertical=1, duration=0.1, wait=True, speed_horizontal=1):
587
+ """Simulate scroll mouse action in your application.
588
+
589
+ speed_vertical : Set how fast to scroll. Positive values will scroll up and negative values will scroll down. Default value is ``1``
590
+
591
+ duration : The duration of the scroll in seconds. Default value is ``0.1``.
592
+
593
+ wait : If set wait for command to finish. Default value is ``True``.
594
+
595
+ speed_horizontal : Set how fast to scroll right or left. Default value is ``1``
596
+
597
+ Example:
598
+
599
+ Scroll down for 1 second
600
+
601
+ | Scroll | speed_vertical=-1 | duration=1
602
+ """
603
+ self._driver.scroll(speed_vertical=speed_vertical, duration=duration,
604
+ wait=wait, speed_horizontal=speed_horizontal)
605
+
606
+ def swipe(self, start, end, duration=0.1, wait=True):
607
+ """Simulates a swipe action between two points.
608
+
609
+ start: Coordinates of the screen where the swipe begins.
610
+
611
+ end : Coordinates of the screen where the swipe ends.
612
+
613
+ duration : The time measured in seconds to move the mouse from start to end location. Default value is ``0.1``.
614
+
615
+ wait : If set wait for command to finish. Default value is ``True``.
616
+
617
+ Example:
618
+
619
+ Swipe for 1 second without waiting for command to finish.
620
+
621
+ | ${start_coordinates}= | Create List | 10 | 10
622
+
623
+ | ${end_coordinates}}= | Create List | 30 | 30
624
+
625
+ | Swipe | ${start_coordinates} | ${end_coordinates} | duration=1 | wait=${False}
626
+ """
627
+ self._driver.swipe(start, end, duration=duration, wait=wait)
628
+
629
+ def multipoint_swipe(self, positions, duration=0.1, wait=True):
630
+ """Simulates a multipoint swipe action.
631
+
632
+ positions : A list of positions on the screen where the swipe be made.
633
+
634
+ duration : The time measured in seconds to swipe from first position to the last position. Default value is ``0.1``.
635
+
636
+ wait : If set wait for command to finish. Default value is ``True``.
637
+
638
+ Example:
639
+
640
+ Swipe for 1 second without waiting for command to finish.
641
+
642
+ | ${position1}= | Create List | 10 | 10
643
+
644
+ | ${position2}= | Create List | 20 | 20
645
+
646
+ | ${position3}= | Create List | 30 | 30
647
+
648
+ | ${positions}= | Create List | ${position1} | ${position2} | ${position3}
649
+
650
+ | Multipoint Swipe| ${positions} | duration=1 | wait=${False}
651
+ """
652
+ self._driver.multipoint_swipe(positions, duration=duration, wait=wait)
653
+
654
+ def begin_touch(self, coordinates):
655
+ """Simulates starting of a touch on the screen.
656
+
657
+ coordinates : The screen coordinates.
658
+
659
+ Example:
660
+
661
+ Begin Touch at coodinates [10, 10]
662
+
663
+ | ${coordinates}= | Create List | 10 | 10
664
+
665
+ | Begin Touch | ${coordinates}
666
+ """
667
+ return self._driver.begin_touch(coordinates)
668
+
669
+ def move_touch(self, finger_id, coordinates):
670
+ """Simulates a touch movement on the screen. Move the touch created with ``begin_touch`` from the previous
671
+ position to the position given as parameters.
672
+
673
+ finger_id : The value returned by ``begin_touch``.
674
+
675
+ coordinates : Screen coordinates where the touch will be moved.
676
+
677
+ Example:
678
+
679
+ Move Touch at coodinates [20, 20]
680
+
681
+ ${initila_coordinates}= | Create List | 10 | 10
682
+
683
+ ${finger_id}= | Begin Touch | ${initila_coordinates}
684
+
685
+ | ${coordinates}= | Create List | 20 | 20
686
+
687
+ | Move Touch | ${finger_id} | ${coordinates}
688
+ """
689
+ self._driver.move_touch(finger_id, coordinates)
690
+
691
+ def end_touch(self, finger_id):
692
+ """Simulates ending of a touch on the screen. This command will destroy the touch making it no longer usable to
693
+ other movements.
694
+
695
+ finger_id : The value returned by ``begin_touch``.
696
+
697
+ Example:
698
+
699
+ Move Touch from [10, 10] to [20, 20]
700
+
701
+ ${initila_coordinates}= | Create List | 10 | 10
702
+
703
+ ${finger_id}= | Begin Touch | ${initila_coordinates}
704
+
705
+ | ${coordinates}= | Create List | 20 | 20
706
+
707
+ | Move Touch | ${finger_id} | ${coordinates}
708
+
709
+ | End Touch | ${finger_id}
710
+ """
711
+ self._driver.end_touch(finger_id)
712
+
713
+ def click(self, coordinates, count=1, interval=0.1, wait=True):
714
+ """Click at screen coordinates.
715
+
716
+ coordinates : The screen coordinates.
717
+
718
+ count : Number of clicks. Default value is ``1``.
719
+
720
+ interval : The interval between clicks in seconds. Default value is ``0.1``.
721
+
722
+ wait : If set to ``True`` Wait for command to finish. Default value is ``True``.
723
+
724
+ Example:
725
+
726
+ Click at coodinates [30, 30] for 3 times.
727
+
728
+ | ${coordinates}= | Create List | 30 | 30
729
+
730
+ | Click | ${coordinates} | count=3
731
+ """
732
+ self._driver.click(coordinates, count=count,
733
+ interval=interval, wait=wait)
734
+
735
+ def tap(self, coordinates, count=1, interval=0.1, wait=True):
736
+ """Tap at screen coordinates.
737
+
738
+ coordinates : The screen coordinates.
739
+
740
+ count : Number of taps. Default value is ``1``.
741
+
742
+ interval : The interval between taps in seconds. Default value is ``0.1``.
743
+
744
+ wait : If set to ``True`` Wait for command to finish. Default value is ``True``.
745
+
746
+ Example:
747
+
748
+ Tap at coodinates [30, 30] for 3 times.
749
+
750
+ | ${coordinates}= | Create List | 30 | 30
751
+
752
+ | Tap | ${coordinates} | count=3
753
+ """
754
+ self._driver.tap(coordinates, count=count,
755
+ interval=interval, wait=wait)
756
+
757
+ def tilt(self, acceleration, duration=0.1, wait=True):
758
+ """Simulates device rotation action in your application.
759
+
760
+ acceleration : The linear acceleration of a device.
761
+
762
+ duration : How long the rotation will take in seconds. Default value is ``0.1``.
763
+
764
+ wait : If set wait for command to finish. Default value is ``True``.
765
+
766
+ Example:
767
+
768
+ Tilt with acceleration [1, 1, 1] for 1 second.
769
+
770
+ | ${acceleration}= | Create List | 1 | 1 | 1
771
+
772
+ | Tilt | ${acceleration} | duration=1
773
+ """
774
+ self._driver.tilt(acceleration, duration=duration, wait=wait)
775
+
776
+ def reset_input(self):
777
+ """Clear all active input actions simulated by AltTester.
778
+
779
+ Example:
780
+
781
+ | Reset Input |
782
+ """
783
+ self._driver.reset_input()
784
+
785
+ def get_png_screenshot(self, path):
786
+ """Creates a screenshot of the current scene in png format at the given path.
787
+
788
+ path : The path where the image will be created.
789
+
790
+ Example:
791
+
792
+ | Get Png Screenshot | C:\TestPNG
793
+ """
794
+ self._driver.get_png_screenshot(path)
795
+
796
+ def get_player_pref_key(self, key_name, key_type):
797
+ """Returns the value for a given key from PlayerPrefs.
798
+
799
+ key_name : The name of the key to be retrived.
800
+
801
+ key_type : The type of the key. One of the following: Int, String, Float.
802
+
803
+ Example:
804
+
805
+ | Get Player Pref Key | test | String
806
+ """
807
+ try:
808
+ return self._driver.get_player_pref_key(key_name, getattr(PlayerPrefKeyType, key_type))
809
+ except AttributeError:
810
+ raise ValueError(
811
+ "Invalid key type: {type}. Valid ones are: {options}.".format(
812
+ type=key_type, options=", ".join(value.name for value in PlayerPrefKeyType)))
813
+
814
+ def set_player_pref_key(self, key_name, value, key_type):
815
+ """Sets the value for a given key in PlayerPrefs.
816
+
817
+ key_name : The name of the key to be set.
818
+
819
+ value : The new value of be set.
820
+
821
+ key_type : The type of the key.One of the following: Int, String, Float.
822
+
823
+ Example:
824
+
825
+ | Set Player Pref Key | test | test | String
826
+ """
827
+ try:
828
+ self._driver.set_player_pref_key(
829
+ key_name, value, getattr(PlayerPrefKeyType, key_type))
830
+ except AttributeError:
831
+ raise ValueError("Invalid key type: {type}. Valid ones are: {options}.".format(
832
+ type=key_type, options=", ".join(value.name for value in PlayerPrefKeyType)))
833
+
834
+ def delete_player_pref_key(self, key_name):
835
+ """Removes a key and its corresponding value from PlayerPrefs.
836
+
837
+ key_name : The name of the key to be deleted.
838
+
839
+ Example:
840
+
841
+ | Delete Player Pref Key | test
842
+ """
843
+ self._driver.delete_player_pref_key(key_name)
844
+
845
+ def delete_player_pref(self):
846
+ """Removes all keys and values from PlayerPref.
847
+
848
+ Example:
849
+
850
+ | Delete Player Pref |
851
+ """
852
+ self._driver.delete_player_pref()
853
+
854
+ def get_current_scene(self):
855
+ """Returns the name of the current scene.
856
+
857
+ Example:
858
+
859
+ | ${scene} = | Get Current Scene |
860
+ """
861
+ return self._driver.get_current_scene()
862
+
863
+ def load_scene(self, scene_name, load_single=True):
864
+ """Loads a scene.
865
+
866
+ scene_name : The name of the scene to be loaded.
867
+
868
+ load_single : Sets the loading mode. If set to ``False`` the scene will be loaded additive, together with the current loaded scenes. Default value is ``True``.
869
+
870
+ Example:
871
+
872
+ Load scene1
873
+
874
+ | Load Scene | scene1
875
+ """
876
+ self._driver.load_scene(scene_name, load_single=load_single)
877
+
878
+ def unload_scene(self, scene_name):
879
+ """Unloads a scene.
880
+
881
+ scene_name : The name of the scene to be unloaded.
882
+
883
+ Example:
884
+
885
+ Unload scene1
886
+
887
+ | Unload Scene | scene1
888
+ """
889
+ self._driver.unload_scene(scene_name)
890
+
891
+ def get_all_loaded_scenes(self):
892
+ """Returns all the scenes that have been loaded.
893
+
894
+ Example:
895
+
896
+ | ${scenes}= | Get All Loaded Scenes
897
+ """
898
+ return self._driver.get_all_loaded_scenes()
899
+
900
+ def wait_for_current_scene_to_be(self, scene_name, timeout=30, interval=1):
901
+ """Waits for the scene to be loaded for a specified amount of time.
902
+
903
+ scene_name : The name of the scene to wait for.
904
+
905
+ timeout : The time measured in seconds to wait for the specified scene. Default value is ``30``.
906
+
907
+ interval : How often to check that the scene was loaded in the given timeout. Default value is ``1``.
908
+
909
+ Example:
910
+
911
+ Wait for scene1 for 10 seconds.
912
+
913
+ | Wait For Current Scene To Be | scene1 | timeout=10
914
+ """
915
+ self._driver.wait_for_current_scene_to_be(
916
+ scene_name, timeout=timeout, interval=interval)
917
+
918
+ def get_application_screensize(self):
919
+ """Returns the value of the application screen size.
920
+
921
+ Example:
922
+
923
+ | ${app_scene_size}= | Get Application Screensize
924
+ """
925
+ return self._driver.get_application_screensize()
926
+
927
+ def get_time_scale(self):
928
+ """Returns the value of the time scale.
929
+
930
+ Example:
931
+
932
+ | ${time_scale}= | Get Time Scale
933
+ """
934
+ return self._driver.get_time_scale()
935
+
936
+ def set_time_scale(self, time_scale):
937
+ """Sets the value of the time scale.
938
+
939
+ time_scale: The value of the time scale.
940
+
941
+ Example:
942
+
943
+ | Set Time Scale | 1
944
+ """
945
+ self._driver.set_time_scale(time_scale)
946
+
947
+ def call_static_method(self, type_name, method_name, assembly, parameters=None, type_of_parameters=None):
948
+ """Invoke a static method from your application.
949
+
950
+ type_name : The name of the script. If the script has a namespace the format should look like
951
+ this: ``"namespace.typeName"``.
952
+
953
+ method_name : The name of the public method that we want to call. If the method is inside a
954
+ static property/field to be able to call that method, methodName need to be the following format
955
+ ``"propertyName.MethodName"``.
956
+
957
+ assembly : The name of the assembly containing the script.
958
+
959
+ parameters : Default value is ``None``.
960
+
961
+ type_of_parameters : Default value is ``None``.
962
+
963
+ Example:
964
+
965
+ Call method GetInt
966
+
967
+ | ${list_to_get}= | Create List | Test | ${2}
968
+
969
+ | ${int_value}= | Call Static Method | UnityEngine.PlayerPrefs | GetInt | UnityEngine.CoreModule | parameters=${list_to_get}
970
+ """
971
+ return self._driver.call_static_method(type_name, method_name, assembly, parameters=parameters, type_of_parameters=type_of_parameters)
972
+
973
+ def get_static_property(self, component_name, property_name, assembly, max_depth=2):
974
+ """Returns the value of the static field or property given as parameter.
975
+
976
+ component_name :The name of the component containing the field or property to be retrieved.
977
+
978
+ property_name : The name of the field or property to be retrieved.
979
+
980
+ assembly : The name of the assembly containing the component mentioned above.
981
+
982
+ max_depth : The value determining how deep to go in the hierarchy of objects to find the field or property. Default value is ``2``.
983
+
984
+ Example:
985
+
986
+ Get Static Property for width resolution.
987
+
988
+ | ${width_resolution}= | Get Static Property | UnityEngine.Screen | currentResolution.width | UnityEngine.CoreModule
989
+ """
990
+ return self._driver.get_static_property(component_name, property_name, assembly, max_depth=max_depth)
991
+
992
+ def set_static_property(self, component_name, property_name, assembly, updated_value):
993
+ """Set the value of the static field or property given as parameter.
994
+
995
+ component_name : The name of the component containing the field or property to be retrieved.
996
+
997
+ property_name : The name of the field or property to be retrieved.
998
+
999
+ assembly : The name of the assembly containing the component mentioned above.
1000
+
1001
+ updated_value : The value of the field or property to be updated.
1002
+
1003
+ Example:
1004
+
1005
+ Set Static Property for width resolution.
1006
+
1007
+ | Set Static Property | UnityEngine.Screen | currentResolution.width | UnityEngine.CoreModule | 1920
1008
+ """
1009
+ self._driver.set_static_property(
1010
+ component_name, property_name, assembly, updated_value)
1011
+
1012
+ def set_server_logging(self, logger, log_level):
1013
+ """Sets the level of logging on AltTester.
1014
+
1015
+ logger : One of the following: File, Unity, Console. The type of logger.
1016
+
1017
+ log_lever : One of the following: Trace, Debug, Info, Warn, Error, Fatal, Off. The logging level.
1018
+
1019
+ Example:
1020
+
1021
+ Set logging level Off for Files.
1022
+
1023
+ | Set Server Logging | File | Off
1024
+ """
1025
+ self._driver.set_server_logging(self.get_logger(
1026
+ logger), self.get_log_level(log_level))
1027
+
1028
+ def call_component_method(self, alt_object: AltObject, component_name, method_name, assembly, parameters=None, type_of_parameters=None):
1029
+ """Invokes a method from an existing component of the object.
1030
+
1031
+ alt_object : The AltObject for which we want to call the method.
1032
+ component_name : The name of the script. If the script has a namespace the format should look
1033
+ like this: ``"namespace.typeName"``.
1034
+
1035
+ method_name : The name of the public method that we want to call. If the method is inside a
1036
+ static property/field to be able to call that method, methodName need to be the following format
1037
+ ``"propertyName.MethodName"``.
1038
+
1039
+ assembly : The name of the assembly containing the script.
1040
+
1041
+ parameters : Default value is ``None``.
1042
+
1043
+ type_of_parameters : Default value is ``None``.
1044
+
1045
+ Example:
1046
+
1047
+ Call method get_text for PlayButton
1048
+
1049
+ | ${object}= | Find Object | PATH | //PlayButton
1050
+
1051
+ | ${text} = | Call Component Method | ${object} | UnityEngine.UI.Text | get_text | UnityEngine.UI
1052
+ """
1053
+ return alt_object.call_component_method(component_name, method_name, assembly, parameters=parameters, type_of_parameters=type_of_parameters)
1054
+
1055
+ def update_object(self, alt_object: AltObject):
1056
+ """Update the altObject.
1057
+ alt_object : The AltObject for which we want to update.
1058
+
1059
+ Example:
1060
+
1061
+ Update Capsule object.
1062
+
1063
+ | ${object}= | Find Object | NAME | Capsule
1064
+
1065
+ | Update Object | ${object}
1066
+ """
1067
+ alt_object.update_object()
1068
+
1069
+ def get_screen_position(self, alt_object: AltObject):
1070
+ """Returns the screen position.
1071
+ alt_object : The AltObject for which we want to get screen positions.
1072
+
1073
+ Example:
1074
+
1075
+ Get Screen Position for Capsule object.
1076
+
1077
+ | ${object}= | Find Object | NAME | Capsule
1078
+
1079
+ | ${positions} = | Get Screen Position | ${object}
1080
+ """
1081
+ return alt_object.get_screen_position()
1082
+
1083
+ def get_world_position(self, alt_object: AltObject):
1084
+ """Returns the world position.
1085
+ alt_object : The AltObject for which we want to get world positions.
1086
+
1087
+ Example:
1088
+
1089
+ Get World Position for Capsule object.
1090
+
1091
+ | ${object}= | Find Object | NAME | Capsule
1092
+
1093
+ | ${positions} = | Get World Position | ${object}
1094
+ """
1095
+ return alt_object.get_world_position()
1096
+
1097
+ def get_parent(self, alt_object: AltObject):
1098
+ """Returns the parent object.
1099
+ alt_object : The AltObject for which we want to get the parent.
1100
+
1101
+ Example:
1102
+
1103
+ Get Parent for Capsule object.
1104
+
1105
+ | ${object}= | Find Object | NAME | Capsule
1106
+
1107
+ | ${parent} = | Get Parent | ${object}
1108
+ """
1109
+ return alt_object.get_parent()
1110
+
1111
+ def get_all_components(self, alt_object: AltObject):
1112
+ """Returns all components.
1113
+ alt_object : The AltObject for which we want to get components.
1114
+
1115
+ Example:
1116
+
1117
+ Get All Components for Capsule object.
1118
+
1119
+ | ${object}= | Find Object | NAME | Capsule
1120
+
1121
+ | ${components} = | Get All Components | ${object}
1122
+ """
1123
+ return alt_object.get_all_components()
1124
+
1125
+ def wait_for_component_property(self, alt_object: AltObject, component_name, property_name,
1126
+ property_value, assembly, timeout=20, interval=0.5):
1127
+ """Wait until a property has a specific value and returns the value of the given component property.
1128
+
1129
+ alt_object : The AltObject for which we want to wait for property.
1130
+
1131
+ component_name : The name of the component. If the component has a namespace the format should
1132
+ look like this: ``"namespace.componentName"``.
1133
+
1134
+ property_name : The name of the property of which value you want. If the property is an array
1135
+ you can specify which element of the array to return by doing ``property[index]``, or if you want a
1136
+ property inside of another property you can get by doing ``property.subProperty``.
1137
+
1138
+ property_value : The value of the component expected.
1139
+
1140
+ assembly : The name of the assembly containing the component.
1141
+
1142
+ timeout : The number of seconds that it will wait for property. Default value is 20 seconds.
1143
+
1144
+ interval : The number of seconds after which it will try to find the object again. The interval should be smaller than timeout. Default value is 0.5.
1145
+
1146
+ Example:
1147
+
1148
+ Wait for property TestBool from Capsule
1149
+
1150
+ | ${object}= | Find Object | NAME | Capsule
1151
+
1152
+ | ${result} = | Wait For Component Property | ${object} | AltExampleScriptCapsule | TestBool | ${True} | Assembly-CSharp
1153
+ """
1154
+ return alt_object.wait_for_component_property(component_name, property_name, property_value, assembly, timeout=timeout, interval=interval)
1155
+
1156
+ def get_component_property(self, alt_object: AltObject, component_name, property_name, assembly, max_depth=2):
1157
+ """Returns the value of the given component property.
1158
+
1159
+ alt_object : The AltObject for which we want to get for property.
1160
+
1161
+ component_name : The name of the component. If the component has a namespace the format should
1162
+ look like this: ``"namespace.componentName"``.
1163
+
1164
+ property_name : The name of the property of which value you want. If the property is an array
1165
+ you can specify which element of the array to return by doing ``property[index]``, or if you want a
1166
+ property inside of another property you can get by doing ``property.subProperty``.
1167
+
1168
+ assembly : The name of the assembly containing the component.
1169
+
1170
+ maxDepth : Set how deep to serialize the property. Default value is ``2``.
1171
+
1172
+ Example:
1173
+
1174
+ Get property arrayOfInts for Capsule .
1175
+
1176
+ | ${object}= | Find Object | NAME | Capsule
1177
+
1178
+ | ${property} = | Get Component Property| ${object} | Capsule | arrayOfInts | ${True} | Assembly-CSharp
1179
+
1180
+ """
1181
+ return alt_object.get_component_property(component_name, property_name, assembly, max_depth=max_depth)
1182
+
1183
+ def set_component_property(self, alt_object: AltObject, component_name, property_name, assembly, value):
1184
+ """Sets a value for a given component property.
1185
+
1186
+ alt_object : The AltObject for which we want to set for property.
1187
+
1188
+ component_name : The name of the component. If the component has a namespace the format should
1189
+ look like this: ``"namespace.componentName"``.
1190
+
1191
+ property_name : The name of the property of which value you want to set.
1192
+
1193
+ assembly : The name of the assembly containing the component.
1194
+
1195
+ value : The value to be set for the chosen component's property.
1196
+
1197
+ Example:
1198
+
1199
+ Set property stringToSetFromTests for Capsule .
1200
+
1201
+ | ${object}= | Find Object | NAME | Capsule
1202
+
1203
+ | Set Component Property| ${object} | Capsule | stringToSetFromTests | Assembly-CSharp | 2
1204
+ """
1205
+ alt_object.set_component_property(
1206
+ component_name, property_name, assembly, value)
1207
+
1208
+ def get_text(self, alt_object: AltObject):
1209
+ """Returns text value from alt_object.
1210
+
1211
+ alt_object : The AltObject for which we want to get text.
1212
+
1213
+ Example:
1214
+
1215
+ Get text for CapsuleInfo.
1216
+
1217
+ | ${object}= | Find Object | NAME | CapsuleInfo
1218
+
1219
+ | ${text}= | Get Text | ${object}
1220
+ """
1221
+ return alt_object.get_text()
1222
+
1223
+ def get_object_name(self, alt_object: AltObject):
1224
+ """Returns name for alt_object.
1225
+
1226
+ alt_object : The AltObject for which we want to get name.
1227
+
1228
+ Example:
1229
+
1230
+ Get Object Name for CapsuleInfo.
1231
+
1232
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1233
+
1234
+ | ${name}= | Get Object Name | ${object}
1235
+ """
1236
+ return alt_object.name
1237
+
1238
+ def get_object_id(self, alt_object: AltObject):
1239
+ """Returns id for alt_object.
1240
+
1241
+ alt_object : The AltObject for which we want to get id.
1242
+
1243
+ Example:
1244
+
1245
+ Get Object Id for CapsuleInfo.
1246
+
1247
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1248
+
1249
+ | ${id}= | Get Object Id | ${object}
1250
+ """
1251
+ return alt_object.id
1252
+
1253
+ def get_object_x(self, alt_object: AltObject):
1254
+ """Returns x for alt_object.
1255
+
1256
+ alt_object : The AltObject for which we want to get x.
1257
+
1258
+ Example:
1259
+
1260
+ Get Object X for CapsuleInfo.
1261
+
1262
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1263
+
1264
+ | ${x_param}= | Get Object X | ${object}
1265
+ """
1266
+ return alt_object.x
1267
+
1268
+ def get_object_y(self, alt_object: AltObject):
1269
+ """Returns y for alt_object.
1270
+
1271
+ alt_object : The AltObject for which we want to get y.
1272
+
1273
+ Example:
1274
+
1275
+ Get Object Y for CapsuleInfo.
1276
+
1277
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1278
+
1279
+ | ${y_param}= | Get Object Y | ${object}
1280
+ """
1281
+ return alt_object.y
1282
+
1283
+ def get_object_z(self, alt_object: AltObject):
1284
+ """Returns z for alt_object.
1285
+
1286
+ alt_object : The AltObject for which we want to get z.
1287
+
1288
+ Example:
1289
+
1290
+ Get Object Z for CapsuleInfo.
1291
+
1292
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1293
+
1294
+ | ${z_param}= | Get Object Z | ${object}
1295
+ """
1296
+ return alt_object.z
1297
+
1298
+ def get_object_mobileY(self, alt_object: AltObject):
1299
+ """Returns mobileY for alt_object.
1300
+
1301
+ alt_object : The AltObject for which we want to get mobileY.
1302
+
1303
+ Example:
1304
+
1305
+ Get Object MobileY for CapsuleInfo.
1306
+
1307
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1308
+
1309
+ | ${mobileY}= | Get Object MobileY | ${object}
1310
+ """
1311
+ return alt_object.mobileY
1312
+
1313
+ def get_object_type(self, alt_object: AltObject):
1314
+ """Returns type for alt_object.
1315
+
1316
+ alt_object : The AltObject for which we want to get type.
1317
+
1318
+ Example:
1319
+
1320
+ Get Object Type for CapsuleInfo.
1321
+
1322
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1323
+
1324
+ | ${type}= | Get Object Type | ${object}
1325
+ """
1326
+ return alt_object.type
1327
+
1328
+ def get_object_enabled(self, alt_object: AltObject):
1329
+ """Returns enabled for alt_object.
1330
+
1331
+ alt_object : The AltObject for which we want to get enabled.
1332
+
1333
+ Example:
1334
+
1335
+ Get Object Enabled for CapsuleInfo.
1336
+
1337
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1338
+
1339
+ | ${enabled}= | Get Object Enabled | ${object}
1340
+ """
1341
+ return alt_object.enabled
1342
+
1343
+ def get_object_worldX(self, alt_object: AltObject):
1344
+ """Returns worldX for alt_object.
1345
+
1346
+ alt_object : The AltObject for which we want to get worldX.
1347
+
1348
+ Example:
1349
+
1350
+ Get Object WorldX for CapsuleInfo.
1351
+
1352
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1353
+
1354
+ | ${worldX}= | Get Object WorldX | ${object}
1355
+ """
1356
+ return alt_object.worldX
1357
+
1358
+ def get_object_worldY(self, alt_object: AltObject):
1359
+ """Returns worldY for alt_object.
1360
+
1361
+ alt_object : The AltObject for which we want to get worldY.
1362
+
1363
+ Example:
1364
+
1365
+ Get Object WorldY for CapsuleInfo.
1366
+
1367
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1368
+
1369
+ | ${worldY}= | Get Object WorldY | ${object}
1370
+ """
1371
+ return alt_object.worldY
1372
+
1373
+ def get_object_worldZ(self, alt_object: AltObject):
1374
+ """Returns worldZ for alt_object.
1375
+
1376
+ alt_object : The AltObject for which we want to get worldZ.
1377
+
1378
+ Example:
1379
+
1380
+ Get Object WorldZ for CapsuleInfo.
1381
+
1382
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1383
+
1384
+ | ${worldZ}= | Get Object WorldZ | ${object}
1385
+ """
1386
+ return alt_object.worldZ
1387
+
1388
+ def get_object_idCamera(self, alt_object: AltObject):
1389
+ """Returns idCamera for alt_object.
1390
+
1391
+ alt_object : The AltObject for which we want to get idCamera.
1392
+
1393
+ Example:
1394
+
1395
+ Get Object IdCamera for CapsuleInfo.
1396
+
1397
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1398
+
1399
+ | ${idCamera}= | Get Object IdCamera | ${object}
1400
+ """
1401
+ return alt_object.idCamera
1402
+
1403
+ def get_object_transformParentId(self, alt_object: AltObject):
1404
+ """Returns transformParentId for alt_object.
1405
+
1406
+ alt_object : The AltObject for which we want to get transformParentId.
1407
+
1408
+ Example:
1409
+
1410
+ Get Object TransformParentId for CapsuleInfo.
1411
+
1412
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1413
+
1414
+ | ${transformParentId}= | Get Object TransformParentId | ${object}
1415
+ """
1416
+ return alt_object.transformParentId
1417
+
1418
+ def get_object_transformId(self, alt_object: AltObject):
1419
+ """Returns transformId for alt_object.
1420
+
1421
+ alt_object : The AltObject for which we want to get transformId.
1422
+
1423
+ Example:
1424
+
1425
+ Get Object TransformId for CapsuleInfo.
1426
+
1427
+ | ${object}= | Find Object | PATH | //CapsuleInfo
1428
+
1429
+ | ${transformId}= | Get Object TransformId | ${object}
1430
+ """
1431
+ return alt_object.transformId
1432
+
1433
+ def set_text(self, alt_object: AltObject, text, submit=False):
1434
+ """Set text value for alt_object.
1435
+
1436
+ alt_object : The AltObject for which we want to set text.
1437
+
1438
+ text : The text to be set.
1439
+
1440
+ submit : If set will trigger a submit event. Default value is False.
1441
+
1442
+ Example:
1443
+
1444
+ Set text InputFieldTest for CapsuleInfo.
1445
+
1446
+ | ${object}= | Find Object | NAME | CapsuleInfo
1447
+
1448
+ | Set Text | ${object} | InputFieldTest
1449
+ """
1450
+ return alt_object.set_text(text, submit=submit)
1451
+
1452
+ def tap_object(self, alt_object: AltObject, count=1, interval=0.1, wait=True):
1453
+ """Tap the alt_object.
1454
+
1455
+ alt_object : The AltObject which we want to tap.
1456
+
1457
+ count : Number of taps. Default value is ``1``.
1458
+
1459
+ interval : Interval between taps in seconds. Default value is ``0.1``.
1460
+
1461
+ wait : Wait for command to finish. Default value is ``True``.
1462
+
1463
+ Example:
1464
+
1465
+ Double tap on Capsule.
1466
+
1467
+ | ${object}= | Find Object | NAME | Capsule
1468
+
1469
+ | Tap Object | ${object} | count=2
1470
+ """
1471
+ alt_object.tap(count=count, interval=interval, wait=wait)
1472
+
1473
+ def click_object(self, alt_object: AltObject, count=1, interval=0.1, wait=True):
1474
+ """Click the alt_object.
1475
+
1476
+ alt_object : The AltObject which we want to click.
1477
+
1478
+ count : Number of clicks. Default value is ``1``.
1479
+
1480
+ interval : Interval between clicks in seconds. Default value is ``0.1``.
1481
+
1482
+ wait : Wait for command to finish. Default value is ``True``.
1483
+
1484
+ Example:
1485
+
1486
+ Double click on Capsule.
1487
+
1488
+ | ${object}= | Find Object | NAME | Capsule
1489
+
1490
+ | Click Object | ${object} | count=2
1491
+ """
1492
+ alt_object.click(count=count, interval=interval, wait=wait)
1493
+
1494
+ def pointer_down(self, alt_object: AltObject):
1495
+ """Simulates pointer down action on alt_object.
1496
+
1497
+ alt_object : The AltObject which we want to pointer down.
1498
+
1499
+ Example:
1500
+
1501
+ Pointer Down on Panel.
1502
+
1503
+ | ${object}= | Find Object | NAME | Panel
1504
+
1505
+ | Pointer Down | ${object} |
1506
+ """
1507
+ return alt_object.pointer_down()
1508
+
1509
+ def pointer_up(self, alt_object: AltObject):
1510
+ """Simulates pointer up action on alt_object.
1511
+
1512
+ alt_object : The AltObject which we want to pointer up.
1513
+
1514
+ Example:
1515
+
1516
+ Pointer Up on Panel.
1517
+
1518
+ | ${object}= | Find Object | NAME | Panel
1519
+
1520
+ | Pointer Up | ${object} |
1521
+ """
1522
+ return alt_object.pointer_up()
1523
+
1524
+ def pointer_enter(self, alt_object: AltObject):
1525
+ """Simulates pointer enter action on alt_object.
1526
+
1527
+ alt_object : The AltObject which we want to pointer enter.
1528
+
1529
+ Example:
1530
+
1531
+ Pointer Enter on Drop Image.
1532
+
1533
+ | ${object}= | Find Object | NAME | Drop Image
1534
+
1535
+ | Pointer Enter | ${object} |
1536
+ """
1537
+ return alt_object.pointer_enter()
1538
+
1539
+ def pointer_exit(self, alt_object: AltObject):
1540
+ """Simulates pointer exit action on alt_object.
1541
+
1542
+ alt_object : The AltObject which we want to pointer exit.
1543
+
1544
+ Example:
1545
+
1546
+ Pointer Exit on Drop Image.
1547
+
1548
+ | ${object}= | Find Object | NAME | Drop Image
1549
+
1550
+ | Pointer Exit | ${object} |
1551
+ """
1552
+ return alt_object.pointer_exit()
1553
+
1554
+ def update_object(self, alt_object: AltObject):
1555
+ """Returns alt_object with new values.
1556
+
1557
+ alt_object : The AltObject which we want to update.
1558
+
1559
+ Example:
1560
+
1561
+ Update Player1.
1562
+
1563
+ | ${object}= | Find Object | NAME | Player1
1564
+
1565
+ | Key Down | A
1566
+
1567
+ | ${new_object}= | Update Object | ${object}
1568
+ """
1569
+ return alt_object.update_object()
1570
+
1571
+ def get_parent(self, alt_object: AltObject):
1572
+ """Returns the parent alt_object.
1573
+
1574
+ alt_object : The AltObject for which we want to find the parent.
1575
+
1576
+ Example:
1577
+
1578
+ Get CapsuleInfo parent.
1579
+
1580
+ | ${object}= | Find Object | NAME | CapsuleInfo
1581
+
1582
+ | ${parent}= | Get Parent | ${object}
1583
+ """
1584
+ return alt_object.get_parent()
1585
+
1586
+ def get_screen_position(self, alt_object: AltObject):
1587
+ """Returns the screen position for alt_object.
1588
+
1589
+ alt_object : The AltObject for which we want to get screen position.
1590
+
1591
+ Example:
1592
+
1593
+ Get Screen Position for CapsuleInfo
1594
+
1595
+ | ${object}= | Find Object | NAME | CapsuleInfo
1596
+
1597
+ | ${positions}= | Get Screen Position | ${object}
1598
+ """
1599
+ return alt_object.get_screen_position()
1600
+
1601
+ def get_world_position(self, alt_object: AltObject):
1602
+ """Returns the world position for alt_object.
1603
+
1604
+ alt_object : The AltObject for which we want to get world position.
1605
+
1606
+ Example:
1607
+
1608
+ Get World Position for CapsuleInfo
1609
+
1610
+ | ${object}= | Find Object | NAME | CapsuleInfo
1611
+
1612
+ | ${positions}= | Get World Position | ${object}
1613
+ """
1614
+ return alt_object.get_world_position()
1615
+
1616
+ def get_by_enum(self, locator):
1617
+ try:
1618
+ locator = getattr(By, str(locator).upper())
1619
+ return locator
1620
+ except AttributeError:
1621
+ raise ValueError(
1622
+ "Invalid locator strategy: {locator}. Valid ones are: {options}.".format(
1623
+ locator=locator, options=", ".join(value.name for value in By)))
1624
+
1625
+ def get_logger(self, logger):
1626
+ try:
1627
+ logger = getattr(AltLogger, logger)
1628
+ return logger
1629
+ except AttributeError:
1630
+ raise ValueError("Invalid logger type: {logger}. Valid ones are: {options}.".format(
1631
+ logger=logger, options=", ".join(value.name for value in AltLogger)))
1632
+
1633
+ def get_log_level(self, log_level):
1634
+ try:
1635
+ log_level = getattr(AltLogLevel, log_level)
1636
+ return log_level
1637
+ except AttributeError:
1638
+ raise ValueError("Invalid log level type: {log_level}. Valid ones are: {options}.".format(
1639
+ log_level=log_level, options=", ".join(value.name for value in AltLogLevel)))