标签:
在使用appium过程中遇到了执行一个用例时有多个不同的acitivity的情况,以下为app内部切换acitivity的方法:
如果仅需要切换一次activity,可以通过设置desired_caps[‘appWaitActivity‘] = ‘xxxxxx‘来实现。
如果需要多次切换activity,则通过webdriver中的wait_activity()方法来实现。
wait_activity():
1 def wait_activity(self, activity, timeout, interval=1): 2 """Wait for an activity: block until target activity presents 3 or time out. 4 5 This is an Android-only method. 6 7 :Agrs: 8 - activity - target activity 9 - timeout - max wait time, in seconds 10 - interval - sleep interval between retries, in seconds 11 """ 12 try: 13 WebDriverWait(self, timeout, interval).until( 14 lambda d: d.current_activity == activity) 15 return True 16 except TimeoutException: 17 return False
标签:
原文地址:http://www.cnblogs.com/xjin/p/4976694.html