def health_summarize(dr, content): dr.XPath_click("//span[text()='编辑信息']") dr.frame(dr.XPath_get("//iframe[@allowtransparency='true']")) dr.tag_name_clear("body") # 输入文章内容 dr.tag_name_click("body") # 输入文章内容 dr.frame_return() dr.XPaths_array_click("//span[text()='确 定']", -1) if dr.XPath_get("//p[text()='内容不能为空']"): print("内容不能为空") myLog.info("内容不能为空") else: print("与预期不符,内容可以为空") myLog.error("与预期不符,内容可以为空") raise dr.frame(dr.XPath_get("//iframe[@allowtransparency='true']")) dr.tag_name_sendkey("body", content) # 输入文章内容 dr.frame_return() dr.XPaths_array_click("//span[text()='确 定']", -1) sleep(5) dr.screenshot( r"C:\Users\Administrator\Desktop\beiting_script\image\卫生管理概述.png") expect = Image.open( r"C:\Users\Administrator\Desktop\beiting_script\image\卫生管理概述True.png") practical = Image.open( r"C:\Users\Administrator\Desktop\beiting_script\image\卫生管理概述.png") Image_1 = operator.eq(expect, practical) if Image_1 == True: print("图片比对结果相同,修改卫生管理概述成功") myLog.info("图片比对结果相同,修改卫生管理概述成功") else: print("图片比对结果不同,修改卫生管理概述失败") myLog.error("图片比对结果不同,修改卫生管理概述失败")
def party_add(dr, title, content): #文章类型(党建活动、学习资料、三会一课、主题党日)、标题、内容、是否发布 # dr.XPath_click("//span[text()='党务管理']") # dr.XPath_click("//span[text()='党建内容']") for i in range(4): if i == 0: type = "党建活动" send = random.choice([True, False]) elif i == 1: type = "学习资料" send = random.choice([True, False]) elif i == 2: type = "三会一课" send = random.choice([True, False]) elif i == 3: type = "主题党日" send = random.choice([True, False]) dr.XPath_click("//span[text()='写文章']") dr.Class_name_s_sendkey("el-input__inner", title + type, 5) #输入文章标题 dr.Class_name_s_click("el-input__inner", 6) dr.XPaths_array_click("//span[text()='" + type + "']", -1) #选择文章类型 if send == True: dr.XPath_click("//span[text()='是']") elif send == False: dr.XPath_click("//span[text()='否']") dr.frame("textEditDialog_ifr") dr.tag_name_sendkey("body", "" + content + "") #输入文章内容 dr.frame_return() dr.XPaths_array_click("//span[text()='确 定']", 2) if dr.XPath_get("//span[text()='" + title + type + "']"): print("" + title + type + "创建成功") myLog.info("" + title + type + "创建成功") else: print("" + title + type + "创建失败") myLog.error("" + title + type + "创建失败")
def case(self): if dr.XPath_text("//*[contains(text(),'阳光党建,智慧北亭')]"): print("登录成功") myLog.info("登录成功") else: print("登录失败") myLog.info("登录失败") raise
def health_area_alter(dr): dr.XPaths_array_click("//span[text()='修改片区']", -1) dr.Class_name_s_sendkey("el-input__inner", "自动化片区二区_修改", 1) dr.XPaths_array_click("//span[text()='确 定']", -1) if dr.XPath_get("//span[text()='自动化片区二区_修改']"): print("卫生片区修改成功") myLog.info("卫生片区修改成功") else: print("卫生片区创建失败") myLog.error("卫生片区修改失败") raise
def case_1_login(self): """用户登录测试用例""" dr = self.dr self.dr.open(self.URL) dr.XPath_get("//div[contains(text(),'广州大学城小谷围街道北亭村信息平台(阳光北亭)')]") dr.Name_sendkey("username", "admin") dr.Name_sendkey("password", "12345678") dr.XPath_click("//span[contains(text(),'登录')]") if dr.XPath_text("//*[contains(text(),'阳光党建,智慧北亭')]"): print("登录成功") myLog.info("登录成功") else: print("登录失败") myLog.info("登录失败") raise
def health_area_del(dr): dr.XPath_click("//div[text()='卫生片区']") if dr.XPath_get("//span[text()='片区管理']"): dr.XPath_click("//span[text()='片区管理']") for i in range(2): delete = dr.XPaths_get("//span[text()='删除']") dr.XPaths_array_click("//span[text()='删除']", -1) dr.XPaths_array_click("//span[contains(text(),'确定')]", -1) sleep(2) compare = dr.XPaths_get("//span[text()='删除']") if len(delete) != len(compare): print("片区删除成功") myLog.info("片区删除成功") else: print("片区删除失败") myLog.error("片区删除失败") raise
def site_area_alter(dr): dr.XPath_click("//div[text()='卫生片区']") if dr.XPath_get("//span[text()='返回']"): dr.XPath_click("//span[text()='返回']") dr.XPath_click("//span[text()='修改所处片区']") dr.Class_name_s_click("el-input__suffix", -1) # dr.XPaths_array_click("//input[text()='请选择' and ]",-1) dr.XPaths_array_click("//span[text()='自动化片区一区']", -1) dr.XPaths_array_click("//span[text()='确 定']", -1) if dr.XPath_get("//span[text()='自动化片区一区']"): if dr.XPath_get("//span[text()='修改所处片区']"): print("修改所处片区成功") myLog.info("修改所处片区成功") else: print("修改所处片区失败") myLog.error("修改所处片区失败") raise
def party_del(dr, title): # dr.XPath_click("//span[text()='党务管理']") # dr.XPath_click("//span[text()='党建内容']") dr.Class_name_s_sendkey("el-input__inner", title, 2) dr.XPath_click("//span[text()='搜索文章']") delete = dr.XPaths_get("//span[text()='删除']") mark = len(delete) print("标题包含“自动化文章”的文章数量:", mark) for i in range(mark): dr.XPath_click("//span[text()='删除']") dr.XPath_click("//span[contains(text(),'确定')]") sleep(2) mark = dr.XPaths_get("//span[contains(text(),'自动化文章')]") if len(mark) == 0: print("标题包含“自动化文章”的文章数量:", len(mark)) myLog.info("文章删除成功") print("文章删除成功") else: myLog.error("文章删除失败") print("文章删除失败")
def party_in_check(dr): """*********************文章类型为空**********************""" dr.Class_name_s_sendkey("el-input__inner", "自动化文章标题", 5) # 输入文章标题 dr.frame("textEditDialog_ifr") dr.tag_name_sendkey("body", "自动化文章内容") # 输入文章内容 dr.frame_return() dr.XPaths_array_click("//span[text()='确 定']", 2) i = 1 if dr.XPath_get("//div[contains(text(),'请选择目录')]"): print("文章类型不能为空") myLog.info("文章类型不能为空") else: print("与预期不符,文章类型可以为空") myLog.error("与预期不符,文章类型可以为空") """*********************文章标题为空**********************""" if i == 1: dr.XPaths_array_click("//span[text()='取 消']", 2) dr.XPath_click("//span[text()='写文章']") dr.Class_name_s_click("el-input__inner", 6) dr.XPaths_array_click("//span[text()='党建活动']", -1) # 选择文章类型 dr.frame("textEditDialog_ifr") dr.tag_name_sendkey("body", "自动化文章内容") # 输入文章内容 dr.frame_return() dr.XPaths_array_click("//span[text()='确 定']", 2) i = 2 if dr.XPath_get("//div[contains(text(),'请输入标题名称')]"): print("文章标题不能为空") myLog.info("文章标题不能为空") else: print("与预期不符,文章标题可以为空") myLog.error("与预期不符,文章标题可以为空") """*********************文章内容为空**********************""" if i == 2: dr.Class_name_s_sendkey("el-input__inner", "自动化文章标题", 5) # 输入文章标题 dr.Class_name_s_click("el-input__inner", 6) dr.XPaths_array_click("//span[text()='党建活动']", -1) # 选择文章类型 dr.frame("textEditDialog_ifr") dr.tag_name_clear("body") # 清空文章内容 dr.tag_name_click("body") dr.frame_return() sleep(2) dr.XPaths_array_click("//span[text()='确 定']", 2) if dr.XPath_get("//p[contains(text(),'文章内容不能为空')]"): print("文章内容不能为空") myLog.info("文章内容不能为空") else: print("与预期不符,文章内容可以为空") myLog.error("与预期不符,文章内容可以为空")
def health_area_add(dr): dr.XPath_click("//div[text()='卫生片区']") dr.XPath_click("//span[text()='片区管理']") dr.XPath_click("//span[text()='新增片区']") for i in range(3): if i == 0: dr.XPaths_array_click("//span[text()='确 定']", 2) if dr.XPath_get("//div[contains(text(),'请输入片区名称')]"): print("片区名称不能为空") myLog.info("片区名称不能为空") else: print("与预期不同,没有提示请输入片区名称") myLog.error("与预期不同,没有提示请输入片区名称") dr.XPaths_array_click("//span[text()='取 消']", 2) elif i == 1: dr.XPath_click("//span[text()='新增片区']") dr.Class_name_sendkey("el-input__inner", "自动化片区一区") dr.XPaths_array_click("//span[text()='确 定']", 2) if dr.XPath_get("//span[text()='自动化片区一区']"): print("卫生片区创建成功") myLog.info("卫生片区创建成功") else: print("卫生片区创建失败") myLog.error("卫生片区创建失败") raise elif i == 2: sleep(3) dr.XPath_click("//span[text()='新增片区']") dr.Class_name_sendkey("el-input__inner", "自动化片区二区") dr.XPaths_array_click("//span[text()='确 定']", 2) if dr.XPath_get("//span[text()='自动化片区二区']"): print("卫生片区创建成功") myLog.info("卫生片区创建成功") else: print("卫生片区创建失败") myLog.error("卫生片区创建失败") raise