Пример #1
0
class TestCase316CommandManagerAbnormalStateSendCommand(unittest.TestCase):
    # 测试 设置 - 指令管理 - 模板管理 - 异常状态imei下发指令
    def setUp(self):
        # 前置条件
        # 实例化对象
        self.driver = AutomateDriver(choose='firefox')
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.command_management_page = CommandManagementPage(self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.command_management_page_read_csv = CommandManagementPageReadCsv()
        self.assert_text = AssertText()

        # 打开页面,填写用户名、密码、点击登录
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.implicitly_wait(5)
        self.driver.clear_cookies()
        self.log_in_base.log_in_jimitest()

        # 登录之后点击控制台,然后点击指令管理
        self.command_management_page.click_control_after_click_command_management()
        sleep(3)

    def tearDown(self):
        self.driver.quit_browser()

    def test_case_command_manage_abnormal_state_send_command(self):
        # 断言url
        expect_url_after_click_command_management = self.base_url + '/custom/toTemplate'
        self.assertEqual(expect_url_after_click_command_management,
                         self.command_management_page.actual_url_click_command_management())
        # 断言左侧列表的title文本
        expect_title_text_after_click_command_management = self.assert_text.command_manager_page_command_type()
        self.assertEqual(expect_title_text_after_click_command_management,
                         self.command_management_page.actual_title_text_after_click_command_management())

        # 点击工作模式模板管理
        self.command_management_page.click_lift_list('work_type_template_management')
        # 断言右侧页面的title文本
        expect_title_text_after_click_work_type_template_management = \
            self.assert_text.command_manager_page_work_type_template_management()
        self.assertEqual(expect_title_text_after_click_work_type_template_management,
                         self.command_management_page.actual_title_text_after_click_work_type_template_management())

        # 点击下发指令
        self.command_management_page.click_send_command()

        # 读取数据
        csv_file = self.command_management_page_read_csv.read_csv("send_command_with_abnormal_dev.csv")
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            abnormal_state_data = {
                "state": row[0]
            }

            # 下发指令并获取文本
            send_command_text = self.command_management_page. \
                get_text_after_send_command_with_abnormal_dev(abnormal_state_data["state"])

            # 断言
            self.assertEqual(send_command_text, self.assert_text.
                             text_with_abnormal_dev_send_command(abnormal_state_data["state"]))

            # 关闭提示框
            self.command_management_page.close_send_command_fail_frame()
        csv_file.close()
Пример #2
0
class TestCase303SetUpWorkTypeTemplateManagementCreatTemplate(
        unittest.TestCase):
    # 测试设置 - 指令管理 - 模板管理 - 创建模板
    driver = None
    base_url = None
    base_page = None
    log_in_page = None
    command_management_page = None

    def setUp(self):
        # 前置条件
        # 实例化对象
        self.driver = AutomateDriver(choose='firefox')
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.command_management_page = CommandManagementPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.command_management_page_read_csv = CommandManagementPageReadCsv()
        self.assert_text = AssertText()

        # 打开页面,填写用户名、密码、点击登录
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.implicitly_wait(5)
        self.driver.clear_cookies()
        self.log_in_base.log_in()

        # 登录之后点击控制台,然后点击指令管理
        self.command_management_page.click_control_after_click_command_management(
        )
        sleep(3)

    def tearDown(self):
        self.driver.quit_browser()

    def test_case_set_up_work_type_template_management_creat_template(self):
        # 断言url
        expect_url_after_click_command_management = self.base_url + '/custom/toTemplate'
        self.assertEqual(
            expect_url_after_click_command_management,
            self.command_management_page.actual_url_click_command_management())
        # 断言左侧列表的title文本
        expect_title_text_after_click_command_management = self.assert_text.command_manager_page_command_type(
        )
        self.assertEqual(
            expect_title_text_after_click_command_management,
            self.command_management_page.
            actual_title_text_after_click_command_management())

        # 点击工作模式模板管理
        self.command_management_page.click_lift_list(
            'work_type_template_management')
        # 断言右侧页面的title文本
        expect_title_text_after_click_work_type_template_management = \
            self.assert_text.command_manager_page_work_type_template_management()
        self.assertEqual(
            expect_title_text_after_click_work_type_template_management,
            self.command_management_page.
            actual_title_text_after_click_work_type_template_management())

        # 点击创建模板
        self.command_management_page.click_create_template()
        # 断言打开的创建模板的title文本
        expect_title_text_after_click_create_template = self.assert_text.command_manager_page_new_command_text(
        )
        self.assertEqual(
            expect_title_text_after_click_create_template,
            self.command_management_page.
            actual_title_text_after_click_create_template())
        # 关闭创建模板
        self.command_management_page.click_close_create_template()
        # 断言是否关闭成功
        self.assertEqual(
            expect_title_text_after_click_work_type_template_management,
            self.command_management_page.
            actual_title_text_after_click_work_type_template_management())

        # 点击创建模板
        self.command_management_page.click_create_template()
        # 断言打开的创建模板的title文本
        self.assertEqual(
            expect_title_text_after_click_create_template,
            self.command_management_page.
            actual_title_text_after_click_create_template())
        # 取消创建模板
        self.command_management_page.click_cancel_create_template()
        # 断言是否关闭成功
        self.assertEqual(
            expect_title_text_after_click_work_type_template_management,
            self.command_management_page.
            actual_title_text_after_click_work_type_template_management())

        # 输入参数
        csv_file = self.command_management_page_read_csv.read_csv(
            'work_template_time_data.csv')
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            work_template_time_data = {
                'name': row[0],
                'type': row[1],
                'day': row[2],
                'circulation': row[3],
                'circulation_day': row[4],
                'week': row[5],
                'circulation1': row[6],
                'circulation_day1': row[7],
                'jiange': row[8],
                'circulation2': row[9],
                'circulation_day2': row[10],
            }
            # 点击创建模板
            self.command_management_page.click_create_template()
            # 断言打开的创建模板的title文本
            self.assertEqual(
                expect_title_text_after_click_create_template,
                self.command_management_page.
                actual_title_text_after_click_create_template())
            sleep(5)
            self.command_management_page.add_create_template_data(
                work_template_time_data)
            # 点击保存
            self.command_management_page.create_template_click_ensure()
            sleep(2)
            # 点击删除
            self.command_management_page.delete_add_new_template()
        csv_file.close()
class TestCase307SetUpIssuedWorkTypeManagementSearch(unittest.TestCase):
    # 测试 设置 - 指令管理 - 下发工作模式管理页面搜索

    driver = None
    base_url = None
    base_page = None
    log_in_page = None
    command_management_page = None

    def setUp(self):
        # 前置条件
        # 实例化对象
        self.driver = AutomateDriver(choose='firefox')
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.command_management_page = CommandManagementPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.command_management_page_read_csv = CommandManagementPageReadCsv()
        self.connect_sql = ConnectSql()
        self.search_sql = SearchSql()
        self.assert_text = AssertText()

        # 打开页面,填写用户名、密码、点击登录
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.implicitly_wait(5)
        self.driver.clear_cookies()

        self.log_in_base.log_in_jimitest()
        self.log_in_base.click_account_center_button()
        self.current_account = self.log_in_base.get_log_in_account()

        # 登录之后点击控制台,然后点击指令管理
        self.command_management_page.click_control_after_click_command_management(
        )
        sleep(3)

    def tearDown(self):
        self.driver.quit_browser()

    def test_case_set_up_issued_work_type_management_search(self):
        # 断言url
        expect_url_after_click_command_management = self.base_url + '/custom/toTemplate'
        self.assertEqual(
            expect_url_after_click_command_management,
            self.command_management_page.actual_url_click_command_management())
        # 断言左侧列表的title文本
        expect_title_text_after_click_command_management = self.assert_text.command_manager_page_command_type(
        )
        self.assertEqual(
            expect_title_text_after_click_command_management,
            self.command_management_page.
            actual_title_text_after_click_command_management())
        # 点击下发工作模式管理
        self.command_management_page.click_lift_list(
            'issued_work_type_management')
        # 断言
        expect_title_text_click_issued_work_type = self.assert_text.command_manager_page_issued_work_type(
        )
        self.assertEqual(
            expect_title_text_click_issued_work_type,
            self.command_management_page.actual_text_click_look_equipment())

        # 读取数据
        csv_file = self.command_management_page_read_csv.read_csv(
            'issused_work_template.csv')
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'batch': row[0],
                'execute_state': row[1],
                'state': row[2],
                'imei': row[3]
            }

            # 传入数据
            self.command_management_page.add_data_to_search(search_data)

            # 创建数据库连接
            connect = self.connect_sql.connect_tuqiang_sql()
            # 创建游标
            cursor = connect.cursor()
            # 获取登录账号的ID
            get_current_user_id_sql = \
                "select o.account,o.userId from user_info o where o.account = '" + self.current_account + "';"
            cursor.execute(get_current_user_id_sql)
            user_relation = cursor.fetchall()
            for row1 in user_relation:
                user_id = {'user_account': row1[0], 'user_id': row1[1]}

                # 查询数据库有多少条记录
                get_total_count_sql = self.search_sql.search_issued_work_template_sql(
                    user_id['user_id'], search_data)
                print(get_total_count_sql)
                cursor.execute(get_total_count_sql)
                current_total = cursor.fetchall()
                total_list = []
                for range1 in current_total:
                    for range2 in range1:
                        total_list.append(range2)
                total = len(total_list)
                web_total = self.command_management_page.search_total_number_issued_work_type(
                )
                self.assertEqual(total, web_total)

            cursor.close()
            connect.close()
        csv_file.close()
class TestCase45IssuedWorkTypetTaskManagementSearch(unittest.TestCase):
    """ 发工作模式任务管理搜索功能 """
    # author:邓肖斌
    driver = None
    base_url = None
    base_page = None
    log_in_page = None
    command_management_page = None

    def setUp(self):
        # 前置条件
        # 实例化对象
        self.driver = AutomateDriver(choose='firefox')
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.command_management_page = CommandManagementPage(self.driver, self.base_url)
        self.command_management_page_read_csv = CommandManagementPageReadCsv()
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.connect_sql = ConnectSql()
        self.assert_text = AssertText()
        self.search_sql = SearchSql()

        # 打开页面,填写用户名、密码、点击登录
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.implicitly_wait(5)
        self.driver.clear_cookies()
        self.log_in_base.log_in()
        self.log_in_base.click_account_center_button()
        self.current_account = self.log_in_base.get_log_in_account()

        # 登录之后点击控制台,然后点击指令管理
        self.command_management_page.click_control_after_click_command_management()
        sleep(3)

    def tearDown(self):
        self.driver.quit_browser()

    def test_case_issued_work_type_task_management_search(self):
        # 断言url
        expect_url_after_click_command_management = self.base_url + '/custom/toTemplate'
        self.assertEqual(expect_url_after_click_command_management,
                         self.command_management_page.actual_url_click_command_management())
        # 断言左侧列表的title文本
        expect_title_text_after_click_command_management = self.assert_text.command_manager_page_command_type()
        self.assertEqual(expect_title_text_after_click_command_management,
                         self.command_management_page.actual_title_text_after_click_command_management())

        # 点击工作模式模板管理
        self.command_management_page.click_lift_list('issued_work_type_task_management')
        # 断言
        expect_title_text_after_click_issued_work_type_task_mangagement = \
            self.assert_text.command_manager_page_work_type_task_manager_text()
        self.assertEqual(expect_title_text_after_click_issued_work_type_task_mangagement,
                         self.command_management_page.actual_title_text_click_issued_work_type_task_management())

        csv_file = self.command_management_page_read_csv.read_csv('search_work_type_task_manage_data.csv')
        csv_data = csv.reader(csv_file)
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'number': row[0],
                'name': row[1]
            }
            self.command_management_page.issued_work_type_task_management_search(search_data['number'],
                                                                                 search_data['name'])
            # 创建连接
            connect = self.connect_sql.connect_tuqiang_sql()
            # 创建游标
            cursor = connect.cursor()
            # 获取当前登录账号的usedID
            get_current_user_id_sql = \
                "select o.account,o.userId from user_info o where o.account = '" + self.current_account + "';"
            cursor.execute(get_current_user_id_sql)

            user_relation = cursor.fetchall()
            for row1 in user_relation:
                user_id = {
                    'user_account': row1[0],
                    'user_id': row1[1]
                }
                get_total_sql = self.search_sql.search_work_task_manager_sql(user_id['user_id'], search_data)
                print(get_total_sql)
                cursor.execute(get_total_sql)
                # 读取数据
                total_data = cursor.fetchall()
                # 从数据tuple中获取最终查询记录统计条数
                total_list = []
                for range1 in total_data:
                    for range2 in range1:
                        total_list.append(range2)
                print(total_list)
                total = len(total_list)
                print('本次查询数据库的条数为:%s' % total)
                web_total = self.command_management_page.search_total_number_work_task_manage()
                print('本次查询页面的条数是:%s' % web_total)
                self.assertEqual(total, web_total)
            cursor.close()
            connect.close()
        csv_file.close()
class TestCase309SetUpIssuedCommandTaskManagementSearch(unittest.TestCase):
    # 测试 设置 - 指令管理 - 下发指令任务管理的搜索功能

    driver = None
    base_url = None
    base_page = None
    log_in_page = None
    command_management_page = None
    base_paging_function = None

    def setUp(self):
        # 前置条件
        # 实例化对象
        self.driver = AutomateDriver(choose='firefox')
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.command_management_page = CommandManagementPage(self.driver, self.base_url)
        self.base_paging_function = BasePagingFunction(self.driver, self.base_url)
        self.command_management_page_read_csv = CommandManagementPageReadCsv()
        self.connect_sql = ConnectSql()
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.search_sql = SearchSql()
        self.assert_text = AssertText()

        # 打开页面,填写用户名、密码、点击登录
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.implicitly_wait(5)
        self.driver.clear_cookies()
        self.log_in_base.log_in()
        self.log_in_base.click_account_center_button()
        self.current_account = self.log_in_base.get_log_in_account()

        # 登录之后点击控制台,然后点击指令管理
        self.command_management_page.click_control_after_click_command_management()
        sleep(3)

    def tearDown(self):
        self.driver.quit_browser()

    def test_case_set_up_issued_command_task_management_search(self):
        # 断言url
        expect_url_after_click_command_management = self.base_url + '/custom/toTemplate'
        self.assertEqual(expect_url_after_click_command_management,
                         self.command_management_page.actual_url_click_command_management())
        # 断言左侧列表的title文本
        expect_title_text_after_click_command_management = self.assert_text.command_manager_page_command_type()
        self.assertEqual(expect_title_text_after_click_command_management,
                         self.command_management_page.actual_title_text_after_click_command_management())

        # 点击下发任务指令管理
        self.command_management_page.click_lift_list('issued_command_task_management')
        # 断言
        expect_title_text_after_click_issued_command_task_management = \
            self.assert_text.command_manager_page_issued_command_task()
        self.assertEqual(expect_title_text_after_click_issued_command_task_management,
                         self.command_management_page.actual_text_after_click_issued_command_task())

        csv_file = self.command_management_page_read_csv.read_csv('issued_command_task_management_serach_data.csv')
        csv_data = csv.reader(csv_file)
        i = 1
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'batch': row[0],
                'name': row[1]
            }
            print(search_data)
            self.command_management_page.issued_command_task_add_data_to_search(search_data)

            '''# 建立数据库的连接
            connect = self.connect_sql.connect_tuqiang_sql()
            # 建立游标
            cursor = connect.cursor()
            # 查询登录用户的ID 和 父ID
            get_current_user_id = \
                "select o.userId,o.fullParentId from user_info o where o.account = '" + self.current_account + "';"
            # 执行
            cursor.execute(get_current_user_id)
            user = cursor.fetchall()
            for row1 in user:
                user_info = {
                    'id': row1[0],
                    'fullparent': row1[1]
                }
                # 查询当前登录用户的全部下级
                get_next_id_sql = "select userId from user_info where fullParentId like" + \
                                  "'" + user_info["fullparent"] + user_info["id"] + "%'" + ";"
                # 执行sql脚本
                cursor.execute(get_next_id_sql)
                current_account = cursor.fetchall()
                current_account_list = [user_info['id']]

                for range1 in current_account:
                    for range2 in range1:
                        current_account_list.append(range2)

                current_user_next = tuple(current_account_list)
                print(current_user_next)

                # 查询数据库'''
            # 执行sql
            user_info = self.command_management_page.get_current_user_id(self.current_account)
            all_user_id = self.command_management_page.get_all_user_id(user_info)
            connect = self.connect_sql.connect_tuqiang_sql()
            cursor = connect.cursor()
            search_sql = self.search_sql.search_issued_command_task_management_sql(all_user_id, search_data)
            print(search_sql)
            cursor.execute(search_sql)
            current_total = cursor.fetchall()
            cursor.close()
            connect.close()
            total = len(current_total)
            web_total = self.command_management_page.search_total_number_with_issued_command_task()
            # 断言
            print('第%s次sql查询的结果是%s' % (i, total))
            print('第%s次web查询的结果是%s' % (i, web_total))
            i += 1
            self.assertEqual(total, web_total)
        csv_file.close()
class TestCase51IssuedCommandManagementSearch(unittest.TestCase):
    """ 下发指令管理页面的搜索 """
    # author:邓肖斌

    driver = None
    base_url = None
    base_page = None
    log_in_page = None
    command_management_page = None
    base_paging_function = None

    def setUp(self):
        # 前置条件
        # 实例化对象
        self.driver = AutomateDriver(choose='firefox')
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.command_management_page = CommandManagementPage(
            self.driver, self.base_url)
        self.base_paging_function = BasePagingFunction(self.driver,
                                                       self.base_url)
        self.command_management_page_read_csv = CommandManagementPageReadCsv()
        self.connect_sql = ConnectSql()
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.assert_text = AssertText()

        # 打开页面,填写用户名、密码、点击登录
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.implicitly_wait(5)
        self.driver.clear_cookies()
        self.log_in_base.log_in_jimitest()
        self.log_in_base.click_account_center_button()
        self.current_account = self.log_in_base.get_log_in_account()

        # 登录之后点击控制台,然后点击指令管理
        self.command_management_page.click_control_after_click_command_management(
        )
        sleep(3)

    def tearDown(self):
        self.driver.quit_browser()

    def test_case_issued_command_management_search(self):
        # 断言url
        expect_url_after_click_command_management = self.base_url + '/custom/toTemplate'
        self.assertEqual(
            expect_url_after_click_command_management,
            self.command_management_page.actual_url_click_command_management())
        # 断言左侧列表的title文本
        expect_title_text_after_click_command_management = self.assert_text.command_manager_page_command_type(
        )
        self.assertEqual(
            expect_title_text_after_click_command_management,
            self.command_management_page.
            actual_title_text_after_click_command_management())

        # 点击下发指令管理
        self.command_management_page.click_lift_list(
            'issued_command_management')
        # 断言
        expect_title_text = self.assert_text.command_manager_page_issued_command_manager(
        )
        self.assertEqual(
            expect_title_text,
            self.command_management_page.
            actual_text_after_click_look_equipment())

        # 读csv
        csv_file = self.command_management_page_read_csv.read_csv(
            'issued_command_management_search_data.csv')
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {'imei': row[0], 'batch': row[1], 'statue': row[2]}
            # 添加搜索添加搜索
            self.command_management_page.issued_command_management_search_data(
                search_data)

            # 连接数据库
            connect = self.connect_sql.connect_tuqiang_sql()
            # 建立游标
            cursor = connect.cursor()
            # 查询登录用户的ID 和 父ID
            get_current_user_id_sql = \
                "select o.userId,o.fullParentId from user_info o where o.account = '" + self.current_account + "';"
            # 执行
            cursor.execute(get_current_user_id_sql)
            user = cursor.fetchall()
            print(user)
            for row1 in user:
                user_info = {'id': row1[0], 'fullparent': row1[1]}

                # 判断搜索条件
                get_sql = self.command_management_page. \
                    search_sql_for_issued_command_management_search(user_info['id'], search_data)
                # 执行sql
                print(get_sql)
                cursor.execute(get_sql)

                current_total = cursor.fetchall()
                total_list = []
                for range1 in current_total:
                    for range2 in range1:
                        total_list.append(range2)
                total_num = len(total_list)
                web_total = self.command_management_page.search_total_number_issued_command_management(
                )
                print("网页搜索数量:'%s'" % web_total)
                print("数据库搜索结果:'%s'" % total_num)
                self.assertEqual(total_num, web_total)

            cursor.close()
            connect.close()