Best Python code snippet using uiautomator
question.py
Source: question.py
...55 if self.d(resourceId='cn.com.askparents.parentchart:id/anslist').exists(timeout=5):56 try:57 for num in range(nums):58 answer = {}59 time_content = self.d(resourceId="cn.com.askparents.parentchart:id/anslist").child_by_instance(60 resourceId="cn.com.askparents.parentchart:id/text_time", inst=num).get_text()61 answer_content = self.d(62 resourceId="cn.com.askparents.parentchart:id/anslist").child_by_instance(63 resourceId="cn.com.askparents.parentchart:id/text_content", inst=num).get_text()64 answer_name = self.d(resourceId="cn.com.askparents.parentchart:id/anslist").child_by_instance(65 resourceId="cn.com.askparents.parentchart:id/text_name", inst=num).get_text()66 answer['answer_time'] = self.parse_time(time_content)67 answer['answer_name'] = answer_name68 answer['answer_content'] = answer_content69 # if self.d(resourceId='cn.com.askparents.parentchart:id/ll_answelist').exists(timeout=3):70 # if self.d(resourceId='cn.com.askparents.parentchart:id/text_fromname').exists(timeout=3):71 # reply_name = self.d.xpath(72 # '//*[@resource-id="cn.com.askparents.parentchart:id/text_fromname"]').get_text()73 # reply_content = self.d.xpath(74 # '//*[@resource-id="cn.com.askparents.parentchart:id/ll_content"]/android.widget.TextView[1]').get_text()75 # reply_time = self.d.xpath(76 # '//*[@resource-id="cn.com.askparents.parentchart:id/ll_content"]/android.widget.TextView[2]').get_text()77 # answer['reply_name'] = reply_name78 # answer['reply_content'] = reply_content79 # answer['reply_time'] = self.parse_time(reply_time)80 # print('{}次{}'.format(num, answer))81 answer_list.append(answer)82 except Exception as e:83 print(e)84 # self.swipe_down(1)85 finally:86 return answer_list87 else:88 return answer_list89 def merge_question_answers(self, question, answers):90 question['answers_num'] = len(answers)91 for index, answer in enumerate(answers, 1):92 tmp_dict = dict()93 tmp_dict['answer' + str(index)] = '{},{}:{}'.format(answer['answer_name'],94 answer['answer_time'],95 answer['answer_content'])96 question.update(tmp_dict)97 def run(self):98 signature_set = set()99 repeat_count = 0100 while True:101 if self.d(text=self.tab_text).exists(timeout=5):102 self.d(text=self.tab_text).click()103 if self.d(resourceId='cn.com.askparents.parentchart:id/text_question').exists(timeout=5):104 self.d(resourceId="cn.com.askparents.parentchart:id/text_question").click()105 question = self.get_question()106 if question:107 answers = self.get_answers()108 self.merge_question_answers(question, answers)109 signature = str(question)110 if signature in signature_set:111 repeat_count += 1112 else:113 repeat_count = 0114 signature_set.add(signature)115 self.mogo.add_one(self.tab_text, question)116 print('å·²ç»ç¬åäº{}æ¡æ°æ®'.format(len(signature_set)))117 print(question)118 if self.d(resourceId='cn.com.askparents.parentchart:id/img_back').exists(timeout=5):119 self.d(resourceId="cn.com.askparents.parentchart:id/img_back").click()120 if repeat_count >= 10:121 print('å°è¾¾åºé¨')122 # break123 self.swipe_down(2)124 def get_one_page(self):125 question = self.get_question()126 self.merge_question_answers(question, self.get_answers())127 self.mogo.add_one(self.tab_text, question)128 print(question)129 def get_one_answer(self, num=0):130 result = {}131 if self.d(resourceId='cn.com.askparents.parentchart:id/text_content').exists(timeout=5):132 time_content = self.d(resourceId="cn.com.askparents.parentchart:id/anslist").child_by_instance(133 resourceId="cn.com.askparents.parentchart:id/text_time", inst=num).get_text()134 answer_content = self.d(135 resourceId="cn.com.askparents.parentchart:id/anslist").child_by_instance(136 resourceId="cn.com.askparents.parentchart:id/text_content", inst=num).get_text()137 answer_name = self.d(resourceId="cn.com.askparents.parentchart:id/anslist").child_by_instance(138 resourceId="cn.com.askparents.parentchart:id/text_name", inst=num).get_text()139 result['time_content'] = self.parse_time(time_content)140 result['answer_content'] = answer_content141 result['answer_name'] = answer_name142 # if self.d(resourceId='cn.com.askparents.parentchart:id/ll_answelist').exists(timeout=3):143 # reply_name = self.d.xpath(144 # '//*[@resource-id="cn.com.askparents.parentchart:id/text_fromname"]').get_text()145 # reply_content = self.d.xpath(146 # '//*[@resource-id="cn.com.askparents.parentchart:id/ll_content"]/android.widget.TextView[1]').get_text()147 # reply_time = self.d.xpath(148 # '//*[@resource-id="cn.com.askparents.parentchart:id/ll_content"]/android.widget.TextView[2]').get_text()149 # result['reply_name'] = reply_name150 # result['reply_content'] = reply_content151 # result['reply_time'] = self.parse_time(reply_time)...
leave.py
Source: leave.py
...33 button.leaveFilter().click()34 time.sleep(1)35 button.deviceBack()36 print("--device back button is clicked in inbox filter")37 button.listView().child_by_instance(1).click()38 print("--leave card opened in inbox")39 time.sleep(1)40 button.deviceBack()41 print("--device back button clicked in leave details page")42 button.listView().child_by_instance(1).click()43 button.back().click()44 print("--app back button is clicked in leave details page")45 button.leaveFilter().click()46 button.scrollView().scroll.to(text='Approved')47 print("--scrolled in filter to find Approved status")48 button.findTextContain('Approved').click()49 print("--approved status selected")50 button.findTextContain('Apply').click()51 print("--filter applied with approved status")52 button.listView().fling.toBeginning()53 print("--refresh to reset filter")54 button.teamViewLeave().click()55 print("--team view opened")56 time.sleep(1)57 button.deviceBack()58 print("--device back button is clicked in team view")59 button.teamViewLeave().click()60 button.back().click()61 print("--app back button is clicked in team view")62 button.teamViewLeave().click()63 button.listView().fling.toEnd()64 print("--scrolled till end in team view")65 button.leaveTeamViewSearch().click()66 print("--search opened in team view")67 button.enterText('Nikesh')68 print("--text entered in search box")69 time.sleep(2)70 button.leaveTeamViewSearchClear().click()71 print("--search key cleared")72 button.leaveTeamViewSearchClear().click()73 print("--search box closed")74 button.leaveFilter().click()75 print("--leave filter opened in team inbox")76 time.sleep(1)77 button.deviceBack()78 print("--device back button is clicked in team view filter")79 button.leaveFilter().click()80 button.appBack().click()81 button.leaveFilter().click()82 button.findTextContain('study').click()83 print("--study leave selected in filter")84 button.findTextContain("Apply").click()85 print("--filter applied")86 button.listView().fling.toBeginning()87 print("refreshed to remove filter")88 button.listView().child_by_instance(1).click()89 print("--leave card opened in team view")90 time.sleep(1)91 button.deviceBack()92 print("--device back button clicked in leave details page")93 button.listView().child_by_instance(1).click()94 button.backLeaveDetaislPage().click()95 print("--app back button clicked in leave details page")96 button.listView().child_by_instance(1).click()97 button.leaveDetailsUserHeader().click()98 print("--user profile opened from leave details page")99 time.sleep(1)100 button.deviceBack()101 resp.append(True)102 resp.append(printMsg.printSuccess(os.path.basename(__file__)))103 except Exception as e:104 # button.takeScreenShort(os.path.basename(__file__))105 resp.append(False)106 resp.append(printMsg.printException(e, os.path.basename(__file__)))107 return resp108if __name__ == "__main__":...
AppRequest.py
Source: AppRequest.py
...29 self.check_pkg(view + 1)30 def check_pkg(self, positon):31 print(positon)32 index_positon_info = d(className="android.widget.ListView", resourceId="android:id/list") \33 .child_by_instance(positon).info34 print(index_positon_info)35 # class_name_ = index_positon_info['className']36 # if not class_name_ == 'android.widget.ListView':37 # d(className="android.widget.ListView", resourceId="android:id/list") \38 # .child_by_instance(positon).click()39 # if class_name_ == 'android.widget.LinearLayout':40 # print(class_name_)41 # info = d(className=class_name_).info()42 # print(info)43 # d.wait(5)44 # d.press.back()45if __name__ == '__main__':...
Check out the latest blogs from LambdaTest on this topic:
Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.
Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.
“Test frequently and early.” If you’ve been following my testing agenda, you’re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. I’ve encountered several teams who have a lot of automated tests but don’t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.
With new-age project development methodologies like Agile and DevOps slowly replacing the old-age waterfall model, the demand for testing is increasing in the industry. Testers are now working together with the developers and automation testing is vastly replacing manual testing in many ways. If you are new to the domain of automation testing, the organization that just hired you, will expect you to be fast, think out of the box, and able to detect bugs or deliver solutions which no one thought of. But with just basic knowledge of testing, how can you be that successful test automation engineer who is different from their predecessors? What are the skills to become a successful automation tester in 2019? Let’s find out.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!