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 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 create_group1(self): base = Base(self.driver) base.click([By.ID, "com.cnmts.smart_message:id/img_show_more"]) self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("发起群聊")').click() base.click([By.ID, "com.cnmts.smart_message:id/tv_title"]) base.findElements([By.ID, "com.cnmts.smart_message:id/tv_full_name" ])[1].click() sleep(1) self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("智能平台研发部")').click() base.findElements([By.ID, "com.cnmts.smart_message:id/radio_select" ])[3].click() base.click([By.ID, "com.cnmts.smart_message:id/btn_ok"])
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 group_setting_group1(self): base = Base(self.driver) # 点击群设置 base.click([By.ID, "com.cnmts.smart_message:id/btn_right"]) # 群减人 number = base.findElement( [By.ID, "com.cnmts.smart_message:id/tv_group_member_size"]).text a = re.findall(r"\d+\.?\d*", number) b = int(a[0]) if b < 4: c = b + 2 base.findElements([By.ID, "com.cnmts.smart_message:id/iv_avatar" ])[c].click() else: base.findElements([By.ID, "com.cnmts.smart_message:id/iv_avatar" ])[6].click() self.driver.find_element_by_android_uiautomator( 'new UiSelector().text("任少龙")').click() base.click([By.ID, "com.cnmts.smart_message:id/btn_sure"]) sleep(2)
def group_setting_group2(self): base = Base(self.driver) # 点击群设置 base.click([By.ID, "com.cnmts.smart_message:id/btn_right"]) number = base.findElement( [By.ID, "com.cnmts.smart_message:id/tv_group_member_size"]).text a = re.findall(r"\d+\.?\d*", number) b = int(a[0]) # 群加人 if b < 3: d = b + 1 base.findElements([By.ID, "com.cnmts.smart_message:id/iv_avatar" ])[d].click() else: sleep(2) base.findElements([By.ID, "com.cnmts.smart_message:id/iv_avatar" ])[5].click() base.click([By.ID, "com.cnmts.smart_message:id/query"]) base.sendKeys([By.ID, "com.cnmts.smart_message:id/query"], "王德晨") base.click([By.ID, "com.cnmts.smart_message:id/radio_select"]) base.click([By.ID, "com.cnmts.smart_message:id/btn_ok"])
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()
def longpress(self): base = Base(self.driver) el = base.findElements( [By.ID, "com.cnmts.smart_message:id/text_message"])[0] TouchAction(self.driver).long_press(el, 1000).perform()