|
24 | 24 | from appium.webdriver.common.multi_action import MultiAction
|
25 | 25 |
|
26 | 26 | from selenium.webdriver.common.by import By
|
27 |
| -from selenium.webdriver.remote.webelement import WebElement |
28 | 27 | from selenium.webdriver.support.ui import WebDriverWait
|
29 | 28 | from selenium.common.exceptions import TimeoutException, InvalidArgumentException
|
30 | 29 |
|
@@ -968,6 +967,87 @@ def set_location(self, latitude, longitude, altitude):
|
968 | 967 | self.execute(Command.SET_LOCATION, data)
|
969 | 968 | return self
|
970 | 969 |
|
| 970 | + def start_recording_screen(self, **options): |
| 971 | + """ |
| 972 | + Start asynchronous screen recording process. |
| 973 | +
|
| 974 | + :param options: The following options are supported: |
| 975 | + - remotePath: The remotePath upload option is the path to the remote location, |
| 976 | + where the resulting video from the previous screen recording should be uploaded. |
| 977 | + The following protocols are supported: http/https (multipart), ftp. |
| 978 | + Missing value (the default setting) means the content of the resulting |
| 979 | + file should be encoded as Base64 and passed as the endpoint response value, but |
| 980 | + an exception will be thrown if the generated media file is too big to |
| 981 | + fit into the available process memory. |
| 982 | + This option only has an effect if there is/was an active screen recording session |
| 983 | + and forced restart is not enabled (the default setting). |
| 984 | + - user: The name of the user for the remote authentication. |
| 985 | + Only has an effect if both `remotePath` and `password` are set. |
| 986 | + - password: The password for the remote authentication. |
| 987 | + Only has an effect if both `remotePath` and `user` are set. |
| 988 | + - method: The HTTP method name ('PUT'/'POST'). PUT method is used by default. |
| 989 | + Only has an effect if `remotePath` is set. |
| 990 | + - timeLimit: The actual time limit of the recorded video in seconds. |
| 991 | + The default value for both iOS and Android is 180 seconds (3 minutes). |
| 992 | + The maximum value for Android is 3 minutes. |
| 993 | + The maximum value for iOS is 10 minutes. |
| 994 | + - forcedRestart: Whether to ignore the result of previous capture and start a new recording |
| 995 | + immediately (`True` value). By default (`False`) the endpoint will try to catch and return the result of |
| 996 | + the previous capture if it's still available. |
| 997 | +
|
| 998 | + iOS Specific: |
| 999 | + - videoQuality: The video encoding quality: 'low', 'medium', 'high', 'photo'. Defaults to 'medium'. |
| 1000 | + Only works for real devices. |
| 1001 | + - videoType: The format of the screen capture to be recorded. |
| 1002 | + Available formats: 'h264', 'mp4' or 'fmp4'. Default is 'mp4'. |
| 1003 | + Only works for Simulator. |
| 1004 | +
|
| 1005 | + Android Specific: |
| 1006 | + - videoSize: The video size of the generated media file. The format is WIDTHxHEIGHT. |
| 1007 | + The default value is the device's native display resolution (if supported), |
| 1008 | + 1280x720 if not. For best results, use a size supported by your device's |
| 1009 | + Advanced Video Coding (AVC) encoder. |
| 1010 | + - bitRate: The video bit rate for the video, in megabits per second. |
| 1011 | + The default value is 4. You can increase the bit rate to improve video quality, |
| 1012 | + but doing so results in larger movie files. |
| 1013 | +
|
| 1014 | + :return: Base-64 encoded content of the recorded media file or an empty string |
| 1015 | + if the file has been successfully uploaded to a remote location |
| 1016 | + (depends on the actual `remotePath` value). |
| 1017 | + """ |
| 1018 | + if 'password' in options: |
| 1019 | + options['pass'] = options['password'] |
| 1020 | + del options['password'] |
| 1021 | + return self.execute(Command.START_RECORDING_SCREEN, options)['value'] |
| 1022 | + |
| 1023 | + def stop_recording_screen(self, **options): |
| 1024 | + """ |
| 1025 | + Gather the output from the previously started screen recording to a media file. |
| 1026 | +
|
| 1027 | + :param options: The following options are supported: |
| 1028 | + - remotePath: The remotePath upload option is the path to the remote location, |
| 1029 | + where the resulting video should be uploaded. |
| 1030 | + The following protocols are supported: http/https (multipart), ftp. |
| 1031 | + Missing value (the default setting) means the content of the resulting |
| 1032 | + file should be encoded as Base64 and passed as the endpoint response value, but |
| 1033 | + an exception will be thrown if the generated media file is too big to |
| 1034 | + fit into the available process memory. |
| 1035 | + - user: The name of the user for the remote authentication. |
| 1036 | + Only has an effect if both `remotePath` and `password` are set. |
| 1037 | + - password: The password for the remote authentication. |
| 1038 | + Only has an effect if both `remotePath` and `user` are set. |
| 1039 | + - method: The HTTP method name ('PUT'/'POST'). PUT method is used by default. |
| 1040 | + Only has an effect if `remotePath` is set. |
| 1041 | +
|
| 1042 | + :return: Base-64 encoded content of the recorded media file or an empty string |
| 1043 | + if the file has been successfully uploaded to a remote location |
| 1044 | + (depends on the actual `remotePath` value). |
| 1045 | + """ |
| 1046 | + if 'password' in options: |
| 1047 | + options['pass'] = options['password'] |
| 1048 | + del options['password'] |
| 1049 | + return self.execute(Command.STOP_RECORDING_SCREEN, options)['value'] |
| 1050 | + |
971 | 1051 | @property
|
972 | 1052 | def device_time(self):
|
973 | 1053 | """Returns the date and time from the device
|
@@ -1070,3 +1150,7 @@ def _addCommands(self):
|
1070 | 1150 | ('GET', '/session/$sessionId/appium/device/system_time')
|
1071 | 1151 | self.command_executor._commands[Command.CLEAR] = \
|
1072 | 1152 | ('POST', '/session/$sessionId/element/$id/clear')
|
| 1153 | + self.command_executor._commands[Command.START_RECORDING_SCREEN] = \ |
| 1154 | + ('POST', '/session/$sessionId/appium/start_recording_screen') |
| 1155 | + self.command_executor._commands[Command.STOP_RECORDING_SCREEN] = \ |
| 1156 | + ('POST', '/session/$sessionId/appium/stop_recording_screen') |
0 commit comments