def check_condition(self): if self.state.lower() == 'on': c=0 while c < self.wait_time: if ui_utils.view_exists(serial = serial, view_to_find = {"text":"NFC"}): if not ( wifi_utils.check_wifi_state_on(serial = self.serial) or bluetooth_utils.check_bluetooth_state_on(serial = self.serial) or ui_utils.is_switch_on(serial = self.serial, view_to_find = {"text":"NFC", "resourceId":"android:id/title"}, right_of = True) ): return True else: if not ( wifi_utils.check_wifi_state_on(serial = self.serial) or bluetooth_utils.check_bluetooth_state_on(serial = self.serial) ): return True c+=1 time.sleep(1) else: self.set_errorm("", 'Not all radios have been turned off by airplane mode:') return False elif self.state.lower() == 'off': c=0 while c < self.wait_time: if ui_utils.view_exists(serial = serial, view_to_find = {"text":"NFC"}): if ( wifi_utils.check_wifi_state_on(serial = self.serial) and bluetooth_utils.check_bluetooth_state_on(serial = self.serial) and ui_utils.is_switch_on(serial = self.serial, view_to_find = {"text":"NFC", "resourceId":"android:id/title"}, right_of = True) ): self.set_passm('All the radios have been turned back on after '+str(c)+' cycles') return True else: if wifi_utils.check_wifi_state_on(serial = self.serial) and bluetooth_utils.check_bluetooth_state_on(serial = self.serial): self.set_passm('All the radios have been turned back on after '+str(c)+' cycles') return True c+=1 time.sleep(1) else: self.set_errorm("", 'Not all radios have been turned back on by airplane mode') return False
def check_condition(self): docs_utils.search_by(serial=self.serial, name=self.title) stat = ui_utils.view_exists(serial = self.serial, view_to_find=\ {"resourceId":"com.google.android.apps.docs.editors.docs:id/title", "text":self.title}) docs_utils.exit_search() return stat
def check_condition(self): docs_utils.exit_search() if self.cancel: to_check = self.title else: to_check = self.new_title docs_utils.search_by(name=to_check, serial=self.serial) stat = ui_utils.view_exists(view_to_find={"text": to_check}) docs_utils.exit_search() return stat
def do(self): open_docs(serial=self.serial)() docs_utils.search_by(serial=self.serial, name=self.title) ui_utils.view_exists(serial=self.serial, view_to_find={"text": self.title}) attempts = 0 while not self.uidevice(text="Remove").wait.exists(timeout=5000)\ and attempts < 4: self.uidevice(text=self.title).\ sibling(resourceId = "com.google.android.apps.docs.editors.docs:id/more_actions_button").click() attempts += 1 ui_steps.click_button( serial=self.serial, view_to_find={"text": "Remove"}, view_to_check={"text": "Do you really want to remove this file?"})() ui_steps.click_button(serial=self.serial, view_to_find={"text": "Remove"}, view_to_check={"description": "Close search"})()
def check_condition(self): ui_steps.click_button( serial=self.serial, view_to_find={"description": "Open navigation drawer"}, view_to_check={"text": "Offline"})() ui_steps.click_button( serial=self.serial, view_to_find={"text": "Offline"}, view_to_check={"description": "Open navigation drawer"})() document_exists = ui_utils.view_exists( view_to_find={"text": self.title}) ui_steps.click_button( serial=self.serial, view_to_find={"description": "Open navigation drawer"}, view_to_check={"text": "Recent"})() ui_steps.click_button( serial=self.serial, view_to_find={"text": "Recent"}, view_to_check={"description": "Open navigation drawer"})() return self.keep_on_device == document_exists
password=PASSWORD)() if (total_account_no >= 2) or (not account_exists) or (account_exists and not account_synced): ui_steps.remove_all_google_accounts(serial=serial)() ui_steps.add_google_account_for_L(serial=serial, account=ACCOUNT, password=PASSWORD, prefer_sync=True)() # remove document if exists docs_steps.open_docs(serial=serial)() docs_utils.search_by(serial=serial, name=TITLE) while ui_utils.view_exists({ "text": TITLE, "resourceIdMatches": ".*title" }, serial=serial): print "found one" docs_steps.delete_document(serial=serial, title=TITLE, no_check=True)() docs_utils.search_by(serial=serial, name=TITLE) docs_utils.exit_search() # add new document docs_steps.add_new_document(serial=serial, title=TITLE, content=CONTENT)() # rename document docs_steps.replace_in_document(serial=serial, title=TITLE, to_replace=TO_REPLACE, replaced_by=REPLACED_BY, count=COUNT)()
account_synced = ui_steps.sync_google_account(serial=serial, account=ACCOUNT, password=PASSWORD)() if (total_account_no >= 2) or (not account_exists) or (account_exists and not account_synced): ui_steps.remove_all_google_accounts(serial=serial)() ui_steps.add_google_account_for_L(serial=serial, account=ACCOUNT, password=PASSWORD, prefer_sync=True)() # remove document if exists docs_steps.open_docs(serial=serial)() docs_utils.search_by(serial=serial, name=TITLE) while ui_utils.view_exists({"text": TITLE, "resourceIdMatches": ".*title"}): print "found one" docs_steps.delete_document(serial=serial, title=TITLE, no_check=True)() docs_utils.exit_search() docs_utils.search_by(serial=serial, name=NEW_TITLE) while ui_utils.view_exists({ "text": NEW_TITLE, "resourceIdMatches": ".*title" }): print "found one" docs_steps.delete_document(serial=serial, title=NEW_TITLE, no_check=True)() docs_utils.search_by(serial=serial, name=TITLE) docs_utils.exit_search() # add new document
ui_steps.unlock_device(serial = serial, pin=wifi_defaults.wifi['pin'])() # go to home screen ui_steps.press_home(serial = serial)() wifi_steps.set_am_state(serial = serial, state='off')() # turn WiFi on wifi_steps.set_wifi_state(serial = serial, state='ON')() # turn BT on adb_steps.command(serial = serial, command = "am start -n com.android.settings/.bluetooth.BluetoothSettings", timeout = wait_time)() ui_steps.click_switch(serial = serial, view_to_find = {"className": "android.widget.Switch"}, state = "ON")() # open More Wireless & networks page adb_steps.command(serial = serial, command = "am start -a android.settings.WIRELESS_SETTINGS", timeout = wait_time)() if ui_utils.view_exists(serial = serial, view_to_find = {"text":"NFC"}): ui_steps.click_switch(serial = serial, view_to_find = {"text":"NFC", "resourceId":"android:id/title"}, state = "ON", right_of = True )() class check_radios_behaviour_airplane_mode(adb_step): def __init__(self, state = 'on', wait_time = 5, **kwargs): adb_step.__init__(self, **kwargs) self.state = state self.wait_time = wait_time def do(self): wifi_steps.set_am_state(serial = self.serial, state=self.state, wait_time = self.wait_time)() def check_condition(self): if self.state.lower() == 'on':