예제 #1
0
class TestDeleteItem(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.basecommon = BaseCommon(self.driver)
        self.mlogin = Mylogin(self.driver)
        self.data = Util().operateYaml(
            "../data/jkData/pageData.yaml")  # 取到yaml里边的所有数据
        self.driver.get(self.data['login']['url'])

    def tearDown(self):
        filedir = "D:/test/screenshot/"
        if not os.path.exists(filedir):
            os.makedirs(os.path.join('D:/', 'test', 'screenshot'))
        screen_name = filedir + time.strftime(
            '%Y-%m-%d-%H-%M-%S', time.localtime(time.time())) + ".png"
        self.basecommon.screenshot(screen_name)
        self.driver.quit()

    def testJenkins01_02(self):
        time.sleep(2)
        self.mlogin.login()
        print "success......."
        self.taskdata = Util().operateYaml(
            "../data/jkData/newTaskData.yaml")  # 取到yaml里边的所有数据
        self.driver.find_element_by_link_text(
            self.taskdata['newtask']['newtask_01']['tasktitle']).click()
        self.driver.implicitly_wait(3)
        self.driver.find_element_by_xpath(
            self.taskdata['newtask']['newtask_02']['deletebutton']).click()
        alert1 = self.driver.switch_to.alert
        alert1.accept()
예제 #2
0
class Testlogin(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.basecommon = BaseCommon(self.driver)
        self.mlogin = Mylogin(self.driver)
        self.data = Util().operateYaml(
            "../data/pageData/pageData.yaml")  #取到yaml里边的所有数据
        self.driver.get(self.data['login']['url'])

    def tearDown(self):

        filedir = "D:/test/screenshot/"
        if not os.path.exists(filedir):
            os.makedirs(os.path.join('D:/', 'test', 'screenshot'))
        screen_name = filedir + time.strftime(
            '%Y-%m-%d-%H-%M-%S', time.localtime(time.time())) + ".png"
        self.basecommon.screenshot(screen_name)
        self.driver.quit()

    def testJenkins01_01(self):

        time.sleep(2)
        self.mlogin.login()
        print "success......."
        self.taskdata = Util().operateYaml(
            "../data/pageData/newTaskData.yaml")  # 取到yaml里边的所有数据
        self.driver.find_element_by_link_text(
            self.taskdata['newtask']['newtask_01']['task']).click()
        txt = self.driver.find_element_by_xpath(
            self.taskdata['newtask']['newtask_01']['taskHo']).text
        print txt
        self.assertEqual(txt, self.taskdata['newtask']['assert']['username'])
예제 #3
0
 def setUp(self):
     self.driver = webdriver.Firefox()
     self.basecommon = BaseCommon(self.driver)
     self.mlogin = Mylogin(self.driver)
     self.data = Util().operateYaml(
         "../data/jkData/pageData.yaml")  # 取到yaml里边的所有数据
     self.driver.get(self.data['login']['url'])
예제 #4
0
 def __init__(self,driver):
     self.driver=driver
     self.login=login(self.driver)
     self.baseCom=BaseCommon(self.driver)
     self.quality_inspection_data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/chat_Record.yaml")
     self.data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/serverSatisficing.yaml")
     self.iframe_data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/iframe.yaml")
 def __init__(self,driver):
     self.driver=driver
     self.login=login(self.driver)
     self.basecom=BaseCommon(self.driver)
     self.data=unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/channl.yaml")
     self.iframe_data=unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/iframe.yaml")
     self.login_data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/inputData/login.yaml")
 def __init__(self,driver):
     self.driver=driver
     self.severSatisFicing=serverSatisficing(self.driver)
     self.baseCom = BaseCommon(self.driver)
     self.data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/serverSatisficing.yaml")
     self.iframe_data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/iframe.yaml")
     self.weadmin_login = login(self.driver)
 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)
예제 #8
0
class Testlogin(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('http://www.baidu.com')

        self.basecommon = BaseCommon(self.driver)

    def tearDown(self):
        print time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time()))
        filedir = "D:/webtest/screenshot/"
        if not os.path.exists(filedir):
            os.makedirs(os.path.join('D:/', 'webtest', 'screenshot'))
        screen_name = filedir + time.strftime(
            '%Y-%m-%d-%H-%M-%S', time.localtime(time.time())) + ".png"
        self.basecommon.screenshot(screen_name)
        self.driver.quit()

    def testBaidu01_01(self):

        self.driver.find_element_by_link_text(u'新闻').click()
        time.sleep(2)
        self.basecommon.back()
        time.sleep(2)
        self.basecommon.forward()
        time.sleep(2)
        print "111111"
        self.assertEqual("https://www.baidu.com", self.driver.current_url)

    def testBaidu01_02(self):

        time.sleep(2)
        self.basecommon.fresh()
        ele = self.basecommon.untilTime("ID", 'kw')
        ele.send_keys("123")
        print "test结束"
예제 #9
0
    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'])
예제 #10
0
 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"
     )
예제 #11
0
class Publish_tiezi(object):
    def __init__(self, driver):
        self.driver = driver
        # #调试
        # self.driver=webdriver.Firefox()
        self.data_page = Util().operateYaml("../data/pageData/page1.yaml")
        self.basecommon = BaseCommon(self.driver)

    def publish(self):
        self.driver.find_element_by_css_selector(
            "input[type='button']").click()
        self.driver.implicitly_wait(5)
        tar_title = self.driver.find_element_by_css_selector(
            self.data_page['page1']['function2']['标题'])
        tar_title.click()
        tar_title.send_keys(self.data_page['page1']['function2']['标题内容'] +
                            Util().suijishu())
        iframe_bite = self.driver.find_element_by_css_selector(
            self.data_page['page1']['function2']['iframe'])

        self.driver.switch_to.frame(iframe_bite)

        # iframe_bite.send_keys('AAA')  #即使一个frame 只有 也不能发信息
        article = self.driver.find_element_by_css_selector(
            self.data_page['page1']['function2']['文本位置'])
        article.send_keys(self.data_page['page1']['function2']['文章内容'])

        #下拉框    , 注意要切回 主frame
        self.driver.switch_to.default_content()

        self.driver.find_element_by_css_selector(
            self.data_page['page1']['function2']['立即发布']).click()
        self.basecommon.untilTime(
            "CSS_SELECTOR", self.data_page['page1']['personal']['图片上传弹框'])
        tankuang = self.driver.find_element_by_css_selector(
            self.data_page['page1']['personal']['图片上传弹框'])
        content = tankuang.text
        # print(content)
        return content
예제 #12
0
class Quality_inspection():
    def __init__(self,driver):
        self.driver=driver
        self.login=login(self.driver)
        self.baseCom=BaseCommon(self.driver)
        self.quality_inspection_data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/chat_Record.yaml")
        self.data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/serverSatisficing.yaml")
        self.iframe_data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/iframe.yaml")
    def Quality_inspection_iframe(self):
        self.login.weadmin_Login()
        time.sleep(3)
        try:
            ele = self.baseCom.untilTime("XPATH", self.data["customer"])
            ActionChains(self.driver).move_to_element(ele).perform()
        except:
            logg.logger.error("ele not find")
        try:
            elem = self.baseCom.untilTime("XPATH", self.data["customer_text"])
            elem.click()
        except:
            print("can not find elem")
        try:
            elem = self.baseCom.untilTime("XPATH", self.quality_inspection_data["Quality_inspection"]["quality_inspection_text"])
            elem.click()
        except:
            print("can not find elem")
        #质检表单配置iframe
        try:
            iframe_satisf = self.baseCom.untilTime("XPATH", self.iframe_data["iframe"]["quality_inspection"])
            # iframe_satisf = self.severSatisFicing.serverSatisficing_iframe()
            self.driver.switch_to.frame(iframe_satisf)
        except:
            print("can not find iframe_satisf")

    def newly_added(self):
        pass
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()
예제 #14
0
class transfer_to_labor():
    def __init__(self,driver):
        self.driver=driver
        self.login=login(self.driver)
        self.basecom=BaseCommon(self.driver)
        self.data=unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/channl.yaml")
        self.iframe_data=unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/iframe.yaml")
        self.login_data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/inputData/login.yaml")
#转人工
    def Transfertolabor(self):
        #登录后台,打开访客端

        try:
            self.login.weadmin_Login()
            channl_elem=self.basecom.untilTime("XPATH",self.data["channl"])
            ActionChains(self.driver).move_to_element(channl_elem).perform()
            channl_text_elem=self.basecom.untilTime("XPATH",self.data["channl_text"])
            channl_text_elem.click()



            web_channl_elem=self.basecom.untilTime("XPATH",self.data["web_channl"])
            ActionChains(self.driver).click(web_channl_elem).perform()



            iframe_elem=self.basecom.untilTime("XPATH",self.iframe_data["iframe"]["web_channl"])
            self.driver.switch_to.frame(iframe_elem)

            debugging_elem=self.basecom.untilTime("XPATH",self.data["debugging"])
            debugging_elem.click()
            time.sleep(5)
            url = self.driver.current_url
            print(url)



        #切换回前一个窗口
            all_handles = self.driver.window_handles
            curr_handles=self.driver.current_window_handle
            print(curr_handles)
            for handle in all_handles:
                if handle == curr_handles:
                    self.driver.switch_to.window(handle)
            time.sleep(5)


        #退出管理端

            person_message_elem=self.basecom.untilTime("XPATH",self.data["person_message"])
            ActionChains(self.driver).move_to_element(person_message_elem).perform()
            self.driver.switch_to.default_content()
            login_out_elem=self.basecom.untilTime("XPATH",self.data["out_login"])
            ActionChains(self.driver).click(login_out_elem).perform()

            time.sleep(4)
        #登录座席端

            username_elem=self.basecom.untilTime("XPATH",self.data["username"])
            username_elem.send_keys(self.login_data["customer_login"]["username"])
            time.sleep(3)

            password_elem=self.basecom.untilTime("XPATH",self.data["password"])
            password_elem.send_keys(self.login_data["customer_login"]["password"])
            time.sleep(3)

            login_elem=self.basecom.untilTime("XPATH",self.data["login"])
            login_elem.send_keys(Keys.ENTER)
            time.sleep(3)

            customer_elem=self.basecom.untilTime("XPATH",self.data["customer"])
            customer_elem.click()
            time.sleep(5)

            choose_skill_elem=self.basecom.untilTime("XPATH",self.data["choose_skill"])
            choose_skill_elem.click()
            time.sleep(3)

            skill_status_elem=self.basecom.untilTime("XPATH",self.data["skill_status"])
            skill_status_elem.click()
            time.sleep(3)

            online_elem=self.basecom.untilTime("XPATH",self.data["online"])
            online_elem.click()
            time.sleep(3)

            affirm_elem=self.basecom.untilTime("XPATH",self.data["affirm"])
            affirm_elem.click()


            time.sleep(5)
            self.basecom.fresh()
        #切回访客端转人工
            self.switch_windows()

            Transfer_to_labor_elem=self.basecom.untilTime("XPATH",self.data["Transfer_to_labor"])
            Transfer_to_labor_elem.click()



        #切回坐席端,验证转人工是否成功
            self.switch_windows()

            result_elem=self.basecom.untilTime("XPATH",self.data["visitor_name"])
            result_elem_text=result_elem.text
            return result_elem_text
        except:
            logg.logger.error("无法定位元素,请联系管理员")

#封装切换窗口方法
    def switch_windows(self):
        all_handles = self.driver.window_handles
        curr_handles = self.driver.current_window_handle
        print(curr_handles)
        for handle in all_handles:
            if handle != curr_handles:
                self.driver.switch_to.window(handle)
                time.sleep(5)
#发送文字表情
    def send_news_text(self):
        self.Transfertolabor()
        try:
            send_news_text_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["send_news_text"])
            #send_news_text_elem.click()
            send_news_text_elem.send_keys("你好,我是小弟弟,你是谁")

            send_news_button_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["send_news_button"])
            send_news_button_elem.click()

            time.sleep(3)

            result_text_elem=self.driver.find_elements_by_xpath(self.data["send_news"]["result_text"])
            #result_text_elem_text=result_text_elem.text
            print(result_text_elem)
            for result in result_text_elem:
                if result.text=="你好,我是小弟弟,你是谁":
                    return result.text


            picture_elem=self.basecom.untilTime("XPATH",self.data["picture"])
            ActionChains(self.driver).move_to_element(picture_elem).perform()
            time.sleep(3)
            login_out_elem=self.basecom.untilTime("XPATH",self.data["login_out"])
            login_out_elem.click()
            time.sleep(3)

            login_out_confirm_elem=self.basecom.untilTime("XPATH",self.data["login_out_confirm"])
            login_out_confirm_elem.click()
            time.sleep(3)
        except:
            logg.logger.error("无法定位到元素,请联系管理员检查一下")

#发送表情消息
    def send_news_expression(self):
        try:
            self.Transfertolabor()
            send_news_expression_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["send_news_expression"])
            ActionChains(self.driver).click(send_news_expression_elem).perform()

            send_expression_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["send_expression"])
            ActionChains(self.driver).click(send_expression_elem).perform()

            send_news_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["send_news_button"])
            send_news_button_elem.click()
            time.sleep(3)

            result_text_elem = self.driver.find_elements_by_xpath(self.data["send_news"]["result_expression"])
            print(result_text_elem)

            picture_elem=self.basecom.untilTime("XPATH",self.data["picture"])
            ActionChains(self.driver).move_to_element(picture_elem).perform()
            time.sleep(3)
            login_out_elem=self.basecom.untilTime("XPATH",self.data["login_out"])
            login_out_elem.click()
            time.sleep(3)
            login_out_confirm_elem=self.basecom.untilTime("XPATH",self.data["login_out_confirm"])
            login_out_confirm_elem.click()
            time.sleep(3)
            return result_text_elem
        except:
            logg.logger.error("无法定位到元素,请联系管理员检查一下")
#发送视频消息
    def send_news_vidio(self):

        try:
            self.Transfertolabor()
            file_button_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["file_button"])
            ActionChains(self.driver).click(file_button_elem).perform()

            upload_button_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["upload_button"])
            ActionChains(self.driver).click(upload_button_elem).perform()
            os.system("C:/Users/yunwen/PycharmProjects/customerServer/testFile/test_mp4.exe")
            time.sleep(3)
            affirm_button_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["affirm_button"])
            affirm_button_elem.send_keys(Keys.ENTER)



            time.sleep(3)
            result_video_elem = self.driver.find_elements_by_xpath(self.data["send_news"]["result_video"])
            print(result_video_elem)

            picture_elem = self.basecom.untilTime("XPATH", self.data["picture"])
            ActionChains(self.driver).move_to_element(picture_elem).perform()
            time.sleep(3)
            login_out_elem = self.basecom.untilTime("XPATH", self.data["login_out"])
            login_out_elem.click()
            time.sleep(3)

            login_out_confirm_elem = self.basecom.untilTime("XPATH", self.data["login_out_confirm"])
            login_out_confirm_elem.click()
            time.sleep(3)
            return result_video_elem
        except:
            logg.logger.error("无法定位到元素,请联系管理员检查一下")

#发送文件消息
    def send_news_docx(self):
        #self.Transfertolabor()
        try:
            self.Transfertolabor()
            file_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["file_button"])
            ActionChains(self.driver).click(file_button_elem).perform()

            upload_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["upload_button"])
            ActionChains(self.driver).click(upload_button_elem).perform()
            os.system("C:/Users/yunwen/PycharmProjects/customerServer/testFile/test_docx.exe")
            time.sleep(3)
            affirm_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["affirm_button"])
            affirm_button_elem.send_keys(Keys.ENTER)

            time.sleep(3)
            result_docx_elem = self.driver.find_element_by_xpath(self.data["send_news"]["result_docx"])
            print(result_docx_elem.text)

            picture_elem = self.basecom.untilTime("XPATH", self.data["picture"])
            ActionChains(self.driver).move_to_element(picture_elem).perform()
            time.sleep(3)
            login_out_elem = self.basecom.untilTime("XPATH", self.data["login_out"])
            login_out_elem.click()
            time.sleep(3)

            login_out_confirm_elem = self.basecom.untilTime("XPATH", self.data["login_out_confirm"])
            login_out_confirm_elem.click()
            time.sleep(3)
            return result_docx_elem.text
        except:
            logg.logger.error("无法定位到元素,请联系管理员检查一下")
#发送音频消息
    def send_news_audio(self):
        try:
            self.Transfertolabor()
            file_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["file_button"])
            ActionChains(self.driver).click(file_button_elem).perform()

            upload_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["upload_button"])
            ActionChains(self.driver).click(upload_button_elem).perform()
            os.system("C:/Users/yunwen/PycharmProjects/customerServer/testFile/test_mp3.exe")
            time.sleep(3)
            affirm_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["affirm_button"])
            affirm_button_elem.send_keys(Keys.ENTER)

            time.sleep(3)
            result_docx_elem = self.driver.find_element_by_xpath(self.data["send_news"]["result_audio"])
            print(result_docx_elem)

            picture_elem = self.basecom.untilTime("XPATH", self.data["picture"])
            ActionChains(self.driver).move_to_element(picture_elem).perform()
            time.sleep(3)
            login_out_elem = self.basecom.untilTime("XPATH", self.data["login_out"])
            login_out_elem.click()
            time.sleep(3)

            login_out_confirm_elem = self.basecom.untilTime("XPATH", self.data["login_out_confirm"])
            login_out_confirm_elem.click()
            time.sleep(3)
            return result_docx_elem
        except:
            logg.logger.error("无法定位到元素,请联系管理员检查一下")
#发送图片
    def send_news_picture(self):
        try:
            self.Transfertolabor()
            file_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["file_button"])
            ActionChains(self.driver).click(file_button_elem).perform()

            upload_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["upload_button"])
            ActionChains(self.driver).click(upload_button_elem).perform()
            os.system("C:/Users/yunwen/PycharmProjects/customerServer/testFile/test_jpg.exe")
            time.sleep(3)
            affirm_button_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["affirm_button"])
            affirm_button_elem.send_keys(Keys.ENTER)

            time.sleep(3)
            result_picture_elem = self.driver.find_elements_by_xpath(self.data["send_news"]["result_picture"])
            print(result_picture_elem)

            picture_elem = self.basecom.untilTime("XPATH", self.data["picture"])
            ActionChains(self.driver).move_to_element(picture_elem).perform()
            time.sleep(3)
            login_out_elem = self.basecom.untilTime("XPATH", self.data["login_out"])
            login_out_elem.click()
            time.sleep(3)

            login_out_confirm_elem = self.basecom.untilTime("XPATH", self.data["login_out_confirm"])
            login_out_confirm_elem.click()
            time.sleep(3)
            return result_picture_elem
        except:
            logg.logger.error("未定位到元素,请来查看原因")
#发起邀评
    def send_Satisfacted_Invite(self):
        try:
            self.Transfertolabor()
            send_Satisfacted_Invite_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["send_Satisfacted_Invite"])
            ActionChains(self.driver).click(send_Satisfacted_Invite_elem).perform()

            self.switch_windows()
            commonly_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["commonly"])
            commonly_elem.click()
            time.sleep(3)
            feedback_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["feedback"])
            feedback_elem.send_keys("小菜正在为您转人工哦,请耐心等待,您也可以继续和我交流哦,谢谢啦~")
            time.sleep(3)
            button_affirm_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["button_affirm"])
            ActionChains(self.driver).click(button_affirm_elem).perform()
            time.sleep(4)

            chat_end_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["chat_end"])
            chat_end_elem.click()

            replay_elems=self.basecom.untilTime("XPATH",self.data["send_news"]["replay"])
            replay_elems_text=replay_elems.text

            self.switch_windows()
            time.sleep(4)
            picture_elem = self.basecom.untilTime("XPATH", self.data["picture"])
            ActionChains(self.driver).move_to_element(picture_elem).perform()
            time.sleep(3)
            login_out_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["Switching_system"])
            login_out_elem.click()
            time.sleep(3)
            all_handles = self.driver.window_handles
            print(all_handles)

            self.driver.switch_to.window(all_handles[-1])
            time.sleep(5)
            curr_handles = self.driver.current_window_handle
            print(curr_handles)

            customer_ele = self.basecom.untilTime("XPATH", self.data["send_news"]["customer"])
            ActionChains(self.driver).move_to_element(customer_ele).perform()
            customer_text_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["customer_text"])
            customer_text_elem.click()
            time.sleep(2)
            customerservice_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["customerservice"]["serverSatisficing"])
            customerservice_elem.click()
                # 人工客服iframe
            iframe_satisf = self.basecom.untilTime("XPATH", self.iframe_data["iframe"]["serverSatisficing"])
                # iframe_satisf = self.severSatisFicing.serverSatisficing_iframe()
            self.driver.switch_to.frame(iframe_satisf)

            list_Satisfied_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["list_Satisfied"])
            list_Satisfied_elem_text=list_Satisfied_elem.text
            return list_Satisfied_elem_text

            #picture_elem = self.basecom.untilTime("XPATH", self.data["picture"])
            #ActionChains(self.driver).move_to_element(picture_elem).perform()
            #time.sleep(3)
            #login_out_elem = self.basecom.untilTime("XPATH", self.data["login_out"])
            #login_out_elem.click()
            #time.sleep(3)

            #login_out_confirm_elem = self.basecom.untilTime("XPATH", self.data["login_out_confirm"])
            #login_out_confirm_elem.click()
            #time.sleep(3)




        except:
            logg.logger.error("请留意,无法定位到元素")
            #self.switch_windows()

#填写服务小结
    def send_summary(self):
        try:
            self.Transfertolabor()
            summary_elem = self.basecom.untilTime("XPATH",self.data["send_news"]["summary"])
            ActionChains(self.driver).click(summary_elem).perform()

            summary_type_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["summary_type"])
            ActionChains(self.driver).click(summary_type_elem).perform()

            summary_type_menu_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["summary_type_menu"])
            ActionChains(self.driver).click(summary_type_menu_elem).perform()

            summary_remarks_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["summary_remarks"])
            summary_remarks_elem.send_keys("俺乃燕人张翼得,尔等还不速速离去")

            summary_affirm_button_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["summary_affirm_button"])
            summary_affirm_button_elem.click()

            close_chat_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["close_chat"])
            close_chat_elem.click()

            close_chat_affirm_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["close_chat_affirm"])
            close_chat_affirm_elem.click()

            picture_elem = self.basecom.untilTime("XPATH", self.data["picture"])
            ActionChains(self.driver).move_to_element(picture_elem).perform()
            time.sleep(3)
            login_out_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["Switching_system"])
            login_out_elem.click()
            time.sleep(3)
            all_handles = self.driver.window_handles
            print(all_handles)

            self.driver.switch_to.window(all_handles[-1])
            time.sleep(5)
            curr_handles = self.driver.current_window_handle
            print(curr_handles)
            customer_ele = self.basecom.untilTime("XPATH", self.data["send_news"]["customer"])
            ActionChains(self.driver).move_to_element(customer_ele).perform()
            customer_text_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["customer_text"])
            customer_text_elem.click()
            time.sleep(2)
            customerservice_elem = self.basecom.untilTime("XPATH",
                                                      self.data["send_news"]["service_Summary"]["serviceSummary"])
            customerservice_elem.click()
            # 人工客服iframe
            iframe_satisf = self.basecom.untilTime("XPATH", self.iframe_data["iframe"]["service_Summary"])
            # iframe_satisf = self.severSatisFicing.serverSatisficing_iframe()
            self.driver.switch_to.frame(iframe_satisf)

            list_summary_remarks_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["list_summary_remarks"])
            list_summary_remarks_elem_text=list_summary_remarks_elem.text

            return  list_summary_remarks_elem_text
        except:
            logg.logger.error("出现问题,请来查看一下")

#创建讨论组
    def create_chat_group(self):
        try:
            self.Transfertolabor()
            self.get_customer_login()
            self.get_register()
            create_group_button_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["create_group_button"])
            ActionChains(self.driver).click(create_group_button_elem).perform()

            after_kefu_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["after_kefu"])
            ActionChains(self.driver).click(after_kefu_elem).perform()

            check_box_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["check_box"])
            check_box_elem.click()

            choose_affirm_button_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["choose_affirm_button"])
            choose_affirm_button_elem.click()

            chat_group_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["chat_group"])
            chat_group_elem_text=chat_group_elem.text
            print(chat_group_elem_text)
            close_chat_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["close_chat"])
            close_chat_elem.click()

            close_chat_affirm_elem = self.basecom.untilTime("XPATH", self.data["send_news"]["close_chat_affirm"])
            close_chat_affirm_elem.click()




            return chat_group_elem_text
            #chat_group_elem.click()
            '''
            visitor_name_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["visitor_name"])
            visitor_name_elem_text=visitor_name_elem.text
            print(visitor_name_elem_text)
            return visitor_name_elem_text
            '''
        except:
            logg.logger.error("请求失败,请前往查看")


        '''   
            #options = webdriver.ChromeOptions()
            #options.add_argument("--incognito")
            #driver = webdriver.Chrome(chrome_options=options)

            #js='window.open("http://v5-dev-customer.faqrobot.net/webcustomer/index_standard.html#/login")'
            #self.driver.execute_script(js)
            #driver.get("http://v5-dev-customer.faqrobot.net/webcustomer/index_standard.html#/login")
            #driver.maximize_window()


            #all_handles = self.driver.window_handles
            #print(all_handles)

            #self.driver.switch_to.window(all_handles[-1])
            #time.sleep(5)
            #username_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["customer_username"])
            #username_elem.send_keys("auto_kefu")

            password_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["customer_password"])
            password_elem.send_keys("123456abc")

            customer_login_button_elem=self.basecom.untilTime("XPATH",self.data["send_news"]["customer_login_button"])
            customer_login_button_elem.click()

            choose_skill_elem = self.basecom.untilTime("XPATH", self.data["choose_skill"])
            choose_skill_elem.click()
            time.sleep(3)

            skill_status_elem = self.basecom.untilTime("XPATH", self.data["skill_status"])
            skill_status_elem.click()
            time.sleep(3)

            online_elem = self.basecom.untilTime("XPATH", self.data["online"])
            online_elem.click()
            time.sleep(3)

            affirm_elem = self.basecom.untilTime("XPATH", self.data["affirm"])
            affirm_elem.click()
        except:
            logg.logger.error("无法定位元素,请前往查看")
    '''

    def get_customer_login(self):
        send_pearm = {"username": "******", "password": "******", "isRememberMe": "false"}
        # baseUrl = local_read_Config.get_HTTP("baseUrl")
        header = {"Content-Type": "application/x-www-form-urlencoded",
                  "Authorization": "Basic bml5YXpob3U6MTIzNDU2YWJj",
                  "Referer": "http://v5-dev-customer.faqrobot.net/webcustomer/index_standard.html",
                  "Accept": "application/json, text/plain, */*"}
        customer_login = requests.post("http://v5-dev-customer.faqrobot.net/customerservice/login", params=send_pearm,
                                       headers=header)
        customer_cookie = requests.utils.dict_from_cookiejar(customer_login.cookies)
        if len(customer_cl) > 0:
            del customer_cl[-len(customer_cl):]
            print(customer_cl)
        for k, v in customer_cookie.items():
            if k + ":" + v:
                s = k + "=" + v

                customer_cl.append(s)
        login_customer_cookies = ";".join(customer_cl)

        print(login_customer_cookies)
        return login_customer_cookies

    # 获取客服信息
    def get_agentInfo(self):
        header = {"cookie":self.get_customer_login()}
        response = requests.get("http://v5-dev-customer.faqrobot.net/customerservice/webim/agent/agentInfo",
                                headers=header)
        print(response.json())
        tenantId = response.json()["data"]["agent"]["tenantId"]
        return tenantId

    # 客服上线技能组
    def get_register(self):
        send_param = [{"tenantId":"149","groupId":"1000010343","groupName":"售后客服","agentId":"30351",
                       "agentName":"","status":"ONLINE","orginStatus":"LEAVE","agentStatus":1,"orginAgentStatus":3}]
        data = json.dumps(send_param)
        header = {"Content-Type": "application/json;charset=UTF-8",
                  "cookie": self.get_customer_login()}
        register_response = requests.post("http://v5-dev-customer.faqrobot.net/customerservice/webim/agent/setUpAgentGroupStatus",
                                          data=data, headers=header)
        print("客服上线技能组:", register_response.json())
예제 #15
0
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('http://www.baidu.com')

        self.basecommon = BaseCommon(self.driver)
예제 #16
0
class Sevice_Summary():
    def __init__(self,driver):
        self.driver=driver
        self.baseCom=BaseCommon(self.driver)
        self.login=login(self.driver)
        self.data = unit().operaYaml(
            "C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/serverSatisficing.yaml")
        self.seviceSummary_data=unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/service_Summary.yaml")
        self.iframe_data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/iframe.yaml")
    def service_Summary_iframe(self):
        self.login.weadmin_Login()
        try:
            ele = self.baseCom.untilTime("XPATH", self.data["customer"])
            ActionChains(self.driver).move_to_element(ele).perform()
        except:
            logg.logger.error("ele not find")
        try:
            elem = self.baseCom.untilTime("XPATH", self.data["customer_text"])
            elem.click()
            time.sleep(2)
        except:
            logg.logger.error("can not find elem")

        try:
            elem = self.baseCom.untilTime("XPATH", self.seviceSummary_data["service_Summary"]["serviceSummary"])
            elem.click()
        except:
            print("can not find elem")
        # 人工客服iframe
        try:
            iframe_satisf = self.baseCom.untilTime("XPATH", self.iframe_data["iframe"]["service_Summary"])

            # iframe_satisf = self.severSatisFicing.serverSatisficing_iframe()

            self.driver.switch_to.frame(iframe_satisf)
        except:
            logg.logger.error("进入iframe失败,请检查")

    def time_search(self):
        self.service_Summary_iframe()
        try:
            chooseTime_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["chooseTime"])
            chooseTime_elem.click()

        except:
            logg.logger.error("无法定位到chooseTime_elem")

        try:
            startTime_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["startTime"])
            startTime_elem.send_keys(Keys.CONTROL,"a")
            startTime_elem.send_keys("2020-06-24")
            startTime_elem.send_keys(Keys.ENTER)
            time.sleep(2)

        except:
            logg.logger.error("无法定位到last_three_months_elem")

        try:
            list_visitor_name_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["list_visitorName"])
            list_visitor_name=list_visitor_name_elem.text
        except:
            logg.logger.error("无法定位到list_visitor_name_elem")
        return list_visitor_name


    def visitor_Name_sarch(self):
        self.time_search()
        try:
            visitor_Name_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["list_visitorName"])
            visitor_Name=visitor_Name_elem.text
        except:
            logg.logger.error("无法定位visitor_name")

        try:
            search_box_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["search_box"])
            search_box_elem.send_keys(visitor_Name)
            search_box_elem.send_keys(Keys.ENTER)
            time.sleep(3)
        except:
            logg.logger.error("无法定位search_Box_elem")
        finally:
            list_visitor_Name_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["list_visitorName"])
            list_visitor_Name=list_visitor_Name_elem.text
            return list_visitor_Name,visitor_Name

    def remark_search(self):
        self.time_search()
        try:
            choose_box_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["choose_box"])
            choose_box_elem.click()
        except:
            logg.logger.error("无法定位到choose_box_elem")
        try:
            remark_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["remarks"])
            remark_elem.click()
        except:
            logg.logger.error("无法定位到remark_elem")

        try:
            remarkElem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["list_remark"])
            remark=remarkElem.text
            searchBox_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["search_box"])
            searchBox_elem.send_keys(remark)
            searchBox_elem.send_keys(Keys.ENTER)
        except:
            logg.logger.error("无法定位到元素")
        finally:
            list_remark_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["list_remark"])
            list_remark=list_remark_elem.text
            return list_remark ,remark

    def export(self):

        try:
            self.time_search()
            listVisitorname_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["list_visitorName"])
            listVisitorname=listVisitorname_elem.text

            export_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["export"])
            export_elem.click()
            time.sleep(10)
            return listVisitorname
        except:
            logg.logger.error("无法定位元素")


    def view_chatMessage(self):
        self.time_search()
        try:
            view_chatMessage_elem=self.baseCom.untilTime("LINK_TEXT",self.seviceSummary_data["service_Summary"]["view_chatMessage"])
            view_chatMessage_elem.click()
            time.sleep(2)
        except:
            logg.logger.error("无法定位到元素")

        try:
            no_chatMessage_elem=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["NO_chatMessage"])
            no_chatMessage=no_chatMessage_elem.text
            return  no_chatMessage
        except:
            logg.logger.error("无法定位元素")

    def add_service_type(self,inputData):
        self.service_Summary_iframe()

        try:
            service_type_elem = self.baseCom.untilTime("XPATH",
                                                       self.seviceSummary_data["service_Summary"]["service_type"])
            ActionChains(self.driver).move_to_element(service_type_elem).perform()
        except:
            logg.logger.error("无法找到元素")
        try:
            attend_elem = self.baseCom.untilTime("XPATH", self.seviceSummary_data["service_Summary"]["attend"])
            attend_elem.click()
            time.sleep(2)
        except:
            logg.logger.error("无法定位元素")

        try:
            service_type_name_elem = self.baseCom.untilTime("XPATH", self.seviceSummary_data["service_Summary"][
                'service_type_name'])
            service_type_name_elem.send_keys(inputData)

            confirm_button_elem = self.baseCom.untilTime("XPATH",
                                                         self.seviceSummary_data["service_Summary"]["add_confirm_button"])
            confirm_button_elem.click()
        except:
            logg.logger.error("无法验证成功")
        if inputData=="":

            try:
                result_elem = self.baseCom.untilTime("XPATH", self.seviceSummary_data["service_Summary"]["empty_prompt"])
                result = result_elem.text
                return result
            except:
                logg.logger.error("无法定位元素")

        else:
            try:
                result_elem = self.baseCom.untilTime("XPATH", self.seviceSummary_data["service_Summary"]["sucess_prompt"])
                result = result_elem.text
                print(result)
                return result

            except:
                logg.logger.error("无法定位元素")
            finally:
                self.delect_service_type()




    def delect_service_type(self):
        #self.service_Summary_iframe()

        #try:
            #iframe_satisf = self.baseCom.untilTime("XPATH", self.iframe_data["iframe"]["service_Summary"])

            #iframe_satisf = self.severSatisFicing.serverSatisficing_iframe()

            #self.driver.switch_to.frame(iframe_satisf)
        #except:
            #logg.logger.error("进入iframe失败,请检查")

        try:
            delect_service_type=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["delect_service_type"])
            delect_service_type.click()
            delect_button=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["delect_button"])
            delect_button.click()
            delect_confirm_button=self.baseCom.untilTime("XPATH",self.seviceSummary_data["service_Summary"]["delect_confirm_button"])
            delect_confirm_button.click()
        except:
            logg.logger.error("无法定位到元素")
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()
예제 #18
0
class Chat_Record():
    def __init__(self, driver):
        self.driver = driver
        self.login = login(self.driver)
        self.baseCom = BaseCommon(self.driver)
        self.chat_Record_data = unit().operaYaml(
            "C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/chat_Record.yaml"
        )
        self.data = unit().operaYaml(
            "C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/serverSatisficing.yaml"
        )
        self.iframe_data = unit().operaYaml(
            "C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/iframe.yaml"
        )

    def chat_Record_iframe(self):
        try:
            self.login.weadmin_Login()
            time.sleep(3)

            customer_ele = self.baseCom.untilTime("XPATH",
                                                  self.data["customer"])
            ActionChains(self.driver).move_to_element(customer_ele).perform()

            customer_text_elem = self.baseCom.untilTime(
                "XPATH", self.data["customer_text"])
            customer_text_elem.click()

            chat_Record_text_elem = self.baseCom.untilTime(
                "XPATH",
                self.chat_Record_data["chat_Record"]["chat_Record_text"])
            chat_Record_text_elem.send_keys(Keys.ENTER)

            # 聊天记录iframe

            iframe_satisf = self.baseCom.untilTime(
                "XPATH", self.iframe_data["iframe"]["chat_Record"])
            # iframe_satisf = self.severSatisFicing.serverSatisficing_iframe()
            self.driver.switch_to.frame(iframe_satisf)
        except:
            logg.logger.error("无法定位元素,请速来查看")

    #时间搜索
    def time_search(self):

        try:
            self.chat_Record_iframe()
            chooseTime_elem = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["chooseTime"])
            chooseTime_elem.click()
            time.sleep(3)

            now_twoMouth_ele = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["now_twoMouth"])
            now_twoMouth_ele.click()
            time.sleep(3)
        except:
            logg.logger.error("无法定位元素,请速来查看")

    #渠道搜索
    def search_channel(self):

        try:
            self.time_search()
            channel_elem = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["channel"])
            channel_elem.click()

            pc_channel_ele = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["pc_channel"])
            pc_channel_ele.click()

            channel_name_element = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["channel_name"])
            channel_name_element.click()
            time.sleep(2)
        except:
            logg.logger.error("无法定位元素,请速来查看")

    def statisfic_search(self):

        try:
            self.time_search()
            satisficing_elem = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["satisficing"])
            satisficing_elem.click()

            very_satisficing_ele = self.baseCom.untilTime(
                "XPATH",
                self.chat_Record_data["chat_Record"]["very_satisficing"])
            very_satisficing_ele.click()
            time.sleep(2)
        except:
            logg.logger.error("无法定位元素,请前来查看")

    def group_search(self):

        try:
            self.time_search()
            group_elem = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["group"])
            group_elem.click()

            groupName_elem = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["groupName"])
            groupName_elem.click()
            time.sleep(2)

            list_groupName_elem = self.baseCom.untilTime(
                "XPATH",
                self.chat_Record_data["chat_Record"]["list_groupName"])
            groupName = list_groupName_elem.text
            return groupName

        except:
            logg.logger.error("无法定位元素,请前来查看")

    def agent_search(self):

        try:
            self.time_search()
            choose_agent = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["agent"])
            choose_agent.click()
            time.sleep(2)

            agentName = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["agentName"])
            agentName.click()
            time.sleep(2)

            list_agentName_elem = self.baseCom.untilTime(
                "XPATH",
                self.chat_Record_data["chat_Record"]["list_agentName"])
            list_agentName = list_agentName_elem.text
            return list_agentName
        except:
            logg.logger.error("无法定位到元素,请速来查看")

    def visitorName_search(self):

        try:
            self.time_search()
            list_visitor_elem = self.baseCom.untilTime(
                "XPATH",
                self.chat_Record_data["chat_Record"]["list_visitorName"])
            list_visitorName = list_visitor_elem.text

            list_visitorName_elem = self.baseCom.untilTime(
                "XPATH", self.chat_Record_data["chat_Record"]["visitorName"])
            list_visitorName_elem.send_keys(list_visitorName)

            list_visitorName_elem.send_keys(Keys.ENTER)
            time.sleep(2)

            list_visitor_element = self.baseCom.untilTime(
                "XPATH",
                self.chat_Record_data["chat_Record"]["list_visitorName"])
            list_visitor_name = list_visitor_element.text
            return list_visitor_name, list_visitorName
        except:
            logg.logger.error("无法定位元素,请前来查看")

    def exportChatRecord(self):

        try:
            self.time_search()
            exportChatRecord_elem = self.baseCom.untilTime(
                "XPATH",
                self.chat_Record_data["chat_Record"]["exportChatRecord"])
            exportChatRecord_elem.click()
            time.sleep(5)

            list_visitor_element = self.baseCom.untilTime(
                "XPATH",
                self.chat_Record_data["chat_Record"]["list_visitorName"])
            list_visitor_name = list_visitor_element.text
            return list_visitor_name
        except:
            logg.logger.error("无法定位元素,请前来查看")

    def View_chat_history(self):

        try:
            self.time_search()
            list_visitorName_elem = self.baseCom.untilTime(
                "XPATH",
                self.chat_Record_data["chat_Record"]["list_visitorName"])
            list_visitorName = list_visitorName_elem.text
            view_chat_elem = self.baseCom.untilTime(
                "LINK_TEXT",
                self.chat_Record_data["chat_Record"]["View_chat_history"])
            view_chat_elem.click()
            time.sleep(3)

            self.driver.switch_to.default_content()

            iframe_elem = self.baseCom.untilTime(
                "XPATH", self.iframe_data["iframe"]["view_chat_Record"])
            self.driver.switch_to.frame(iframe_elem)
            list_visitor_elem = self.baseCom.untilTime(
                "CSS_SELECTOR",
                self.chat_Record_data["chat_Record"]["list_VisitorName"])
            list_visitor_elem_text = list_visitor_elem.text
            return list_visitor_elem_text, list_visitorName
        except:
            logg.logger.error("无法定位元素,请前来查看")
예제 #19
0
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()
예제 #20
0
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()
예제 #21
0
 def __init__(self, driver):
     self.driver = driver
     # #调试
     # self.driver=webdriver.Firefox()
     self.data_page = Util().operateYaml("../data/pageData/page1.yaml")
     self.basecommon = BaseCommon(self.driver)
예제 #22
0
class ServerSatisficing():
    def __init__(self,driver):
        self.driver=driver
        self.severSatisFicing=serverSatisficing(self.driver)
        self.baseCom = BaseCommon(self.driver)
        self.data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/serverSatisficing.yaml")
        self.iframe_data = unit().operaYaml("C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/iframe.yaml")
        self.weadmin_login = login(self.driver)

    def serverSatisficing_iframe(self):

        try:
            self.weadmin_login.weadmin_Login()
            customer_ele=self.baseCom.untilTime("XPATH", self.data["customer"])
            ActionChains(self.driver).move_to_element(customer_ele).perform()

            customer_text_elem=self.baseCom.untilTime("XPATH", self.data["customer_text"])
            customer_text_elem.click()
            time.sleep(2)

            serverSatisficing_elem=self.baseCom.untilTime("XPATH", self.data["customerservice"]["serverSatisficing"])
            serverSatisficing_elem.click()

        # 人工客服iframe

            iframe_satisf=self.baseCom.untilTime("XPATH", self.iframe_data["iframe"]["serverSatisficing"])

            #iframe_satisf = self.severSatisFicing.serverSatisficing_iframe()

            self.driver.switch_to.frame(iframe_satisf)
        except:
            print("无法定位元素,请速来查看")

        #人工客服,时间查询
    def timeSearch(self):


        try:
            self.serverSatisficing_iframe()
            chooseTime_elem=self.baseCom.untilTime("XPATH", self.data["customerservice"]["chooseTime"])
            chooseTime_elem.click()

            startTime_elem=self.baseCom.untilTime("XPATH",self.data["customerservice"]["startTime"])

            startTime_elem.send_keys(Keys.CONTROL,"a")

            startTime_elem.send_keys("2020-07-03")
            startTime_elem.send_keys(Keys.ENTER)
        except:
            print("无法定位元素,请前来查看")


        time.sleep(3)
    def very_Dissatisfied(self):
        #self.serverSatisficing_iframe()

        try:
            self.timeSearch()
            satisfaction_elem=self.baseCom.untilTime("XPATH",self.data["condition_Satisfaction"]["satisfaction"])
            satisfaction_elem.click()

            very_Dissatisfied_elem=self.baseCom.untilTime("XPATH",self.data["condition_Satisfaction"]["very_Dissatisfied"])
            time.sleep(3)
            very_Dissatisfied_elem.click()
        except:
            print("无法定位元素,请前来查看")

    def dissatisfied(self):

        try:
            self.timeSearch()
            satisfaction_elem=self.baseCom.untilTime("XPATH", self.data["condition_Satisfaction"]["satisfaction"])
            satisfaction_elem.click()

            dissatisfied_ele=self.baseCom.untilTime("XPATH",self.data["condition_Satisfaction"]["dissatisfied"])
            time.sleep(3)
            dissatisfied_ele.click()
        except:
            logg.logger.error("无法定位,前来查看")
    def commonly(self):

        try:
            self.timeSearch()
            satisfaction_elem=self.baseCom.untilTime("XPATH", self.data["condition_Satisfaction"]["satisfaction"])
            satisfaction_elem.click()

            commonly_ele=self.baseCom.untilTime("XPATH",self.data["condition_Satisfaction"]["commonly"])
            time.sleep(3)
            commonly_ele.click()

        except:
            logg.logger.error("无法定位,请速来查看")




    def satisfied(self):

        try:
            self.timeSearch()
            satisfaction_ele=self.baseCom.untilTime("XPATH", self.data["condition_Satisfaction"]["satisfaction"])
            satisfaction_ele.click()

            satisfied_elem=self.baseCom.untilTime("XPATH",self.data["condition_Satisfaction"]["satisfied"])
            time.sleep(3)
            satisfied_elem.click()
        except:
            logg.logger.error("无法定位,请速来查看")


    def very_Satisfied(self):

        try:
            self.timeSearch()
            satisfaction_elem=self.baseCom.untilTime("XPATH", self.data["condition_Satisfaction"]["satisfaction"])
            satisfaction_elem.click()

            time.sleep(3)

            very_Satisfied_ele=self.baseCom.untilTime("XPATH", self.data["condition_Satisfaction"]["very_Satisfied"])
            time.sleep(3)
            very_Satisfied_ele.click()
        except:
            logg.logger.error("无法定位,请前来查看")

    def customer_Search(self):

        try:
            self.timeSearch()
            customer_elem=self.baseCom.untilTime("XPATH",self.data["condition_Satisfaction"]["customer"])
            customer_elem.click()


            customer_Name_ele=self.baseCom.untilTime("XPATH",self.data["condition_Satisfaction"]["customer_Name"])
            time.sleep(3)
            customer_Name_ele.click()
        except:
            logg.logger.error("无法定位元素,请速来查看")

    def down_loade(self):

        try:
            self.timeSearch()
            downlode_elem=self.baseCom.untilTime("XPATH",self.data["condition_Satisfaction"]["downlode"])
            downlode_elem.click()
            time.sleep(20)
        except:
            logg.logger.error("无法定位元素,请速来查看")

    def look_message(self):

        try:
            self.timeSearch()
            chatList_elem=self.baseCom.untilTime("XPATH",self.data["condition_Satisfaction"]["chatList"])
            chatList_elem.click()
            time.sleep(3)
        except :
            logg.logger.error("无法定位元素,请速来查看")
예제 #23
0
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()