def group_setting_name(self, rename): base = Base(self.driver) # 点击群设置 base.click([By.ID, "com.cnmts.smart_message:id/btn_right"]) # 更改群名称 base.click([By.ID, "com.cnmts.smart_message:id/tv_change_group_name"]) base.sendKeys([By.ID, "com.cnmts.smart_message:id/et_content"], rename) base.click([By.ID, "com.cnmts.smart_message:id/tv_save"])
def send_word(self, word): base = Base(self.driver) for i in range(2): base.sendKeys([By.ID, "com.cnmts.smart_message:id/rc_edit_text"], word) base.click([By.ID, "com.cnmts.smart_message:id/rc_send_toggle"]) base.click([By.ID, "com.cnmts.smart_message:id/rc_emoticon_toggle"]) for i in range(3): base.click([By.ID, "com.cnmts.smart_message:id/rc_ext_emoji_item"]) base.click([By.ID, "com.cnmts.smart_message:id/rc_send_toggle"])
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 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 approval_company_project(self, name): sleep(1) base = Base(self.driver) # 点击正式项目管理 base.click([By.XPATH, "//*[@id='leftBox']/ul/li[2]/ul/li/ul/li[1]"]) # 选择要审批的项目 sleep(1) for num in range(1, 6): companyname = self.driver.find_element_by_xpath( '//*[@id="pane-first"]/div/div[3]/div/div[3]/table/tbody/tr[' + str(num) + ']/td[3]/div').text if name == str(companyname): # 点击查看 self.driver.find_element_by_xpath( '//*[@id="pane-first"]/div/div[3]/div/div[4]/div[2]/table/tbody/tr[' + str(num) + ']/td[9]/div/div/div[1]').click() break # 点击同意 base.click( [By.XPATH, '//*[@id="printContent"]/div[1]/div[2]/div/span[1]']) base.sendKeys([By.CLASS_NAME, "el-textarea__inner"], "同意同意同意") base.click([ By.XPATH, '//*[@id="approvalDetail"]/div[2]/div/div[3]/span/button[2]/span' ]) sleep(1) # 点击审批主题 base.click([ By.XPATH, '//*[@id="pane-first"]/div/div[1]/form/div[2]/div/div/div/input' ]) # 选择我已审批 sleep(1) base.click([By.XPATH, '/html/body/div[2]/div[1]/div[1]/ul/li[2]/span']) # 点击查询 base.click([ By.XPATH, '//*[@id="pane-first"]/div/div[1]/div/div[2]/button[1]/span' ])
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 search(self, keyword): logging.info("========start serch========") base = Base(self.driver) base.click([By.ID, "com.cnmts.smart_message:id/search"]) base.sendKeys([By.ID, "com.cnmts.smart_message:id/query"], keyword) base.click([By.ID, "com.cnmts.smart_message:id/layout_item"])