Exemple #1
0
    def test_add_source(self, marketing_query_info):

        # 点击新增
        Service.get_ele_location_method(
            self.driver, 'css',
            '#queryDiv > div:nth-child(2) > button:nth-child(9)').click()

        # 调用新增操作
        Marketing.marketing_add(self.driver, marketing_query_info)

        # 判断出现保存成功框
        commit_window_ele = Service.is_Element_present(
            self.driver, By.CSS_SELECTOR,
            "body > div.bootbox.modal.fade.mydialog.in > "
            "div > div > div.modal-footer > button")
        if commit_window_ele:
            actual = "add-customer-success"
            commit_window_ele.click()
        else:
            actual = "add-customer-fail"

        # 预期不符,截图
        if actual != marketing_query_info["expect"]:
            file_name = "add_error" + Service.format_date() + '.png'
            self.driver.get_screenshot_as_file(
                "C:\\Users\wang\Desktop\woniuboss4.0\gui\error\\'%s'" %
                (file_name))
        # 断言
        self.assertEqual(actual, marketing_query_info["expect"])
    def test_class_manager_add(self, add_info):
        # 新增按钮
        Service.get_ele_location_method(
            self.driver, "xpath", "//*[@id='cmDiv']/div[1]/button").click()

        # 调用新增班级
        ClassManager.class_manager_add(self.driver, add_info)

        true_window_ele = Service.is_Element_present(
            self.driver, By.CSS_SELECTOR,
            "body > div.bootbox.modal.fade.mydialog.in > div > div > div.modal-footer > button"
        )

        if true_window_ele:
            actual = "add-class-success"
            true_window_ele.click()
        else:
            actual = "add-class-fail"

        # 预期不符,截图
        Service.get_screen(self.driver, actual, add_info["expect"],
                           "/add_class",
                           "C:/Users/wang/Desktop/woniuboss4.0/gui/error")

        self.assertEqual(actual, add_info["expect"])
Exemple #3
0
 def test_open_page(self, expect):
     open_page_url = self.url
     Login.open_page(self.driver, open_page_url)
     if Service.is_Element_present(
             self.driver, By.CSS_SELECTOR,
             "#form-login > div > div > div.modal-header.text-center"):
         actual = "open-page-pass"
     else:
         actual = "open_page-fail"
     self.assertEqual(actual, expect)
     self.driver.quit()
Exemple #4
0
 def test_login(self, login_data, expect):
     # 每次用例执行,强制等待1s
     time.sleep(1)
     login_url = self.url
     Login.login(self.driver, login_url, login_data)
     if Service.is_Element_present(self.driver, By.PARTIAL_LINK_TEXT, "注销"):
         actual = "login-pass"
     else:
         actual = "login-fail"
     self.assertEqual(actual, expect)
     # 退出
     self.driver.quit()
    def verification_check_result(self, check_ele, check_path):

        Service.get_tier_ele(check_ele, By.CSS_SELECTOR, check_path).click()
        # 判断 查看功能
        if Service.is_Element_present(self.driver, By.CSS_SELECTOR,
                                      "#seeStuInfo-modal > div > div"):
            # 关闭页面
            Service.get_ele(
                self.driver, By.CSS_SELECTOR,
                "#seeStuInfo-modal > div > div > div.modal-header > button > span:nth-child(1)"
            ).click()
        else:
            print("查看功能出错")
            self.driver.quit()
Exemple #6
0
    def test_training_resource(self, training_resource_info, expect):

        # 获取sql
        def joint_sql():
            time_base_sql = ' and create_time between "%s" and "%s" and type="下载"' % (
                training_resource_info['date1'],
                training_resource_info['date2'])
            if training_resource_info['poolSelect']=="全部" and training_resource_info['empNameSelect']=="全部" and\
                training_resource_info['statusSelect']=="全部" and training_resource_info['sourceSelect']=="全部" and\
                    training_resource_info['date1']=="" and training_resource_info['date2']!="":
                sql = 'select count(customer_id) from customer where pool_type != "public"' + time_base_sql
                return sql

            if training_resource_info['poolSelect']=="全部" and training_resource_info['empNameSelect']=="全部" and\
                training_resource_info['statusSelect']=="全部" and training_resource_info['sourceSelect']!="全部":

                sql = 'select count(customer_id) from customer where source = "%s" and pool_type != "public"'\
                      %training_resource_info['sourceSelect']+time_base_sql
                return sql

            elif training_resource_info['poolSelect']!="全部" and training_resource_info['empNameSelect']=="全部" and\
                training_resource_info['statusSelect']=="全部" and training_resource_info['sourceSelect']!="全部":

                sql = 'select count(customer_id) from customer where source = "%s" and pool_type = "%s"' \
                      % (training_resource_info['sourceSelect'],training_resource_info['poolSelect'])+time_base_sql
                return sql

            elif training_resource_info['poolSelect']!="全部" and training_resource_info['empNameSelect']=="全部" and\
                training_resource_info['statusSelect']!="全部" and training_resource_info['sourceSelect']!="全部":

                sql = 'select count(customer_id) from customer where source = "%s" and pool_type = "%s" and last_status="%s"' \
                      % (training_resource_info['sourceSelect'],training_resource_info['poolSelect'],
                         training_resource_info['statusSelect'])+time_base_sql
                return sql

        # 获取cookie
        self.training_resource_init()
        # 选择加载资源模块
        Service.get_ele(
            self.driver, By.CSS_SELECTOR,
            "#content > div.row.con-margin.con-body-header > div:nth-child(1) > ul > li.active > a"
        ).click()
        TrainingResource.training_resource(self.driver, training_resource_info)

        # 系统提示搜索条件
        if Service.is_Element_present(
                self.driver, By.CSS_SELECTOR,
                "body > div.bootbox.modal.fade.mydialog.in > div > div > "
                "div.modal-footer > button"):
            actual = "query-fail"
            self.assertEqual(actual, expect)
            # 关闭
            self.driver.quit()
        else:
            # 判断是否查询出数据
            training_resource_query_result = Service.get_ele(
                self.driver, By.CSS_SELECTOR,
                "table#personal-table tbody").text
            # 市场营销有上传过数据
            if training_resource_query_result != "无符合条件的记录":
                # 前端页面显示数据数,根据状态(不同状态数量不同)
                query_count_result = Service.get_ele(
                    self.driver, By.CSS_SELECTOR, "span.pagination-info").text
                result = re.match('^显示.*,总.*?(\d+)', query_count_result)
                print(result.group(1))
                sql = joint_sql()
                print(sql)
                if sql:
                    query_connect_count = Utility.get_connect_one(
                        sql, "../config/data_base")
                    print(query_connect_count)
                    if int(result.group(1)) == int(query_connect_count[0]):
                        actual = 'query-pass'
                    else:
                        actual = 'query-fail'
                    self.assertEqual(actual, expect)

            else:
                print("查询结果为空")
            self.driver.close()