|
20 | 20 |
|
21 | 21 | from __future__ import print_function |
22 | 22 |
|
23 | | -__version__ = '21.10.2' |
| 23 | +__version__ = '21.11.0' |
24 | 24 |
|
25 | 25 | import json |
26 | 26 | import os |
@@ -416,12 +416,18 @@ def find_object(self, **kwargs): |
416 | 416 | def find_objects(self, **kwargs): |
417 | 417 | """ |
418 | 418 | Finds objects. |
| 419 | + Invokes GET or POST method depending on the arguments passed. |
419 | 420 |
|
420 | 421 | :see https://github.com/dtmilano/CulebraTester2-public/blob/master/openapi.yaml |
421 | 422 | :param kwargs: |
422 | 423 | :return: |
423 | 424 | """ |
424 | | - return self.uiAutomatorHelper.api_instance.ui_device_find_objects_get(**kwargs) |
| 425 | + if 'body' in kwargs: |
| 426 | + return self.uiAutomatorHelper.api_instance.ui_device_find_objects_post(**kwargs) |
| 427 | + if 'by_selector' in kwargs: |
| 428 | + return self.uiAutomatorHelper.api_instance.ui_device_find_objects_get(**kwargs) |
| 429 | + body = culebratester_client.Selector(**kwargs) |
| 430 | + return self.uiAutomatorHelper.api_instance.ui_device_find_objects_post(body=body) |
425 | 431 |
|
426 | 432 | def press_back(self): |
427 | 433 | """ |
@@ -475,18 +481,30 @@ def swipe(self, **kwargs): |
475 | 481 | body = culebratester_client.SwipeBody(**kwargs) |
476 | 482 | return self.uiAutomatorHelper.api_instance.ui_device_swipe_post(body=body) |
477 | 483 |
|
478 | | - def take_screenshot(self, scale=1.0, quality=90, **kwargs): |
| 484 | + def take_screenshot(self, scale=1.0, quality=90, filename=None, **kwargs): |
479 | 485 | """ |
480 | 486 | Takes screenshot. |
| 487 | + Eventually save it in a file specified by filename. |
481 | 488 |
|
482 | 489 | :see https://github.com/dtmilano/CulebraTester2-public/blob/master/openapi.yaml |
483 | | - :param scale: |
484 | | - :param quality: |
485 | | - :param kwargs: |
486 | | - :return: |
487 | | - """ |
488 | | - return self.uiAutomatorHelper.api_instance.ui_device_screenshot_get(scale=scale, quality=quality, |
489 | | - _preload_content=False, **kwargs) |
| 490 | + :param scale: the scale |
| 491 | + :param quality: the quality |
| 492 | + :param filename: if specified the image will be saved in filename |
| 493 | + :param kwargs: optional arguments |
| 494 | + :return: the response containing the image binary if the filename was not specified |
| 495 | + """ |
| 496 | + if filename: |
| 497 | + img = self.uiAutomatorHelper.api_instance.ui_device_screenshot_get(scale=scale, |
| 498 | + quality=quality, |
| 499 | + _preload_content=False, |
| 500 | + **kwargs).read() |
| 501 | + with open(filename, 'wb') as file: |
| 502 | + file.write(img) |
| 503 | + return |
| 504 | + return self.uiAutomatorHelper.api_instance.ui_device_screenshot_get(scale=scale, |
| 505 | + quality=quality, |
| 506 | + _preload_content=False, |
| 507 | + **kwargs) |
490 | 508 |
|
491 | 509 | def wait(self, search_condition_ref: int, timeout=10000): |
492 | 510 | """ |
|
0 commit comments