def setUpClass(self):#修饰器,最开始执行 #建立连接信息 cnn = Connect() self.driver = cnn.connect() #创建工具类 self.tools = Tools(self.driver)#tools工具 #创建_Yunku_公有定位控件对象 self.yunku = Yunku(self.driver) #创建读取配置信息对象 cf = Config() #获取截图路径、日志路径、日志名 self.screen_path = cf.get_PATH('yunku',"path_001")#通过配置文件获取截图的路径 self.log_path = cf.get_PATH('yunku','log_001')#通过配置文件获取日志的路径 self.filename = cf.get_PATH('yunku','filename_001')#日志文件名 sleep(2)
def test_addContact(self): cnn = Connect() driver = cnn.connect() tools = Tools(driver) #tools工具 cf = Config() screen_path = cf.get_PATH('contact', "path_001") #通过配置文件获取截图的路径 log_path = cf.get_PATH('contact', 'log_001') #通过配置文件获取日志的路径 try: tools.coverUpdate(screen_path) #覆盖更新日志,覆盖更新截图 tools.getLog(log_path) #打印日志 sleep(1) #添加人脉 contact = AddContact() contact.addContact(driver) logging.info("susscess@@!!!!!!") #宣布成功 driver.quit() except Exception as e: tools.getScreenShot(screen_path, 'exception') #截图 logging.info("error@@@@!!!!!!") #打印错误的日志 driver.quit()
def test_delContact(self): cnn = Connect() driver = cnn.connect() tools = Tools(driver) #tools工具 cf = Config() screen_path = cf.get_PATH('contact', "path_003") #通过配置文件获取截图的路径 log_path = cf.get_PATH('contact', 'log_003') #通过配置文件获取日志的路径 try: tools.coverUpdate(screen_path) #覆盖更新日志,覆盖更新截图 tools.getLog(log_path) #打印日志 #删除人脉 contact = DelContact() contact.delContact(driver) #还原人脉 driver.find_element_by_id( "com.yunlu6.stone:id/title_main_back_more_icon").click() #点击返回 driver.find_element_by_name("黑名单").click() #点击黑名单 sleep(1) driver.find_element_by_name("肖静远").click() #点击联系人 sleep(3) driver.find_element_by_id( "com.yunlu6.stone:id/iv_more").click() #右上角下拉框 driver.find_element_by_id( "com.yunlu6.stone:id/ll_recover").click() #点击还原按钮 driver.find_element_by_id( "com.yunlu6.stone:id/title_main_back_more_icon").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回人脉 logging.info("susscess@@!!!!!!") #宣布成功 driver.quit() except Exception as e: tools.getScreenShot(screen_path, 'exception') #截图 logging.info("error@@@@!!!!!!") #打印错误的日志 driver.quit()
def test_browseContact(self): cnn = Connect() driver = cnn.connect() tools = Tools(driver) #tools工具 cf = Config() screen_path = cf.get_PATH('contact', "path_002") #通过配置文件获取截图的路径 log_path = cf.get_PATH('contact', 'log_002') #通过配置文件获取日志的路径 try: tools.coverUpdate(screen_path) #覆盖更新日志,覆盖更新截图 tools.getLog(log_path) #打印日志 #添加人脉 contact = AddContact() contact.addContact(driver) #点击返回人脉列表页面 driver.find_element_by_id( "com.yunlu6.stone:id/title_main_back_more_icon").click() sleep(1) #添加人脉后,刷新人脉列表 driver.swipe(497, 634, 497, 1103) sleep(1) #搜索新增人脉 driver.find_element_by_id( "com.yunlu6.stone:id/img_btn_search").click() driver.find_element_by_id( "com.yunlu6.stone:id/et_search").send_keys(u"肖静远") driver.find_element_by_id("com.yunlu6.stone:id/iv").click() sleep(1) tools.getScreenShot(screen_path, '搜索新增人脉结果') #截图 #查看该人脉相关信息 driver.find_element_by_id("com.yunlu6.stone:id/iv_arrow").click() sleep(2) tools.getScreenShot(screen_path, '查看该人脉名片') #截图 #查看该人脉下的空间 #楚正和珠宝 driver.find_element_by_id("com.yunlu6.stone:id/tv_name").click() sleep(2) tools.getScreenShot(screen_path, '通道设置空间浏览') #截图 logging.info("susscess@@!!!!!!") #宣布成功 driver.quit() #退出 except Exception as e: tools.getScreenShot(screen_path, 'exception') #截图 logging.info("error@@@@!!!!!!") #打印错误的日志 driver.quit()
class yunku_ShangChuan(unittest.TestCase): @classmethod def setUpClass(self):#修饰器,最开始执行 #建立连接信息 cnn = Connect() self.driver = cnn.connect() #创建工具类 self.tools = Tools(self.driver)#tools工具 #创建_Yunku_公有定位控件对象 self.yunku = Yunku(self.driver) #创建读取配置信息对象 cf = Config() #获取截图路径、日志路径、日志名 self.screen_path = cf.get_PATH('yunku',"path_001")#通过配置文件获取截图的路径 self.log_path = cf.get_PATH('yunku','log_001')#通过配置文件获取日志的路径 self.filename = cf.get_PATH('yunku','filename_001')#日志文件名 sleep(2) def test_shangchuan(self): try: self.tools.coverUpdate(self.log_path,self.screen_path)#覆盖更新日志,覆盖更新截图 self.tools.getLog(self.filename)#打印日志 #点击进入云库界面 self.yunku.Jryk().click() sleep(1) self.tools.getScreenShot(self.screen_path,'main')#截图 #右上角下拉框 self.yunku.Yunku_Sgd().click() sleep(1) #点击"+文件" self.yunku.Jwj().click() #选择相册方式添加1张照片 self.yunku.Xc().click()#点击相册 sleep(1) self.tools.getScreenShot(self.screen_path,'本地相册图片')#截图 r = random.randint(0,11) self.yunku.Xc_Zp()[r].click()#点击第1张照片 self.yunku.Complete().click()#点击完成 # driver.implicitly_wait(10)#智能等待10秒 sleep(10) #判断等待 # if self.driver.find_element_by_id("com.yunlu6.stone:id/gridview").is_displayed(): # sleep(20) #通过查看该照片详情删除刚上传的照片 self.tools.getScreenShot(self.screen_path,'上传后云库检查') self.yunku.Yk_Zp()[0].click()#点击第一张照片 self.yunku.Main_menu().click()#点击右上角主菜单 sleep(1) self.yunku.Main_menu_edit().click()#点击右上角主菜单下的编辑 self.yunku.Main_menu_edit_delete().click()#点击删除按钮 sleep(1) self.tools.getScreenShot(self.screen_path,'删除待确认图片') self.yunku.Confirm().click()#点击删除确认按钮 sleep(1) self.tools.getScreenShot(self.screen_path,'删除后云库检查') logging.info("success@@!!!!!!!")#宣布成功 finally: self.tools.getScreenShot(self.screen_path,'finally')#截图 logging.info("finally@@!!!!!!!")#打印错误的日志 self.driver.quit()
def test_gongsi(self): cnn = Connect() driver = cnn.connect() tools = Tools(driver)#tools工具 cf = Config() screen_path = cf.get_PATH('yunku',"path_003")#通过配置文件获取截图的路径 log_path = cf.get_PATH('yunku','log_003')#通过配置文件获取日志的路径 try: tools.coverUpdate(screen_path)#覆盖更新日志,覆盖更新截图 tools.getLog(log_path)#打印日志 sleep(1) #点击进入云库界面 driver.find_element_by_id("com.yunlu6.stone:id/navi_item_work_cloundlibrary").click() sleep(1) tools.getScreenShot(screen_path,'main')#截main图 #右上角下拉框 driver.find_element_by_id("com.yunlu6.stone:id/iv_right_search_cloundlibrary").click() sleep(1) #点击"+文件" driver.find_element_by_id("com.yunlu6.stone:id/btn_pop_cloundlibrary_fragement_upload").click() #选择相册方式添加1张照片 driver.find_element_by_id("com.yunlu6.stone:id/pop_cloundlibrary_tv_album").click()#点击相册 sleep(1) driver.find_elements_by_id("com.yunlu6.stone:id/item_cloudlibrary_ll_checked")[2].click()#点击第四章照片 driver.find_element_by_id("com.yunlu6.stone:id/title_tv_edit_menu_tv").click()#点击完成 #当上传图片加载中提示框消失后,再进行截图操作 # if not driver.find_element_by_id("com.yunlu6.stone:id/ll_loading").is_displayed(): if driver.find_element_by_id("com.yunlu6.stone:id/gridview").is_displayed(): sleep(10) tools.getScreenShot(screen_path,'上传后云库检查')#截图 #点击批量操作,选择第一张照片 driver.find_elements_by_id("com.yunlu6.stone:id/cloudlibrary_image_item")[0].click()#选择第一张照片 driver.find_element_by_id("com.yunlu6.stone:id/title_main_tv_more_menu").click()#点击下拉框 driver.find_element_by_id("com.yunlu6.stone:id/btn_new_space").click()#点击分类 #点击分类到 sleep(1) driver.save_screenshot("C地址拼接:\\Users\\xiaoj\Desktop\screenshot\云库分类公司档\分类到页面检查.png") driver.find_element_by_name("xjy机构").click()#选择分类到xjy机构 driver.find_element_by_name("公司档").click()#选择分类到文件库 driver.find_element_by_id("com.yunlu6.stone:id/title_tv_menu").click()#点击"√"按钮 sleep(1) tools.getScreenShot(screen_path,'分类后云库检查')#截图 #检查xjy机构的文件库是否有刚才传过来的图片 #1.选择空间列表 driver.find_element_by_id("com.yunlu6.stone:id/navi_item_zone").click() #2.选择"xjy机构" driver.find_element_by_name("xjy机构").click() #3.点击公司档 driver.find_element_by_id("com.yunlu6.stone:id/title_main_tv_more_menu").click() driver.find_element_by_id("com.yunlu6.stone:id/btn_pop_company_archivies").click() #4.点击添加公司档 driver.find_element_by_id("com.yunlu6.stone:id/title_tv_menu").click() #5.点击添加照片,选择文件库 driver.find_element_by_id("com.yunlu6.stone:id/iv_add").click() driver.find_element_by_id("com.yunlu6.stone:id/pop_cloundlibrary_tv_wifi_sync").click() sleep(1) tools.getScreenShot(screen_path,'文件库检查')#截图 #6.删除 logging.info("susscess@@!!!!!!")#宣布成功 driver.quit()#退出 except Exception as e: tools.getScreenShot(screen_path,'exception')#截图 logging.info("error@@@@!!!!!!")#打印错误的日志 driver.quit()
def test_labelContact(self): cnn = Connect() driver = cnn.connect() tools = Tools(driver) #tools工具 cf = Config() screen_path = cf.get_PATH('contact', "path_006") #通过配置文件获取截图的路径 log_path = cf.get_PATH('contact', 'log_006') #通过配置文件获取日志的路径 try: tools.coverUpdate(screen_path) #覆盖更新日志,覆盖更新截图 tools.getLog(log_path) #打印日志 #点击人脉列表页面 sleep(2) driver.find_element_by_id( "com.yunlu6.stone:id/navi_item_connection").click() sleep(1) # 15102761413 12345678 #搜索人脉 driver.find_element_by_id( "com.yunlu6.stone:id/img_btn_search").click() driver.find_element_by_id( "com.yunlu6.stone:id/et_search").send_keys(u"金天浩") driver.find_element_by_id("com.yunlu6.stone:id/iv").click() sleep(1) #查看该人脉相关信息 driver.find_element_by_id( "com.yunlu6.stone:id/iv_arrow").click() #点击该人脉 sleep(2) tools.getScreenShot(screen_path, '查看该人脉名片') #截图 #打标签 driver.find_element_by_id( "com.yunlu6.stone:id/iv_more").click() #点击下拉框 driver.find_element_by_id( "com.yunlu6.stone:id/label").click() #点击标签栏 #先做标签检查,如果该联系人有标签,先置为空 try: label = driver.find_element_by_id( "com.yunlu6.stone:id/tag_view_label") label1 = label.find_elements_by_id( "com.yunlu6.stone:id/tag_id") for l in label1[::-1]: #倒序检查 if l.is_enabled(): l.click() except Exception as e: print(e) #---------------------------A连接信息.先打一个标签测试--------------------------- driver.find_element_by_name("同事").click() #点击同事标签 tools.getScreenShot(screen_path, '选中某标签后') #截图 driver.find_element_by_id( "com.yunlu6.stone:id/iv_confirm").click() #确认 #测试点: # 1.重新查看标签中,标签是否打上 # 2.人脉列表搜索,标签筛选功能,是否有该用户(多个标签时再测试) #---1.--- driver.find_element_by_id( "com.yunlu6.stone:id/iv_more").click() #点击下拉框 driver.find_element_by_id( "com.yunlu6.stone:id/label").click() #点击标签栏 sleep(1) tools.getScreenShot(screen_path, '标签检查是否打上') #截图 #此时可以做取消勾选检查,如果打上了的话 driver.find_element_by_id( "com.yunlu6.stone:id/tag_view_label").find_element_by_name( "同事").click() #取消勾选标签 tools.getScreenShot(screen_path, '取消选中某标签后') #截图 driver.find_element_by_id( "com.yunlu6.stone:id/iv_confirm").click() #点击确认 #再次检查取消标签勾选是否生效 driver.find_element_by_id( "com.yunlu6.stone:id/iv_more").click() #点击下拉框 driver.find_element_by_id( "com.yunlu6.stone:id/label").click() #点击标签栏 sleep(1) tools.getScreenShot(screen_path, '标签检查是否取消') #截图 #---------------------------B系统地址.打多个标签测试--------------------------- #测试点: # 1.重新查看标签中,标签是否打上 # 2.人脉列表搜索,标签筛选功能,是否有该用户(多个标签时再测试) driver.find_element_by_name("同事").click() #同事标签 driver.find_element_by_name("朋友").click() #朋友标签 driver.find_element_by_name("职业").click() #职业栏 driver.find_element_by_name("IT互联网").click() #IT互联网标签 driver.find_element_by_name("性格").click() #性格栏 driver.find_element_by_name("不拘小节").click() #不拘小节标签 sleep(1) tools.getScreenShot(screen_path, '打多个标签') #截图 driver.find_element_by_id( "com.yunlu6.stone:id/iv_confirm").click() #点击确认 sleep(2) #---1.---再次确认多标签是否打上 driver.find_element_by_id( "com.yunlu6.stone:id/iv_more").click() #点击下拉框 driver.find_element_by_id( "com.yunlu6.stone:id/label").click() #点击标签栏 #断言检查 id1 = driver.find_element_by_id( "com.yunlu6.stone:id/tag_view_label") #先看标签元素框 label = id1.find_elements_by_id( "com.yunlu6.stone:id/tag_id") #再标签元素框下查找元素 try: self.assertEqual(label[0].text, 'IT互联网', msg="error\n") # print("IT互联网:标签已打上") except Exception as e: print("错误信息:%s" % e) try: self.assertEqual(label[1].text, '不拘小节', msg="error\n") # print("不拘小节:标签已打上") except Exception as e: print("错误信息:%s" % e) try: self.assertEqual(label[2].text, '同事', msg="error\n") # print("同事:标签已打上") except Exception as e: print("错误信息:%s" % e) try: self.assertEqual(label[3].text, '朋友', msg="error\n") # print("朋友:标签已打上") except Exception as e: print("错误信息:%s" % e) sleep(1) tools.getScreenShot(screen_path, '多标签确认') #截图 #---2.---标签筛选分别查看上述几个标签中是否有该人脉 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #返回 #同事、朋友、不拘小节、IT互联网 #检查同事标签 Label = driver.find_elements_by_id("com.yunlu6.stone:id/item_name") driver.find_element_by_name("同事").click() try: for label in Label: if label.text == '金天浩': # print("同事标签:OK") break except Exception as e: print("错误信息:%s" % e) driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #返回上一页 #检查朋友标签 driver.find_element_by_name("朋友").click() try: for label in Label: if label.text == '金天浩': # print("朋友标签:OK") break except Exception as e: print("错误信息:%s" % e) driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #返回上一页 #不拒小节标签检查 driver.find_element_by_id( "com.yunlu6.stone:id/et_search").send_keys(u"不拘小节") driver.find_element_by_id("com.yunlu6.stone:id/iv").click() try: for label in Label: if label.text == '金天浩': # print("不拘小节标签:OK") break except Exception as e: print("错误信息:%s" % e) driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #返回上一页 #IT互联网标签检查 driver.find_element_by_id( "com.yunlu6.stone:id/et_search").send_keys(u"IT互联网") driver.find_element_by_id("com.yunlu6.stone:id/iv").click() try: for label in Label: if label.text == '金天浩': # print("IT互联网标签:OK") break except Exception as e: print("错误信息:%s" % e) driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #返回上一页 #------------------搜索金天浩,取消所有标签,还原状态----------------------- driver.find_element_by_id( "com.yunlu6.stone:id/img_btn_search").click() driver.find_element_by_id( "com.yunlu6.stone:id/et_search").send_keys(u"金天浩") driver.find_element_by_id("com.yunlu6.stone:id/iv").click() sleep(1) #查看该人脉相关信息 driver.find_element_by_id( "com.yunlu6.stone:id/iv_arrow").click() #点击该人脉 sleep(2) #打标签 driver.find_element_by_id( "com.yunlu6.stone:id/iv_more").click() #点击下拉框 driver.find_element_by_id( "com.yunlu6.stone:id/label").click() #点击标签栏 #取消多个标签 label = driver.find_elements_by_id("com.yunlu6.stone:id/tag_id") label[0].click() label[0].click() label[0].click() label[0].click() driver.find_element_by_id( "com.yunlu6.stone:id/iv_confirm").click() #点击确认 sleep(1) tools.getScreenShot(screen_path, '多标签取消确认') #截图 #返回人脉列表 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 logging.info("susscess@@!!!!!!") #宣布成功 driver.quit() #退出 except Exception as e: tools.getScreenShot(screen_path, 'exception') #截图 logging.info("error@@@@!!!!!!") #打印错误的日志 driver.quit()
def test_edit(self): cnn = Connect() driver = cnn.connect() tools = Tools(driver) #tools工具 cf = Config() screen_path = cf.get_PATH('yunku', "path_001") #通过配置文件获取截图的路径 log_path = cf.get_PATH('yunku', 'log_001') #通过配置文件获取日志的路径 try: tools.coverUpdate(screen_path) #覆盖更新日志,覆盖更新截图 tools.getLog(log_path) #打印日志 #上传图片 pic = UploadPic() pic.uploadpic(driver) tools.getScreenShot(screen_path, '上传后云库检查') #截图 #点击云库第一张照片 driver.find_elements_by_id( "com.yunlu6.stone:id/cloudlibrary_image_item")[0].click() driver.find_element_by_id( "com.yunlu6.stone:id/title_main_tv_more_menu").click() #点击下拉框 driver.find_element_by_id( "com.yunlu6.stone:id/btn_share_space").click() #点击"编辑" tools.getScreenShot(screen_path, '编辑页面检查') #截图 #点击编辑框,改名为"产品图片001" driver.find_element_by_id( "com.yunlu6.stone:id/image_edit_et_name").send_keys(u"产品名称001") #填写备注,"产品备注001" driver.find_element_by_id( "com.yunlu6.stone:id/image_edit_et_remark").send_keys( u"产品备注001") #点击保存 driver.save_screenshot( "C:\\Users\\xiaoj\Desktop\screenshot\云库图片编辑\编辑中页面检查.png") driver.find_element_by_id( "com.yunlu6.stone:id/btn_image_edit_save").click() #检查编辑后的输入显示 proname = driver.find_element_by_id( "com.yunlu6.stone:id/title_main_tv_more_title") self.assertEqual(proname.text, "产品名称001", msg="名称不OK") print("-----编辑后:名称检查OK------") proremark = driver.find_element_by_id( "com.yunlu6.stone:id/tv_remark") self.assertEqual(proremark.text, "产品备注001", msg="备注不OK") print("-----编辑后:备注检查OK------") sleep(1) tools.getScreenShot(screen_path, '编辑后页面检查') #截图 #返回云库 driver.find_element_by_id( "com.yunlu6.stone:id/title_main_back_more_icon").click() #删除图片,还原云库 deletepic = DeletePic() deletepic.deletepic(driver) #删除图片后云库检查 tools.getScreenShot(screen_path, '云库删除后检查') #截图 logging.info("susscess@@!!!!!!") #宣布成功 driver.quit() #退出 except Exception as e: tools.getScreenShot(screen_path, 'exception') #截图 logging.info("error@@@@!!!!!!") #打印错误的日志 driver.quit()
class yunku_FenLei(unittest.TestCase): @classmethod def setUpClass(self): #修饰器,最开始执行 #建立连接信息 cnn = Connect() self.driver = cnn.connect() #创建工具类 self.tools = Tools(self.driver) #tools工具 #创建_Yunku_公有定位控件对象 #创建_Space_公有定位控件对象 self.yunku = Yunku(self.driver) self.space = Space(self.driver) #创建读取配置信息对象 cf = Config() #获取截图路径、日志路径、日志名 self.screen_path = cf.get_PATH('yunku', "path_002") #通过配置文件获取截图的路径 self.log_path = cf.get_PATH('yunku', 'log_002') #通过配置文件获取日志的路径 self.filename = cf.get_PATH('yunku', 'filename_002') #日志文件名 sleep(2) def test_fenlei(self): try: self.tools.coverUpdate(self.log_path, self.screen_path) #覆盖更新日志,覆盖更新截图 self.tools.getLog(self.filename) #打印日志 #点击进入云库界面 self.yunku.Jryk().click() sleep(1) self.tools.getScreenShot(self.screen_path, 'main') #截main图 #右上角下拉框 self.yunku.Yunku_Sgd().click() sleep(1) #点击"+文件" self.yunku.Jwj().click() #选择相册方式添加1张照片 self.yunku.Xc().click() #点击相册 sleep(1) self.tools.getScreenShot(self.screen_path, '本地相册图片') #截图 r = random.randint(0, 11) self.yunku.Xc_Zp()[r].click() #随机添加照片 self.yunku.Complete().click() #点击完成 # driver.implicitly_wait(10)#智能等待10秒 sleep(10) #点击上传的图片 #通过查看该照片详情删除刚上传的照片 self.tools.getScreenShot(self.screen_path, '上传后云库检查') self.yunku.Yk_Zp()[0].click() #点击第一张照片 self.yunku.Main_menu().click() #点击右上角主菜单 sleep(1) #点击分类 self.yunku.Main_menu_classify().click() sleep(1) self.tools.getScreenShot(self.screen_path, '分类到页面检查') #选择分类到"xjy机构" self.yunku.Main_menu_classify_xjy_Org().click() #选择分类到产品库 self.yunku.Main_menu_classify_product().click() #点击"√"按钮 self.yunku.Title_tv_menu().click() sleep(1) self.tools.getScreenShot(self.screen_path, '分类后云库检查') #截图 #检查xjy机构的产品库是否有刚才传过来的图片 #1.选择空间列表 self.space.Jrkj().click() #2.选择"xjy机构" self.space.Jrkj_xjy_company_org().click() #3.点击产品列表 self.space.Main_menu().click() #主菜单 self.space.Main_menu_company_product().click() #产品栏 #4.点击添加产品 self.space.Main_menu_company_product_new().click() #新增 #5.点击添加照片,选择产品库 self.space.Main_menu_company_product_new_addphoto().click( ) #点击添加照片 self.space.Main_menu_company_product_new_addphoto_Bywifisync( ).click() #选择产品库 sleep(1) self.tools.getScreenShot(self.screen_path, '产品库检查') #截图 logging.info("susscess@@!!!!!!") #宣布成功 finally: self.tools.getScreenShot(self.screen_path, 'finally') #截图 logging.info("finally@@!!!!!!!") #打印错误的日志 self.driver.quit()
def test_talkContact(self): #连接信息 cnn = Connect() driver = cnn.connect() tools = Tools(driver) #tools工具 cf = Config() screen_path = cf.get_PATH('contact', "path_005") #通过配置文件获取截图的路径 log_path = cf.get_PATH('contact', 'log_005') #通过配置文件获取日志的路径 try: tools.coverUpdate(screen_path) #覆盖更新日志,覆盖更新截图 tools.getLog(log_path) #打印日志 #点击人脉列表页面 driver.find_element_by_id( "com.yunlu6.stone:id/navi_item_connection").click() sleep(1) # 15102761413 12345678 #搜索新增人脉 driver.find_element_by_id( "com.yunlu6.stone:id/img_btn_search").click() driver.find_element_by_id( "com.yunlu6.stone:id/et_search").send_keys(u"金天浩") driver.find_element_by_id("com.yunlu6.stone:id/iv").click() sleep(1) #查看该人脉相关信息 driver.find_element_by_id("com.yunlu6.stone:id/iv_arrow").click() sleep(2) tools.getScreenShot(screen_path, '查看该人脉名片') #截图 #点击单人会话按钮,开始会话 driver.find_element_by_id("com.yunlu6.stone:id/edit_text").click() sleep(1) driver.find_element_by_id( "com.yunlu6.stone:id/message_content_msgcontent").send_keys( u"你好") #发消息 driver.find_element_by_id( "com.yunlu6.stone:id/iv_emoji").click() #点击表情包按钮 sleep(1) driver.find_elements_by_id( "com.yunlu6.stone:id/item_iv_face")[0].click() #选择第一个表情 driver.find_element_by_id( "com.yunlu6.stone:id/message_content_send").click() #点击发送 tools.getScreenShot(screen_path, '发送消息页面') #截图 #返回人脉列表 driver.find_element_by_id( "com.yunlu6.stone:id/title_main_more_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 #----------------------------------登录另一个账号查看---------------------------------------- #换完名片之后,要去另一个账号检查是否成功收到消息 logout = Logout() logout.userLogout(driver) sleep(1) login = Login() login.userLogin(driver, 15102761413, 12345678) sleep(1) # text = driver.find_element_by_class_name("android.widget.TextView")#获取会话条数 # self.assertEqual(text.text,'2',msg="条数显示错误")#检查会话条数显示是否正确 # print("-----------会话消息条数显示有误--------------") driver.find_element_by_id( "com.yunlu6.stone:id/icon_message").click() #点击会话按钮 driver.save_screenshot( "C:\\Users\\xiaoj\Desktop\screenshot\人脉单人会话\收到会话消息.png" ) #后期要调整的 driver.find_element_by_id( "com.yunlu6.stone:id/msgitem_arrow").click() tools.getScreenShot(screen_path, '单人会话详情页') #截图,后期要调整的 #返回主页面 driver.find_element_by_id( "com.yunlu6.stone:id/title_main_more_back").click() #返回 driver.find_element_by_id( "com.yunlu6.stone:id/buildstione_backe").click() #返回 #------------------------------------退出当前账号,登录原始账号------------------------------- logout = Logout() logout.userLogout(driver) sleep(1) login = Login() login.userLogin(driver, 13027104206, 12345678) sleep(1) logging.info("susscess@@!!!!!!") #宣布成功 driver.quit() #退出 except Exception as e: tools.getScreenShot(screen_path, 'exception') #截图 logging.info("error@@@@!!!!!!") #打印错误的日志 driver.quit()
def test_excContact(self): cnn = Connect() driver = cnn.connect() tools = Tools(driver)#tools工具 cf = Config() screen_path = cf.get_PATH('contact',"path_004")#通过配置文件获取截图的路径 log_path = cf.get_PATH('contact','log_004')#通过配置文件获取日志的路径 try: tools.coverUpdate(screen_path)#覆盖更新日志,覆盖更新截图 tools.getLog(log_path)#打印日志 #点击搜索框,搜索"肖静远" sleep(2) driver.find_element_by_id("com.yunlu6.stone:id/navi_item_connection").click()#点击人脉列表 driver.find_element_by_id("com.yunlu6.stone:id/img_btn_search").click()#搜索框 driver.find_element_by_id("com.yunlu6.stone:id/et_search").send_keys(u"肖静远") driver.find_element_by_id("com.yunlu6.stone:id/iv").click() sleep(1) tools.getScreenShot(screen_path,'搜索结果')#截图 #点击搜索出来的联系人 sleep(2) driver.find_element_by_id("com.yunlu6.stone:id/iv_arrow").click()#点击联系人 sleep(2) driver.find_element_by_id("com.yunlu6.stone:id/iv_more").click()#下拉框 driver.find_element_by_id("com.yunlu6.stone:id/card_exchange").click()#名片设置 sleep(1) tools.getScreenShot(screen_path,'名片设置界面')#截图 #点击预览,发送 driver.find_element_by_name("预览").click() driver.find_element_by_name("发送名片").click() sleep(1) tools.getScreenShot(screen_path,'发送名片成功')#截图 #返回到人脉首页 driver.find_element_by_id("com.yunlu6.stone:id/iv_back").click()#点击返回 driver.find_element_by_id("com.yunlu6.stone:id/iv_back").click()#点击返回 driver.find_element_by_id("com.yunlu6.stone:id/iv_back").click()#点击返回 #----------------------------------登录另一个账号查看---------------------------------------- #换完名片之后,要去另一个账号检查是否成功收到消息 logout = Logout() logout.userLogout(driver) sleep(1) login = Login() login.userLogin(driver,17607136211,12345678) sleep(1) tools.getScreenShot(screen_path,'申请截图')#截图,后期要调整的 #------------------------------------退出当前账号,登录原始账号------------------------------- logout = Logout() logout.userLogout(driver) sleep(1) login = Login() login.userLogin(driver,13027104206,12345678) sleep(1) logging.info("susscess@@!!!!!!")#宣布成功 driver.quit()#退出 except Exception as e: tools.getScreenShot(screen_path,'exception')#截图 logging.info("error@@@@!!!!!!")#打印错误的日志 driver.quit()
def test_groupchatContact(self): cnn = Connect() driver = cnn.connect() tools = Tools(driver) #tools工具 cf = Config() screen_path = cf.get_PATH('contact', "path_001") #通过配置文件获取截图的路径 log_path = cf.get_PATH('contact', 'log_001') #通过配置文件获取日志的路径 try: tools.coverUpdate(screen_path) #覆盖更新日志,覆盖更新截图 tools.getLog(log_path) #打印日志 #点击人脉列表页面 sleep(2) driver.find_element_by_id( "com.yunlu6.stone:id/navi_item_connection").click() sleep(1) # 15102761413 12345678 #搜索人脉 driver.find_element_by_id( "com.yunlu6.stone:id/img_btn_search").click() driver.find_element_by_id( "com.yunlu6.stone:id/et_search").send_keys(u"金天浩") driver.find_element_by_id("com.yunlu6.stone:id/iv").click() sleep(1) #查看该人脉相关信息 driver.find_element_by_id( "com.yunlu6.stone:id/iv_arrow").click() #点击该人脉 sleep(2) tools.getScreenShot(screen_path, '查看该人脉名片') #截图 #打标签 driver.find_element_by_id( "com.yunlu6.stone:id/iv_more").click() #点击下拉框 driver.find_element_by_id( "com.yunlu6.stone:id/label").click() #点击标签栏 #---------------------------先打一个标签测试--------------------------- driver.find_element_by_name("同事").click() #点击同事标签 tools.getScreenShot(screen_path, '选中某标签后') #截图 driver.find_element_by_id( "com.yunlu6.stone:id/iv_confirm").click() #确认 #返回人脉列表 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 #-------------------------按标签"同事"进行群聊------------------------- #1.点击搜索框 driver.find_element_by_id( "com.yunlu6.stone:id/img_btn_search").click() #2.点击"同事标签" driver.find_element_by_name("同事").click() tools.getScreenShot(screen_path, '标签下人脉') #截图 #3.点击群聊入口,并发送消息 driver.find_element_by_name("点击进入群聊").click() sleep(1) tools.getScreenShot(screen_path, '群聊界面') #截图 #4.发消息 driver.find_element_by_id( "com.yunlu6.stone:id/message_content_msgcontent").send_keys( u"你好") #发消息 driver.find_element_by_id( "com.yunlu6.stone:id/iv_emoji").click() #点击表情包按钮 sleep(1) driver.find_elements_by_id( "com.yunlu6.stone:id/item_iv_face")[0].click() #选择第一个表情 driver.find_element_by_id( "com.yunlu6.stone:id/message_content_send").click() #点击发送 tools.getScreenShot(screen_path, '发送消息页面') #截图 #5.查看群成员列表 driver.find_element_by_id( "com.yunlu6.stone:id/iv_to_message").click() #点击群成员图标 sleep(1) tools.getScreenShot(screen_path, '群成员列表') #截图 #6.返回人脉列表 driver.find_element_by_id( "com.yunlu6.stone:id/title_main_more_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/title_main_more_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 driver.find_element_by_id( "com.yunlu6.stone:id/iv_back").click() #点击返回 #----------------------------------登录另一个账号查看---------------------------------------- #群聊发送消息后,要去另一个账号检查是否成功收到消息 logout = Logout() logout.userLogout(driver) sleep(1) login = Login() login.userLogin(driver, 15102761413, 12345678) sleep(1) tools.getScreenShot(screen_path, 'main页') #截图,后期调整 driver.find_element_by_id( "com.yunlu6.stone:id/icon_message").click() #点击会话按钮 tools.getScreenShot(screen_path, '收到会话消息') #截图 driver.find_element_by_id( "com.yunlu6.stone:id/msgitem_arrow").click() tools.getScreenShot(screen_path, '单人会话详情页') #截图 #返回主页面 driver.find_element_by_id( "com.yunlu6.stone:id/title_main_more_back").click() #返回 driver.find_element_by_id( "com.yunlu6.stone:id/buildstione_backe").click() #返回 #------------------------------------退出当前账号,登录原始账号------------------------------- logout = Logout() logout.userLogout(driver) sleep(1) login = Login() login.userLogin(driver, 13027104206, 12345678) sleep(1) #-----------------------取消人脉标签,还原至初始状态----------------------- sleep(2) driver.find_element_by_id( "com.yunlu6.stone:id/navi_item_connection").click() #搜索人脉 driver.find_element_by_id( "com.yunlu6.stone:id/img_btn_search").click() driver.find_element_by_id( "com.yunlu6.stone:id/et_search").send_keys(u"金天浩") driver.find_element_by_id("com.yunlu6.stone:id/iv").click() sleep(1) #查看该人脉相关信息 driver.find_element_by_id( "com.yunlu6.stone:id/iv_arrow").click() #点击该人脉 sleep(2) tools.getScreenShot(screen_path, '查看该人脉名片') #截图 #取消标签 driver.find_element_by_id( "com.yunlu6.stone:id/iv_more").click() #点击下拉框 driver.find_element_by_id( "com.yunlu6.stone:id/label").click() #点击标签栏 driver.find_elements_by_id( "com.yunlu6.stone:id/tag_id")[0].click() #取消标签 driver.find_element_by_id( "com.yunlu6.stone:id/iv_confirm").click() #勾选 #检查一下取消标签后的效果 driver.find_element_by_id( "com.yunlu6.stone:id/iv_more").click() #下拉框 driver.find_element_by_id("com.yunlu6.stone:id/label").click() #标签 sleep(1) tools.getScreenShot(screen_path, '取消标签检查') #截图 logging.info("susscess@@!!!!!!") #宣布成功 driver.quit() #退出 except Exception as e: tools.getScreenShot(screen_path, 'exception') #截图 logging.info("error@@@@!!!!!!") #打印错误的日志 driver.quit()