def initialize(self): logging.info("========initialize========") base = Base(self.driver) for i in range(10): myself = base.isElementExist( [By.ID, "com.cnmts.smart_message:id/message"]) if myself: base.click([By.ID, "com.cnmts.smart_message:id/message"]) break else: self.driver.keyevent(4)
def login_status(self): base = Base(self.driver) ele = base.isElementExist( [By.ID, "com.cnmts.smart_message:id/img_ming_lu"]) if ele: logging.info("========login success========") return True else: logging.info("========login fail========") base.screenShot("login_zx fail") return False
def send_location(self): # 发送位置 base = Base(self.driver) ele = base.isElementExist( [By.ID, "com.cnmts.smart_message:id/rc_ext_plugin_icon"]) if ele: pass else: base.click([By.ID, "com.cnmts.smart_message:id/rc_plugin_toggle"]) base.findElements( [By.ID, "com.cnmts.smart_message:id/rc_ext_plugin_icon"])[2].click() base.click([By.ID, "com.cnmts.smart_message:id/btn_location_send"])
def login_zx1(self, username, password): base = Base(self.driver) skip = base.isElementExist( [By.ID, "com.cnmts.smart_message:id/tv_jump"]) if skip: base.click([By.ID, "com.cnmts.smart_message:id/tv_jump"]) else: pass for i in range(5): logging.info("======quanxian_setting======") permission_allow = base.isElementExist([ By.ID, "com.android.packageinstaller:id/permission_allow_button" ]) if permission_allow: logging.info("======quanxian_cunzai======") base.click([ By.ID, "com.android.packageinstaller:id/permission_allow_button" ]) else: break logging.info("======login zhixin======") base.click([By.ID, "com.cnmts.smart_message:id/tv_change_user"]) base.sendKeys([By.ID, "com.cnmts.smart_message:id/et_username"], username) base.sendKeys([By.ID, "com.cnmts.smart_message:id/et_pwd"], password) base.click([By.ID, "com.cnmts.smart_message:id/btn_login"]) # 需要加一个新用户的判断 # 电池优化权限 self.driver.implicitly_wait(40) button = base.isElementExist([By.ID, "android:id/button1"]) if button: base.click([By.ID, "android:id/button1"]) else: pass
def login_zx2(self, username="******", password="******"): base = Base(self.driver) skip = base.isElementExist( [By.ID, "com.cnmts.smart_message:id/tv_jump"]) if skip: base.click([By.ID, "com.cnmts.smart_message:id/tv_jump"]) else: pass logging.info("======login zhixin======") base.click([By.ID, "com.cnmts.smart_message:id/tv_change_user"]) base.sendKeys([By.ID, "com.cnmts.smart_message:id/et_username"], username) base.sendKeys([By.ID, "com.cnmts.smart_message:id/et_pwd"], password) base.click([By.ID, "com.cnmts.smart_message:id/btn_login"])
def send_document(self): # 发送文件 base = Base(self.driver) ele = base.isElementExist( [By.ID, "com.cnmts.smart_message:id/rc_ext_plugin_icon"]) if ele: pass else: base.click([By.ID, "com.cnmts.smart_message:id/rc_plugin_toggle"]) base.findElements( [By.ID, "com.cnmts.smart_message:id/rc_ext_plugin_icon"])[3].click() base.click([By.ID, "com.cnmts.smart_message:id/radio_select"]) base.click([By.ID, "com.cnmts.smart_message:id/layout_send"])
def send_picture(self): # 发送图片 base = Base(self.driver) # 需要加+的判断 ele = base.isElementExist( [By.ID, "com.cnmts.smart_message:id/rc_ext_plugin_icon"]) if ele: pass else: base.click([By.ID, "com.cnmts.smart_message:id/rc_plugin_toggle"]) base.findElements( [By.ID, "com.cnmts.smart_message:id/rc_ext_plugin_icon"])[0].click() base.click([By.ID, "com.cnmts.smart_message:id/tv_select"]) base.click([By.ID, "com.cnmts.smart_message:id/tv_confirm"])
def login_out_zx(self): base = Base(self.driver) logging.info("========login out========") for i in range(10): myself = base.isElementExist( [By.ID, "com.cnmts.smart_message:id/people"]) if myself: base.click([By.ID, "com.cnmts.smart_message:id/people"]) break else: self.driver.keyevent(4) self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("退出登录")').click() sleep(1) self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("确定")').click()
def take_photo(self): # 拍摄图片 base = Base(self.driver) ele = base.isElementExist( [By.ID, "com.cnmts.smart_message:id/rc_ext_plugin_icon"]) if ele: pass else: base.click([By.ID, "com.cnmts.smart_message:id/rc_plugin_toggle"]) base.findElements( [By.ID, "com.cnmts.smart_message:id/rc_ext_plugin_icon"])[1].click() sleep(2) base.findElements([By.CLASS_NAME, "android.view.View"])[1].click() sleep(2) base.findElements([By.CLASS_NAME, "android.view.View"])[1].click()