def setup(self): self.enter() for web in self.config.get("Browser", "setup").split(","): bookmark = [ # {"id":"text","content":["Accept & continue"],"assert":False}, # {"id":"text","content":["Next"],"assert":False}, # {"id":"text","content":["No thanks"],"assert":False}, { "id": "meta", "content": "chrome_webpage", "action": { "param": [web], "assert": False } }, { "id": "description", "content": ["More options", "Bookmark this page"] }, { "id": { "text": "Save" } }, { "id": "meta", "content": "back_to_chrome" } ] #self.chrome_webpage("www.baidu.com") UIParser.run(self, bookmark, self.back_to_chrome) pass
def setup(self): self.enter() for web in self.config.get("Browser","setup").split(","): bookmark = [ # {"id":"text","content":["Accept & continue"],"assert":False}, # {"id":"text","content":["Next"],"assert":False}, # {"id":"text","content":["No thanks"],"assert":False}, {"id":"meta","content":"chrome_webpage","action":{"param":[web],"assert":False}}, {"id":"description","content":["More options","Bookmark this page"]}, {"id":{"text":"Save"}}, {"id":"meta","content":"back_to_chrome"} ] #self.chrome_webpage("www.baidu.com") UIParser.run(self,bookmark,self.back_to_chrome) pass
def setup(self): """Launch music by StartActivity. """ self.enter() step = [ {"id":{"text":'Skip'},"assert":False}, ] return UIParser.run(self,step,self.close)
def del_all_message(self): """delete all message in current list """ self.logger.debug('delete all message') delete_all = [ {"id":"description","content":"More options"}, {"id":"text","content":["Delete all threads","Delete"]}, {"id":"resourceId","content":"com.android.mms:id/empty","action":None}, ] return UIParser.run(self,delete_all,self.back_to_message) '''
def del_all_message(self): """delete all message in current list """ self.logger.debug("delete all message") delete_all = [ {"id": "description", "content": "More options"}, {"id": "text", "content": ["Delete all threads", "Delete"]}, {"id": "resourceId", "content": "com.android.mms:id/empty", "action": None}, ] return UIParser.run(self, delete_all, self.back_to_message) """
def mms_Send(self,number,type,content = "10010"): """send a message(MMS) argv: (str)number -- the telephone number you want to send (str)content -- MMS content (str)subject -- MMS subject pic\video\audio -- attachment of the message """ if not self.enter(): return False text = [ {"id":"resourceId","content":"com.android.mms:id/action_compose_new"}, {"id":"className","content":"android.widget.MultiAutoCompleteTextView","action":{"type":"set_text","param":[number]}}, {"id":"text","content":"Type text message","action":{"type":"set_text","param":[content]}}, {"id":"resourceId","content":"com.android.mms:id/send_button_sms"}, {"id":"meta","content":"back_to_message"}, ] picture = [ {"id":"resourceId","content":"com.android.mms:id/action_compose_new"}, {"id":"className","content":"android.widget.MultiAutoCompleteTextView","action":{"type":"set_text","param":[number]}}, {"id":"resourceId","content":"com.android.mms:id/share_button"}, {"id":"text","content":["Pictures","Capture picture"]}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/shutter_button","action":{"type":"click"}}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/btn_done"}, {"id":"resourceId","content":"com.android.mms:id/send_button_mms"}, {"id":"meta","content":"back_to_message"}, ] video = [ {"id":"resourceId","content":"com.android.mms:id/action_compose_new"}, {"id":"className","content":"android.widget.MultiAutoCompleteTextView","action":{"type":"set_text","param":[number]}}, {"id":"resourceId","content":"com.android.mms:id/share_button"}, {"id":"text","content":["Videos","Capture video"]}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/shutter_button","action":{"type":"click","delay":1000}}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/shutter_button"}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/btn_done"}, {"id":"resourceId","content":"com.android.mms:id/send_button_mms"}, {"id":"meta","content":"back_to_message"}, ] audio = [ {"id":"resourceId","content":"com.android.mms:id/action_compose_new"}, {"id":"className","content":"android.widget.MultiAutoCompleteTextView","action":{"type":"set_text","param":[number]}}, {"id":"resourceId","content":"com.android.mms:id/share_button"}, {"id":"text","content":["Audio","Record audio"]}, {"id":"resourceId","content":"com.tct.soundrecorder:id/recordButton","action":{"type":"click","delay":1000}}, {"id":"text","content":"Save"}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/btn_done","assert":False}, {"id":"resourceId","content":"com.android.mms:id/send_button_mms"}, {"id":"meta","content":"back_to_message"}, ] return UIParser.run(self,locals()[str(type)],self.back_to_message)
def setup(self): """Launch music by StartActivity. """ self.enter() step = [ { "id": { "text": 'Skip' }, "assert": False }, ] return UIParser.run(self, step, self.close)
def setup(self,data = None): if not self.enter(): return False text = [ {"id":{"resourceId":self.appconfig.id("id_new")}}, {"id":{"className":"android.widget.MultiAutoCompleteTextView"},"action":{"type":"set_text","param":[self.msgs["Text"]]}}, #{"id":{"text":"Type text message"},"action":{"type":"set_text","param":["10010"]}}, #sprints {"id":{"resourceId":"com.android.mms:id/embedded_text_editor"},"action":{"type":"set_text","param":["10010"]}}, #alto5gl {"id":{"resourceId":self.appconfig.id("id_sms_send")}}, {"id":{"meta":"back_to_message"}}, ] picture = [ {"id":"resourceId","content":self.appconfig.id("id_new")}, {"id":"className","content":"android.widget.MultiAutoCompleteTextView","action":{"type":"set_text","param":[self.msgs["Photo"]]}}, {"id":"resourceId","content":self.appconfig.id("id_share")}, {"id":"text","content":[self.appconfig("picture"),self.appconfig("capture_picture")]}, {"id":"text","content":"No thanks","assert":False}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/shutter_button","action":{"type":"click"}}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/btn_done"}, {"id":{"resourceId":self.appconfig.id("id_mms_send")}}, {"id":"meta","content":"back_to_message"}, ] video = [ {"id":"resourceId","content":self.appconfig.id("id_new")}, {"id":"className","content":"android.widget.MultiAutoCompleteTextView","action":{"type":"set_text","param":[self.msgs["Video"]]}}, {"id":"resourceId","content":"com.android.mms:id/share_button"}, {"id":"text","content":["Videos","Capture video"]}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/shutter_button","action":{"type":"click","delay":1000}}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/shutter_button"}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/btn_done"}, {"id":"resourceId","content":"com.android.mms:id/send_button_mms"}, {"id":"meta","content":"back_to_message"}, ] audio = [ {"id":"resourceId","content":self.appconfig.id("id_new")}, {"id":"className","content":"android.widget.MultiAutoCompleteTextView","action":{"type":"set_text","param":self.msgs["Audio"]}}, {"id":"resourceId","content":"com.android.mms:id/share_button"}, {"id":"text","content":["Audio","Record audio"]}, {"id":"resourceId","content":"com.tct.soundrecorder:id/recordButton","action":{"type":"click","delay":1000}}, {"id":"text","content":"Save","wait":20000}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/btn_done","assert":False}, {"id":"resourceId","content":"com.android.mms:id/send_button_mms"}, {"id":"meta","content":"back_to_message"}, ] return UIParser.run(self,[text,picture,video,audio],self.back_to_message)
def send_pic(self,number): """send a message(SMS) argv: (str)number -- the telephone number you want to send (str)content -- SMS content """ picture = [ {"id":"resourceId","content":"com.android.mms:id/action_compose_new"}, {"id":"className","content":"android.widget.MultiAutoCompleteTextView","action":{"type":"set_text","param":[number]}}, {"id":"resourceId","content":"com.android.mms:id/share_button"}, {"id":"text","content":["Pictures","Capture picture"]}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/shutter_button","action":{"type":"click"}}, {"id":"resourceId","content":"org.codeaurora.snapcam:id/btn_done"}, {"id":"resourceId","content":"com.android.mms:id/send_button_mms"}, {"id":"meta","content":"back_to_message"}, ] return UIParser.run(self,picture,self.back_to_message)
def fwd_msg(self, type, number): """Long touch a msg in tread screen and select the option. argv: (str)str_option -- option dispaly in the popup menu. """ self.logger.debug("Select message option %s." % (type)) self.select_msg(type) self.device.press.back() send = "Send" if type == "Text" else "Send MMS" fwd = [ {"id": {"resourceId": self.appconfig.id("id_text_view")}, "action": {"type": "long_click"}}, {"id": {"text": "Forward"}}, { "id": {"className": "android.widget.MultiAutoCompleteTextView"}, "action": {"type": "set_text", "param": [number]}, }, {"id": {"description": send}}, {"id": "meta", "content": "_verify_msg_sending", "assert": False}, {"id": "meta", "content": "back_to_message"}, ] return UIParser.run(self, fwd, self.back_to_message) # ------------------legency--------------------------- self.device(resourceId="com.android.mms:id/msg_list_item").long_click() if self.device(resourceId="com.android.mms:id/forward").wait.exists(timeout=2000): self.device(resourceId="com.android.mms:id/forward").click() input_text = self.device(className="android.widget.MultiAutoCompleteTextView") if input_text.wait.exists(timeout=2000): self.logger.debug("input phone number:" + str(number)) input_text.set_text(str(number)) self.device.delay(1) self.logger.debug("send") if type == "Text": if self.device(resourceId=self.appconfig.id("id_sms_send")).wait.exists(timeout=3000): self.device(resourceId=self.appconfig.id("id_sms_send")).click() else: if self.device(resourceId=self.appconfig.id("id_mms_send")).wait.exists(timeout=3000): self.device(resourceId=self.appconfig.id("id_mms_send")).click() self.device.delay(1) self.back_to_message() self.device.delay(2) self.device(className="android.widget.ListView").child(index=0).click() self.device.delay(2) return self._verify_msg_sending()
def select_msg(self, strtype): """select message by specified index. argv: (int)index -- message order in the list_node (str)strtype -- for stability test. msgs = {'Audio':0,'Video':1,'Photo':2,'Text':3} """ select = [{"id": {"resourceId": "com.android.mms:id/from", "text": self.msgs[strtype]}}] return UIParser.run(self, select, self.back_to_message) # ------------------legency--------------------------- if self.device(resourceId="com.android.mms:id/from", text=self.msgs[strtype]).exists: if self.device(resourceId="com.android.mms:id/from", text=self.msgs[strtype]).click(): if self.device(resourceId="com.android.mms:id/history").wait.exists(timeout=2000): return True else: self.logger.debug("select message fail!!!") return False return True
def fwd_msg(self,type,number): """Long touch a msg in tread screen and select the option. argv: (str)str_option -- option dispaly in the popup menu. """ self.logger.debug("Select message option %s." %(type)) self.select_msg(type) self.device.press.back() send = "Send" if type=="Text" else "Send MMS" fwd = [ {"id":{"resourceId":self.appconfig.id("id_text_view")},"action":{"type":"long_click"}}, {"id":{"text":'Forward'}}, {"id":{"className":"android.widget.MultiAutoCompleteTextView"},"action":{"type":"set_text","param":[number]}}, {"id":{"description":send}}, {"id":"meta","content":"_verify_msg_sending","assert":False}, {"id":"meta","content":"back_to_message"} ] return UIParser.run(self,fwd,self.back_to_message) #------------------legency--------------------------- self.device(resourceId="com.android.mms:id/msg_list_item").long_click() if self.device(resourceId="com.android.mms:id/forward").wait.exists(timeout = 2000): self.device(resourceId="com.android.mms:id/forward").click() input_text = self.device(className='android.widget.MultiAutoCompleteTextView') if input_text.wait.exists(timeout = 2000): self.logger.debug('input phone number:'+str(number)) input_text.set_text(str(number)) self.device.delay(1) self.logger.debug('send') if type == "Text": if self.device(resourceId=self.appconfig.id("id_sms_send")).wait.exists(timeout = 3000): self.device(resourceId=self.appconfig.id("id_sms_send")).click() else: if self.device(resourceId=self.appconfig.id("id_mms_send")).wait.exists(timeout = 3000): self.device(resourceId=self.appconfig.id("id_mms_send")).click() self.device.delay(1) self.back_to_message() self.device.delay(2) self.device(className='android.widget.ListView').child(index=0).click() self.device.delay(2) return self._verify_msg_sending()
def send_pic(self, number): """send a message(SMS) argv: (str)number -- the telephone number you want to send (str)content -- SMS content """ picture = [ {"id": "resourceId", "content": "com.android.mms:id/action_compose_new"}, { "id": "className", "content": "android.widget.MultiAutoCompleteTextView", "action": {"type": "set_text", "param": [number]}, }, {"id": "resourceId", "content": "com.android.mms:id/share_button"}, {"id": "text", "content": ["Pictures", "Capture picture"]}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/shutter_button", "action": {"type": "click"}}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/btn_done"}, {"id": "resourceId", "content": "com.android.mms:id/send_button_mms"}, {"id": "meta", "content": "back_to_message"}, ] return UIParser.run(self, picture, self.back_to_message)
def select_msg(self,strtype): """select message by specified index. argv: (int)index -- message order in the list_node (str)strtype -- for stability test. msgs = {'Audio':0,'Video':1,'Photo':2,'Text':3} """ select = [ {"id":{"resourceId":'com.android.mms:id/from',"text":self.msgs[strtype]}} ] return UIParser.run(self,select,self.back_to_message) #------------------legency--------------------------- if self.device(resourceId='com.android.mms:id/from',text = self.msgs[strtype]).exists: if self.device(resourceId='com.android.mms:id/from',text = self.msgs[strtype]).click(): if self.device(resourceId='com.android.mms:id/history').wait.exists(timeout = 2000): return True else: self.logger.debug('select message fail!!!') return False return True
def setup(self,accountName,password,type = "pop3"): self.enter() if type == "pop3": step1 = [ {"id":{"text":self.appconfig("mail_type","Email")}}, {"id":{"resourceId":self.appconfig.id("id_next","Email")}}, {"id":{"resourceId":"com.android.email:id/account_email"},"action":{"type":"set_text","param":[accountName]}}, {"id":{"resourceId":"com.android.email:id/next"}}, {"id":{"text":"POP3"}}, {"id":{"resourceId":"com.android.email:id/regular_password"},"action":{"type":"set_text","param":[password]}}, {"id":{"resourceId":"com.android.email:id/next"},"delay":5000}, {"id":{"resourceId":"com.android.email:id/account_server"},"action":{"type":"clear_text"},"delay":5000}, {"id":{"resourceId":"com.android.email:id/account_server"},"action":{"type":"set_text","param":[self.appconfig("mail_server")]}}, ] if UIParser.run(self,step1, self.back_to_mainapp)==False: return False self.device(scrollable=True).scroll.vert.to(description="Next") step2 = [ {"id":{"description":"Next"},"delay":10000}, {"id":{"resourceId":"com.android.email:id/account_server"},"action":{"type":"clear_text"},"delay":5000}, {"id":{"resourceId":"com.android.email:id/account_server"},"action":{"type":"set_text","param":[self.appconfig("mail_server")]}}, ] if UIParser.run(self,step2, self.back_to_mainapp)==False: return False self.device(scrollable=True).scroll.vert.to(description="Next") step3 = [ {"id":"description","resourceId":["Next","Next"],"delay":10000}, {"id":{"resourceId":"com.android.email:id/account_name"},"action":{"type":"set_text","param":"CreatedByUIA"}}, {"id":"description","resourceId":["Next","Next"]} ] if UIParser.run(self,step3, self.back_to_mainapp)==False: return False elif type == "exchange": step1 = [ {"id":{"resourceId":"com.android.email:id/account_email"},"action":{"type":"set_text","param":[accountName]}}, {"id":"text","content":["Manual setup","Exchange"]}, {"id":{"resourceId":"com.android.email:id/regular_password"},"action":{"type":"set_text","param":[password]}}, {"id":{"resourceId":"com.android.email:id/next"},"delay":5000}, {"id":{"resourceId":"com.android.email:id/account_username"},"action":{"type":"clear_text"},"delay":5000}, {"id":{"resourceId":"com.android.email:id/account_username"},"action":{"type":"set_text","param":[accountName]}}, {"id":"meta","content":"back"}, {"id":{"resourceId":"com.android.email:id/account_server"},"action":{"type":"clear_text"},"delay":5000}, {"id":{"resourceId":"com.android.email:id/account_server"},"action":{"type":"set_text","param":["mail.tcl.com"]}}, {"id":"meta","content":"back"}, {"id":{"description":"Security type"}}, {"id":{"text":"SSL/TLS (Accept all certificates)"}}, ] if UIParser.run(self,step1, self.back_to_mainapp)==False: return False self.device(scrollable=True).scroll.vert.to(description="Next") step3 = [ {"id":{"description":"Next"}}, {"id":{"text":"OK"},"wait":60000}, {"id":{"resourceId":"com.android.email:id/account_check_frequency"}}, {"id":{"text":"Manual"}}, {"id":{"resourceId":"com.android.email:id/account_sync_window"}}, {"id":{"text":"All"}}, ] if UIParser.run(self,step3, self.back_to_mainapp)==False: return False self.device(scrollable=True).scroll.vert.to(description="Next") step4 = [ {"id":{"description":"Next"}}, {"id":{"text":"Activate"},"wait":10000}, {"id":{"description":"Next"},"wait":30000}, ] if UIParser.run(self,step4, self.back_to_mainapp)==False: return False self.device.delay(60) self.select_mail(0) self.device.delay(5) self.select_mail(1) step5 = [ {"id":{"resourceId":"com.android.email:id/attachment_icon"},"wait":30000}, ] if UIParser.run(self,step5, self.back_to_mainapp)==False: return False self.back_to_mainapp() return True
def setup(self, data=None): if not self.enter(): return False text = [ {"id": {"resourceId": self.appconfig.id("id_new")}}, { "id": {"className": "android.widget.MultiAutoCompleteTextView"}, "action": {"type": "set_text", "param": [self.msgs["Text"]]}, }, # {"id":{"text":"Type text message"},"action":{"type":"set_text","param":["10010"]}}, #sprints { "id": {"resourceId": "com.android.mms:id/embedded_text_editor"}, "action": {"type": "set_text", "param": ["10010"]}, }, # alto5gl {"id": {"resourceId": self.appconfig.id("id_sms_send")}}, {"id": {"meta": "back_to_message"}}, ] picture = [ {"id": "resourceId", "content": self.appconfig.id("id_new")}, { "id": "className", "content": "android.widget.MultiAutoCompleteTextView", "action": {"type": "set_text", "param": [self.msgs["Photo"]]}, }, {"id": "resourceId", "content": self.appconfig.id("id_share")}, {"id": "text", "content": [self.appconfig("picture"), self.appconfig("capture_picture")]}, {"id": "text", "content": "No thanks", "assert": False}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/shutter_button", "action": {"type": "click"}}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/btn_done"}, {"id": {"resourceId": self.appconfig.id("id_mms_send")}}, {"id": "meta", "content": "back_to_message"}, ] video = [ {"id": "resourceId", "content": self.appconfig.id("id_new")}, { "id": "className", "content": "android.widget.MultiAutoCompleteTextView", "action": {"type": "set_text", "param": [self.msgs["Video"]]}, }, {"id": "resourceId", "content": "com.android.mms:id/share_button"}, {"id": "text", "content": ["Videos", "Capture video"]}, { "id": "resourceId", "content": "org.codeaurora.snapcam:id/shutter_button", "action": {"type": "click", "delay": 1000}, }, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/shutter_button"}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/btn_done"}, {"id": "resourceId", "content": "com.android.mms:id/send_button_mms"}, {"id": "meta", "content": "back_to_message"}, ] audio = [ {"id": "resourceId", "content": self.appconfig.id("id_new")}, { "id": "className", "content": "android.widget.MultiAutoCompleteTextView", "action": {"type": "set_text", "param": self.msgs["Audio"]}, }, {"id": "resourceId", "content": "com.android.mms:id/share_button"}, {"id": "text", "content": ["Audio", "Record audio"]}, { "id": "resourceId", "content": "com.tct.soundrecorder:id/recordButton", "action": {"type": "click", "delay": 1000}, }, {"id": "text", "content": "Save", "wait": 20000}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/btn_done", "assert": False}, {"id": "resourceId", "content": "com.android.mms:id/send_button_mms"}, {"id": "meta", "content": "back_to_message"}, ] return UIParser.run(self, [text, picture, video, audio], self.back_to_message)
def mms_Send(self, number, type, content="10010"): """send a message(MMS) argv: (str)number -- the telephone number you want to send (str)content -- MMS content (str)subject -- MMS subject pic\video\audio -- attachment of the message """ if not self.enter(): return False text = [ {"id": "resourceId", "content": "com.android.mms:id/action_compose_new"}, { "id": "className", "content": "android.widget.MultiAutoCompleteTextView", "action": {"type": "set_text", "param": [number]}, }, {"id": "text", "content": "Type text message", "action": {"type": "set_text", "param": [content]}}, {"id": "resourceId", "content": "com.android.mms:id/send_button_sms"}, {"id": "meta", "content": "back_to_message"}, ] picture = [ {"id": "resourceId", "content": "com.android.mms:id/action_compose_new"}, { "id": "className", "content": "android.widget.MultiAutoCompleteTextView", "action": {"type": "set_text", "param": [number]}, }, {"id": "resourceId", "content": "com.android.mms:id/share_button"}, {"id": "text", "content": ["Pictures", "Capture picture"]}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/shutter_button", "action": {"type": "click"}}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/btn_done"}, {"id": "resourceId", "content": "com.android.mms:id/send_button_mms"}, {"id": "meta", "content": "back_to_message"}, ] video = [ {"id": "resourceId", "content": "com.android.mms:id/action_compose_new"}, { "id": "className", "content": "android.widget.MultiAutoCompleteTextView", "action": {"type": "set_text", "param": [number]}, }, {"id": "resourceId", "content": "com.android.mms:id/share_button"}, {"id": "text", "content": ["Videos", "Capture video"]}, { "id": "resourceId", "content": "org.codeaurora.snapcam:id/shutter_button", "action": {"type": "click", "delay": 1000}, }, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/shutter_button"}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/btn_done"}, {"id": "resourceId", "content": "com.android.mms:id/send_button_mms"}, {"id": "meta", "content": "back_to_message"}, ] audio = [ {"id": "resourceId", "content": "com.android.mms:id/action_compose_new"}, { "id": "className", "content": "android.widget.MultiAutoCompleteTextView", "action": {"type": "set_text", "param": [number]}, }, {"id": "resourceId", "content": "com.android.mms:id/share_button"}, {"id": "text", "content": ["Audio", "Record audio"]}, { "id": "resourceId", "content": "com.tct.soundrecorder:id/recordButton", "action": {"type": "click", "delay": 1000}, }, {"id": "text", "content": "Save"}, {"id": "resourceId", "content": "org.codeaurora.snapcam:id/btn_done", "assert": False}, {"id": "resourceId", "content": "com.android.mms:id/send_button_mms"}, {"id": "meta", "content": "back_to_message"}, ] return UIParser.run(self, locals()[str(type)], self.back_to_message)