On the code:
#!/usr/bin/env python#-*-coding:utf-8-*-#@Time: 2018/08/31 09:43#@Author: Zc#@File: test.pyImportUiautomator2 as U2 fromTimeImportSLEEPD= U2.connect_usb ('608ad0fe')#Open Small Sell#d (text=u "small sell Safe"). Click ()D.app_start ("cn.sqm.citymine_safety") Sleep (0.2)#Enter user nameD (resourceid="cn.sqm.citymine_safety:id/et_login_id"). Send_keys ("ceshi06") D.click (0.924, 0.607)#Enter PasswordD (resourceid="Cn.sqm.citymine_safety:id/et_login_password"). Set_text ("123456") D.click (0.924, 0.607)#Click the login buttonD (resourceid="Cn.sqm.citymine_safety:id/btn_login"). Click ()#Click Start TaskD (classname="Android.widget.ImageView", instance=25). Click ()#Select task type: daily CheckD (resourceid="Cn.sqm.citymine_safety:id/tv_select_task_type"). Click () Sleep (0.5) d (ClassName="Android.view.View"). Drag_to (0.506, 0.759, duration=0.5) d (resourceId="cn.sqm.citymine_safety:id/btn_confirm"). Click ()#Check Unit: iOS developmentD (resourceid="Cn.sqm.citymine_safety:id/tv_select_inspection_area"). Click () d (ResourceId="Cn.sqm.citymine_safety:id/item_tv_next_level"). Click () d (ResourceId="cn.sqm.citymine_safety:id/item_tv_department"). Click ()#type of vulnerability: otherD (resourceid="Cn.sqm.citymine_safety:id/tv_select_hidden_danger_type"). Click () d (ClassName="Android.view.View"). Drag_to (0.506, 0.759, duration=0.5) d (Text='Determine'). Click ()#Hidden Danger DescriptionD (resourceid="cn.sqm.citymine_safety:id/et_hidden_danger_description"). Set_text ("Other questions") D.click (0.924, 0.607)#Photos: 1D (resourceid="Cn.sqm.citymine_safety:id/iv_choose_photos"). Click () d (Text=u"Mobile Album"). Click () d (ResourceId="cn.sqm.citymine_safety:id/v_selected", classname="Android.widget.ImageView", instance=10). Click () d (ResourceId="Cn.sqm.citymine_safety:id/done"). Click ()#violation of the system: violation of employee Code of conductD (resourceid="cn.sqm.citymine_safety:id/iv_add_violation"). Click () d (ResourceId="cn.sqm.citymine_safety:id/item_tv_content_violation", Text=u"violation of employee code of conduct"). Click () d (ResourceId="Cn.sqm.citymine_safety:id/tv_complete"). Click ()#slide up and dragD (classname="Android.widget.LinearLayout"). Drag_to (0.498, 0.00, duration=0.5)#Rectification Period: Select September 1D (resourceid="cn.sqm.citymine_safety:id/tv_please_the_rectification_date"). Click () forIinchRange (2): D (resourceId="Cn.sqm.citymine_safety:id/day"). Drag_to (0.82, 0.8, duration=0.5) d (Text='Determine'). Click ()#co-workersList = ["Development"]d (ResourceId="Cn.sqm.citymine_safety:id/item_tv_personnel_name"). Click () d (ResourceId="Cn.sqm.citymine_safety:id/item_tv_personnel_name", text=list[0]). Click () d (ResourceId="Cn.sqm.citymine_safety:id/tv_complete"). Click ()#Unit HeadD (resourceid="Cn.sqm.citymine_safety:id/item_tv_personnel_name", classname="Android.widget.TextView", Instance=len (list) +1). Click () forIinchRange (2): D (resourceId="Cn.sqm.citymine_safety:id/lv_area_manager"). Click () d (ResourceId="cn.sqm.citymine_safety:id/item_tv_department", Text=u"Region"). Click () d (ResourceId="Cn.sqm.citymine_safety:id/tv_complete"). Click ()#Back to HomeSleep (0.5) D.click (0.063, 0.068)#Click on myD (resourceid="Cn.sqm.citymine_safety:id/rb_single_center"). Click ()#Exit AccountD (text="Secure Exit Account"). Click ()#Back Home Homepage HomeD.press ("Home")#Test complete closed softwareD.service ("Uiautomator"). Stop ()
Python + Uiaotumator2 Android-app Simple example of automation