File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ import time
16
+
15
17
from selenium import webdriver
16
18
17
19
from .connectiontype import ConnectionType
@@ -400,6 +402,25 @@ def current_activity(self):
400
402
"""
401
403
return self .execute (Command .GET_CURRENT_ACTIVITY )['value' ]
402
404
405
+ def wait_activity (self , activity , retries = 10 , interval = 1 ):
406
+ """Wait for an activity: block until target activity presents or retry
407
+ time exhausts.
408
+
409
+ This is an Android-only method.
410
+
411
+ :Agrs:
412
+ - activity - target activity
413
+ - retries - max retry times
414
+ - interval - sleep interval, in seconds
415
+ """
416
+ for i in xrange (retries ):
417
+ if self .current_activity == activity :
418
+ return True
419
+ time .sleep (interval )
420
+ if self .current_activity == activity :
421
+ return True
422
+ return False
423
+
403
424
def set_value (self , element , value ):
404
425
"""Set the value on an element in the application.
405
426
You can’t perform that action at this time.
0 commit comments