class Main(unittest.TestCase): def setUp(self): warnings.simplefilter("ignore", ResourceWarning) self.driver = webdriver.Chrome() self.baseCom = BaseCommon(self.driver) self.baseCom.maxBroswer() self.data = unit().operaYaml( 'C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/login.yaml' ) self.weadmin_login = Login(self.driver) self.baseCom.openUrl(self.data['url']['webadmin']) #输入正确的用户名及密码 @ddt.data(*readExcel) @ddt.unpack def test_login(self, username, password, result): self.baseCom.untilTime("XPATH", self.data["login"]["username"]) self.weadmin_login.userName().send_keys(username) self.baseCom.untilTime("XPATH", self.data["login"]["password"]) self.weadmin_login.password().send_keys(password) self.baseCom.untilTime("XPATH", self.data["login"]["login-btn"]) self.weadmin_login.login_Btn().click() time.sleep(2) self.assertEqual( self.driver.find_element_by_xpath( self.data["msg-content_username"]).text, result) #只输入用户名,不输入密码 #def test_login_username(self): #self.weadmin_login.webadmin_Login_username() #self.baseCom.untilTime("XPATH",self.data["msg-content_username"]) #self.assertEqual(self.driver.find_element_by_xpath(self.data['msg-content_username']).text,self.assertData['login_username']) #只输入密码,不输入用户名 #def test_login_password(self): #self.weadmin_login.webadmin_Login_password() #self.assertEqual(self.driver.find_element_by_xpath(self.data['msg-content_password']).text,self.assertData['login_password']) #不输入密码及用户名 #def test_login_Null(self): #self.weadmin_login.webadmin_Login_Allnull() #self.baseCom.untilTime("XPATH",self.data["All_Null"]) #time.sleep(3) #self.assertEqual(self.driver.find_element_by_xpath(self.data['All_Null']).text,self.assertData['login_password']) #输入错误的用户名及密码 #def test_login_all_Error(self): #self.weadmin_login.webadmin_Login_All_Errror() #self.assertEqual(self.driver.find_element_by_xpath(self.data['msg-content_AllError']).text,self.assertData['login_AllError']) #客服登录系统 #def test_cus_login(self): #self.weadmin_login.webcustomer_login() #self.assertEqual(self.driver.find_element_by_xpath(self.data['myContent']).text,self.assertData['myContent']) def tearDown(self): self.baseCom.quitBrowser()
class transfer_To_labor(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.basecom = BaseCommon(self.driver) self.basecom.maxBroswer() self.data = unit().operaYaml( "C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/login.yaml" ) self.basecom.openUrl(self.data["url"]["webadmin"]) self.Transfer_To_labor = transfer_to_labor(self.driver) def test_transfer_To_Labor(self): result = self.Transfer_To_labor.Transfertolabor() self.assertIsNotNone(result) def test_send_news_text(self): result = self.Transfer_To_labor.send_news_text() self.assertEqual(result, "你好,我是小弟弟,你是谁") def test_send_expression(self): result = self.Transfer_To_labor.send_news_expression() self.assertIsNotNone(result, msg="有问题,请找管理员处理一下") def test_send_vidio(self): result = self.Transfer_To_labor.send_news_vidio() self.assertIsNotNone(result, msg="出问题了,请来查看") def test_send_docx(self): result = self.Transfer_To_labor.send_news_docx() self.assertEqual(result, "点击下载文件 > test.docx") def test_send_audio(self): result = self.Transfer_To_labor.send_news_audio() self.assertIsNotNone(result, msg="出现问题,请及时处理") def test_send_Satisfacted_Invite(self): result = self.Transfer_To_labor.send_Satisfacted_Invite() self.assertEqual(result, "一般") def test_send_summary(self): result = self.Transfer_To_labor.send_summary() self.assertEqual(result, "俺乃燕人张翼得,尔等还不速速离去") def test_send_picture(self): result = self.Transfer_To_labor.send_news_picture() self.assertIsNotNone(result, msg="出现问题,请前来查看") def test_create_chat_group(self): result = self.Transfer_To_labor.create_chat_group() self.assertEqual(result, '讨论组(1)') def tearDown(self): self.basecom.quitBrowser()
class Main(unittest.TestCase): def setUp(self): warnings.simplefilter("ignore", ResourceWarning) self.driver = webdriver.Chrome() self.baseCom = BaseCommon(self.driver) self.baseCom.maxBroswer() self.data = unit().operaYaml( 'C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/login.yaml' ) #self.weadmin_login = login(self.driver) self.time_search = ServerSatisficing(self.driver) self.severSatisFicing = serverSatisficing(self.driver) self.baseCom.openUrl(self.data['url']['webadmin']) self.assertData = unit().operaYaml( 'C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/Assert.yaml' ) #时间查询 def test_Time_Seach(self): #登录访客端 # self.weadmin_login.weadmin_Login() #time.sleep(3) #时间查询 self.time_search.timeSearch() #aeert=self.severSatisFicing.allListCount().text self.assertIsNotNone(self.severSatisFicing.allListCount().text, msg="有问题,请及时查看") #满意度查询 def test_very_Dissatisfied(self): #self.time_search.timeSearch() #time.sleep(3) self.time_search.very_Dissatisfied() time.sleep(3) self.assertEqual(self.severSatisFicing.list_Satisfied().text, "非常不满意") def test_dissatisfied(self): self.time_search.dissatisfied() time.sleep(3) self.assertEqual(self.severSatisFicing.list_Satisfied().text, "不满意") def test_commonly(self): self.time_search.commonly() time.sleep(3) self.assertEqual(self.severSatisFicing.list_Satisfied().text, "一般") def test_satisfied(self): self.time_search.satisfied() time.sleep(3) self.assertEqual(self.severSatisFicing.list_Satisfied().text, "满意") def test_very_Satisfied(self): self.time_search.very_Satisfied() time.sleep(3) self.assertEqual(self.severSatisFicing.list_Satisfied().text, "非常满意") #客服查询 def test_customer_search(self): self.time_search.customer_Search() time.sleep(3) self.assertEqual(self.severSatisFicing.list_customer().text, "思思") #导出功能 def test_down_loade(self): self.time_search.down_loade() try: file = xlrd.open_workbook("C:/Users/yunwen/Downloads/客服满意度.xls") sheet = file.sheet_by_name("Sheet1") nrows = sheet.nrows for i in range(nrows): a = sheet.row_values(i)[0] cls.append(a) print(cls) except Exception as e: print(e) for infile in glob(os.path.join("C:/Users/yunwen/Downloads", "客服满意度*")): os.remove(infile) self.assertIn(self.severSatisFicing.visitorId().text, cls) #查看聊天记录 def test_look_message(self): self.time_search.look_message() self.assertIsNotNone(self.severSatisFicing.message_visitorId().text, msg="出现问题,请查看") def tearDown(self): self.baseCom.quitBrowser()
class Main(unittest.TestCase): def setUp(self): warnings.simplefilter("ignore", ResourceWarning) self.driver = webdriver.Chrome() self.baseCom = BaseCommon(self.driver) self.baseCom.maxBroswer() self.chatRecord = Chat_Record(self.driver) self.record_Chat = chatRecord(self.driver) self.data = unit().operaYaml( 'C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/login.yaml' ) self.baseCom.openUrl(self.data['url']['webadmin']) def test_time_search(self): self.chatRecord.time_search() self.assertIsNotNone(self.record_Chat.list_Count().text, msg="出问题了,快来产看") def test_channel_search(self): self.chatRecord.search_channel() self.assertIsNotNone(self.record_Chat.list_Count().text, msg="出问题了,快来查看一下") def test_satisfic_search(self): self.chatRecord.statisfic_search() self.assertIsNotNone(self.record_Chat.list_Count().text, msg="出问题了,快来查看一下") def test_group_search(self): result = self.chatRecord.group_search() self.assertEqual(result, "售前客服") def test_agent_search(self): result = self.chatRecord.agent_search() self.assertEqual(result, "思思") def test_visitorName_search(self): result = self.chatRecord.visitorName_search() self.assertEqual(result[0], result[1]) def test_exportChatRecord(self): cls = [] result = self.chatRecord.exportChatRecord() try: file = xlrd.open_workbook("C:/Users/yunwen/Downloads/聊天记录.xlsx") sheet = file.sheet_by_name("Sheet1") nrows = sheet.nrows for i in range(nrows): a = sheet.row_values(i)[1] print(a) cls.append(a) print(cls) except Exception as e: print(e) finally: self.assertIn(result, cls) for infile in glob(os.path.join("C:/Users/yunwen/Downloads", "聊天记录*")): os.remove(infile) #self.assertIn(result,cls) def test_View_chat_history(self): result = self.chatRecord.View_chat_history() self.assertEqual(result[0], result[1]) def tearDown(self): self.baseCom.closeBrowser()
class main(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.basecom = BaseCommon(self.driver) self.basecom.maxBroswer() self.data = unit().operaYaml( 'C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/login.yaml' ) self.basecom.openUrl(self.data['url']['webadmin']) self.serviceSummary = Sevice_Summary(self.driver) self.seviceSummary_data = unit().operaYaml( "C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/service_Summary.yaml" ) def test_tineSearch(self): result = self.serviceSummary.time_search() self.assertIsNotNone(result, msg="出现bug,请前往查看") def test_visitorNameSearch(self): result = self.serviceSummary.visitor_Name_sarch() self.assertEqual(result[0], result[1]) def test_remark_search(self): result = self.serviceSummary.remark_search() self.assertEqual(result[0], result[1]) def test_export(self): cls = [] result = self.serviceSummary.export() try: file = xlrd.open_workbook("C:/Users/yunwen/Downloads/服务小结.xlsx") sheet = file.sheet_by_name("Sheet1") nrows = sheet.nrows for i in range(nrows): a = sheet.row_values(i)[0] print(a) cls.append(a) print(cls) except Exception as e: print(e) finally: self.assertIn(result, cls) for infile in glob(os.path.join("C:/Users/yunwen/Downloads", "服务小结*")): os.remove(infile) def test_view_chatMessage(self): result = self.serviceSummary.view_chatMessage() self.assertIsNot(result, "暂无聊天记录") @ddt.data(*readExcel) @ddt.unpack def test_add_service_type(self, inputData, Result): fially_result = self.serviceSummary.add_service_type(inputData) #self.serviceSummary.delect_service_type() self.assertEqual(Result, fially_result) #self.serviceSummary.delect_service_type() #def test_delect_service_type(self): #self.serviceSummary.delect_service_type() def tearDown(self): self.basecom.quitBrowser()