Skip to content

Commit 09621df

Browse files
committed
add wait_activity method for webdriver
1 parent b562288 commit 09621df

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

appium/webdriver/webdriver.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import time
16+
1517
from selenium import webdriver
1618

1719
from .connectiontype import ConnectionType
@@ -400,6 +402,25 @@ def current_activity(self):
400402
"""
401403
return self.execute(Command.GET_CURRENT_ACTIVITY)['value']
402404

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+
403424
def set_value(self, element, value):
404425
"""Set the value on an element in the application.
405426

0 commit comments

Comments
 (0)