def search(self, name="张超"): sleep(1) Base.sendKeys(self, [By.ID, "search-input"], name, self.driver) sleep(1) self.driver.get_screenshot_as_file("E:\\screenshot\\搜索人" + name + ".png") Base.click( self, [By.XPATH, "//*[@id='app']/div/section/header/div[1]/ul/li[1]"], self.driver)
def withdraw(self): sleep(1) right_click = self.driver.find_element_by_xpath( '//*[@id="scroll-body"]/li/div/div[2]/div/p') # 对定位到的元素执行右击操作 ActionChains(driver).context_click(right_click).perform() # 撤回 Base.click( self, [By.XPATH, '//*[@id="message-container"]/ul[2]/li[1]/button'], self.driver) sleep(1) self.driver.get_screenshot_as_file("E:\\screenshot\\撤回.png")
def transpond(self, transpond_name="任少龙"): sleep(1) right_click = self.driver.find_element_by_xpath( '//*[@id="scroll-body"]/li[2]/div/div[2]/div/p') # 对定位到的元素执行右击操作 ActionChains(driver).context_click(right_click).perform() Base.click( self, [By.XPATH, '//*[@id="message-container"]/ul[2]/li[4]/button'], self.driver) # 选择收件人 Base.sendKeys(self, [ By.XPATH, '/html/body/div[3]/div[2]/div/div/div[2]/section/div[1]/div/div/input' ], transpond_name, self.driver) sleep(1) Base.click(self, [ By.XPATH, '/html/body/div[3]/div[2]/div/div/div[2]/section/div[1]/ul/li[1]' ], self.driver) # 点击确定 Base.click( self, [By.XPATH, '/html/body/div[3]/div[2]/div/div/div[3]/div/button'], self.driver) # 切换到任少龙界面 sleep(1) Base.click(self, [ By.XPATH, '//*[@id="app"]/div/section/section/div[1]/div/ul[1]/li[1]' ], self.driver) driver.get_screenshot_as_file("E:\\screenshot\\转发.png")
def copy(self): sleep(1) right_click = self.driver.find_element_by_xpath( '//*[@id="scroll-body"]/li/div/div[2]/div/p') # 对定位到的元素执行右击操作 ActionChains(driver).context_click(right_click).perform() # 删除 Base.click( self, [By.XPATH, '//*[@id="message-container"]/ul[2]/li[3]/button'], self.driver) # 模拟鼠标复制(ctrl+v) self.driver.find_element_by_class_name('editor').send_keys( Keys.CONTROL, 'v') sleep(1) self.driver.get_screenshot_as_file("E:\\screenshot\\复制.png") # 将复制内容发送出去 Base.click(self, [ By.XPATH, '//*[@id="app"]/div/section/section/div[2]/div/div[2]/div/div[2]/div[2]/div/button' ], self.driver) self.driver.get_screenshot_as_file("E:\\screenshot\\复制1.png")
def sendWord(self, words): Base.sendKeys(self, [By.CLASS_NAME, "editor"], words, self.driver) Base.click(self, [ By.XPATH, '//*[@id="app"]/div/section/section/div[2]/div/div[2]/div/div[2]/div[2]/div/button' ], self.driver)
def create_combaby_project(self, name, namea): sleep(1) # 点击正式项目管理 Base.click(self, [By.XPATH, "//*[@id='leftBox']/ul/li[2]/ul/li/ul/li[1]"], self.driver) # 点击创建正式项目 Base.click( self, [By.XPATH, "//*[@id='pane-first']/div/div[1]/div/div[1]/button"], self.driver) # 点击创建子项目 Base.click(self, [By.CLASS_NAME, "hasFirm"], self.driver) # 输入项目名称 Base.sendKeys( self, [By.XPATH, '//*[@id="el_main"]/div/form/div[1]/div/div/input'], name, self.driver) # 关联父项目 Base.click(self, [ By.XPATH, '//*[@id="el_main"]/div/form/div[2]/div/div/div[1]/input' ], self.driver) for num in range(1, 8): sleep(1) name1 = driver.find_element_by_xpath( "/html/body/div[2]/div[1]/div[1]/ul/li[" + str(num) + "]/span").text if name1 == str(namea): driver.find_element_by_xpath( "/html/body/div[2]/div[1]/div[1]/ul/li[" + str(num) + "]/span").click() break # 添加子项目成员 for num1 in range(5, 20): ele1 = "//*[@id='el_main']/div/form/div[4]/div/div/div/div[" + str( num1) + "]/p" abc1 = Base.isElementExist(self, ele1) if not abc1: driver.find_element_by_xpath( "//*[@id='el_main']/div/form/div[4]/div/div/div/div[" + str(num1) + "]/img").click() break # 选择天津美腾 sleep(1) for num2 in range(1, 18): ele2 = "/html/body/div[" + str( num2) + "]/div/div[2]/div/div[2]/div/ul/div[1]/li/p" abc2 = Base.isElementExist(self, ele2) if abc2: driver.find_element_by_xpath( "/html/body/div[" + str(num2) + "]/div/div[2]/div/div[2]/div/ul/div[1]/li/p").click() # 选择美腾智冠信息事业部 sleep(1) Base.click(self, [ By.XPATH, "/html/body/div[" + str(num2) + "]/div/div[2]/div/div[2]/div/ul/div[1]/li[2]/p" ], self.driver) # 选择智能工厂研发部 sleep(1) Base.click(self, [ By.XPATH, "/html/body/div[" + str(num2) + "]/div/div[2]/div/div[2]/div/ul/div[1]/li[1]/p" ], self.driver) # 选择web组 sleep(1) Base.click(self, [ By.XPATH, "/html/body/div[" + str(num2) + "]/div/div[2]/div/div[2]/div/ul/div[1]/li[2]/label/span[1]/span" ], self.driver) # 点击确定 Base.click(self, [ By.XPATH, "/html/body/div[" + str(num2) + "]/div/div[3]/span/button[2]" ], self.driver) self.driver.get_screenshot_as_file( "E:\\screenshot\\renyuan.png") # 点击确定 sleep(1) Base.click( self, [By.XPATH, '//*[@id="el_main"]/div/div/div[2]/button[2]'], self.driver) self.driver.get_screenshot_as_file( "E:\\screenshot\\tijiao.png")
def create_company_project(self, name): sleep(1) # 点击正式项目管理 Base.click(self, [By.XPATH, "//*[@id='leftBox']/ul/li[2]/ul/li/ul/li[1]"], self.driver) # 点击创建正式项目 Base.click( self, [By.XPATH, "//*[@id='pane-first']/div/div[1]/div/div[1]/button"], self.driver) # 点击创建新的正式项目 Base.click(self, [ By.XPATH, '//*[@id="pane-first"]/div/div[5]/div/div[2]/div/div[1]' ], self.driver) # 公司项目命名 Base.sendKeys(self, [ By.XPATH, '//*[@id="el_main"]/div/div[1]/div[1]/form/div[1]/div/div/input' ], name, self.driver) Base.click(self, [ By.XPATH, '//*[@id="el_main"]/div/div[1]/div[1]/form/div[1]/label' ], self.driver) r2 = Base.is_alert(self) print(r2) # 选择立项部门 Base.click(self, [ By.XPATH, '//*[@id="el_main"]/div/div[1]/div[1]/form/div[2]/div/div/input' ], self.driver) # 选择公司为立项部门 Base.click(self, [ By.XPATH, '/html/body/div[2]/div/div[2]/div/div[2]/div/ul/div/li/label/span[1]/span' ], self.driver) # 点击确定 Base.click( self, [By.XPATH, '/html/body/div[2]/div/div[3]/span/button[2]/span'], self.driver) # 选择日期 sleep(1) Base.click(self, [ By.XPATH, '//*[@id="el_main"]/div/div[1]/div[1]/form/div[3]/div/div' ], self.driver) sleep(1) Base.click(self, [ By.XPATH, '/html/body/div[3]/div[1]/div/div[2]/table/tbody/tr[7]/td[1]/div/span' ], self.driver) Base.click(self, [ By.XPATH, '/html/body/div[3]/div[1]/div/div[2]/table/tbody/tr[7]/td[1]/div/span' ], self.driver) # 点击下一步 Base.click(self, [By.XPATH, '//*[@id="el_main"]/div/div[2]/button'], self.driver) # 点击下一步 Base.click(self, [By.XPATH, '//*[@id="el_main"]/div/div[2]/button[2]'], self.driver) # 点击下一步 Base.click(self, [By.XPATH, '//*[@id="el_main"]/div/div[2]/button[2]'], self.driver) # 选择承担部门 Base.click(self, [ By.XPATH, '//*[@id="el_main"]/div/div[1]/div[4]/form/div[1]/div/div/input' ], self.driver) Base.click(self, [ By.XPATH, '/html/body/div[4]/div/div[2]/div/div[2]/div/ul/div/li/label/span[1]/span' ], self.driver) # 点击确定 Base.click(self, [By.XPATH, '/html/body/div[4]/div/div[3]/span/button[2]'], self.driver) # 添加人员 sleep(1) Base.click(self, [ By.XPATH, '//*[@id="el_main"]/div/div[1]/div[4]/form/div[3]/div/button' ], self.driver) # 点击天津美腾科技有限公司 Base.click( self, [By.XPATH, '//*[@id="pane-first"]/div/div[2]/div/ul/div[1]/li/p'], self.driver) # 选中综合服务部 Base.click(self, [ By.XPATH, '//*[@id="pane-first"]/div/div[2]/div/ul/div[1]/li[4]/label/span[1]/span' ], self.driver) # 分担职务 Base.click(self, [By.XPATH, '//*[@id="tab-second"]'], self.driver) # 输入内容 Base.sendKeys(self, [By.XPATH, '//*[@id="pane-second"]/div/div/input'], "测试", self.driver) # 选择时间阶段 Base.click(self, [By.XPATH, '//*[@id="tab-third"]'], self.driver) # 选择长期 Base.click(self, [By.XPATH, '//*[@id="pane-third"]/div/p[2]/label/span[2]'], self.driver) # 点击确定 Base.click( self, [By.XPATH, '/html/body/div[5]/div/div[3]/span/button[2]/span'], self.driver) # 项目参与人数 Base.sendKeys(self, [ By.XPATH, '//*[@id="el_main"]/div/div[1]/div[4]/form/div[4]/div/div[1]/input' ], "6", self.driver) # 点击下一步 sleep(1) Base.click(self, [By.XPATH, '//*[@id="el_main"]/div/div[2]/button[2]'], self.driver) # 点击下一步 Base.click(self, [By.XPATH, '//*[@id="el_main"]/div/div[2]/button[2]'], self.driver) # 选择审批人 sleep(1) Base.click(self, [ By.XPATH, '//*[@id="el_main"]/div/div[1]/div[6]/div[2]/div[1]/div/div/img' ], self.driver) # 点击天津美腾科技有限公司 Base.click(self, [ By.XPATH, '/html/body/div[6]/div/div[2]/div/div[2]/div/ul/div[1]/li/p' ], self.driver) # 选择智冠信息事业部 Base.click(self, [ By.XPATH, '/html/body/div[6]/div/div[2]/div/div[2]/div/ul/div[1]/li[2]/p' ], self.driver) # 选择智能工厂研发部 sleep(1) Base.click(self, [ By.XPATH, '/html/body/div[6]/div/div[2]/div/div[2]/div/ul/div[1]/li[1]/p' ], self.driver) # 选择测试组 Base.click(self, [ By.XPATH, '/html/body/div[6]/div/div[2]/div/div[2]/div/ul/div[1]/li[6]/p' ], self.driver) # 选择具体审批人 sleep(1) for num in range(1, 15): name1 = self.driver.find_element_by_xpath( "/html/body/div[6]/div/div[2]/div/div[2]/div/ul/div[2]/li[" + str(num) + "]/label/span[2]/span").text if name1 == '张凯1': self.driver.find_element_by_xpath( "/html/body/div[6]/div/div[2]/div/div[2]/div/ul/div[2]/li[" + str(num) + "]/label/span[2]/span").click() break # 点击确定 Base.click(self, [By.XPATH, '/html/body/div[6]/div/div[3]/span/button[2]'], self.driver) # 选择抄送人 sleep(1) Base.click(self, [ By.XPATH, '//*[@id="el_main"]/div/div[1]/div[6]/div[2]/div[2]/div/div/img' ], self.driver) # 点击天津美腾科技有限公司 Base.click(self, [ By.XPATH, '/html/body/div[7]/div/div[2]/div/div[2]/div/ul/div[1]/li/p' ], self.driver) # 选择智冠信息事业部 Base.click(self, [ By.XPATH, '/html/body/div[7]/div/div[2]/div/div[2]/div/ul/div[1]/li[2]/p' ], self.driver) # 选择智能工厂研发部 sleep(1) Base.click(self, [ By.XPATH, '/html/body/div[7]/div/div[2]/div/div[2]/div/ul/div[1]/li[1]/p' ], self.driver) # 选择测试组 Base.click(self, [ By.XPATH, '/html/body/div[7]/div/div[2]/div/div[2]/div/ul/div[1]/li[6]/label/span[1]/span' ], self.driver) # 点击确定 Base.click(self, [By.XPATH, '/html/body/div[7]/div/div[3]/span/button[2]'], self.driver) # 点击提交 sleep(1) Base.click(self, [By.XPATH, '//*[@id="el_main"]/div/div[2]/button[2]'], self.driver)