@@ -68,18 +68,19 @@ def is_running(id):
68
68
return False
69
69
70
70
@staticmethod
71
- def wait_until_boot (id , timeout = 180 ):
71
+ def wait_until_boot (id , timeout = 180 , check_interval = 3 ):
72
72
"""
73
73
Wait android device/emulator is up and running.
74
74
:param id: Device identifier.
75
75
:param timeout: Timeout until device is ready (in seconds).
76
+ :param check_interval: Sleep specified time before check again.
76
77
:return: True if device is ready before timeout, otherwise - False.
77
78
"""
78
79
booted = False
79
80
start_time = time .time ()
80
81
end_time = start_time + timeout
81
82
while not booted :
82
- time .sleep (2 )
83
+ time .sleep (check_interval )
83
84
booted = Adb .is_running (id = id )
84
85
if (booted is True ) or (time .time () > end_time ):
85
86
break
@@ -144,14 +145,11 @@ def is_text_visible(id, text, case_sensitive=False):
144
145
@staticmethod
145
146
def get_screen (id , file_path ):
146
147
File .clean (path = file_path )
147
- Adb .__run_adb_command (command = 'shell rm /sdcard/screen.png' , id = id )
148
- result = Adb .__run_adb_command (command = 'shell screencap -p /sdcard/screen.png' , id = id )
149
- if result .exit_code == 0 :
150
- time .sleep (1 )
151
- Adb .pull (id = id , source = '/sdcard/screen.png' , target = file_path )
152
- if File .exists (file_path ):
153
- return
154
- raise Exception ('Failed to get screen of {0}.' .format (id ))
148
+ Adb .__run_adb_command (command = 'exec-out screencap -p > ' + file_path , id = id )
149
+ if File .exists (file_path ):
150
+ return
151
+ else :
152
+ raise Exception ('Failed to get screen of {0}.' .format (id ))
155
153
156
154
@staticmethod
157
155
def get_device_version (id ):
0 commit comments