class TestCase100GlobAccountSearch(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_global_account_search(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        self.log_in_base.log_in()
        self.log_in_base.click_account_center_button()
        current_account = self.log_in_base.get_log_in_account()
        self.global_dev_search_page.click_easy_search()
        # 关闭
        self.global_dev_search_page.close_search()
        sleep(2)

        self.global_dev_search_page.click_easy_search()
        # self.global_dev_search_page.click_account_search()

        # 度数据
        csv_file = self.global_search_page_read_csv.read_csv('global_search_account_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 = {
                'account_info': row[0]
            }
            self.global_dev_search_page.swith_to_search_frame()
            self.global_dev_search_page.account_easy_search(search_data)

            connect = self.connect_sql.connect_tuqiang_sql()
            # 创建数据库游标
            cur = connect.cursor()

            # 执行sql脚本查询当前登录账号的userId,fullParent
            get_id_sql = "select o.account,o.userId,o.fullParentId from user_info o where o.account = '" + current_account + "' ;"
            cur.execute(get_id_sql)
            # 读取数据
            user_relation = cur.fetchall()
            # 遍历数据
            for row in user_relation:
                user_relation_id = {
                    "account": row[0],
                    "userId": row[1],
                    "fullParent": row[2]
                }

                # 执行sql脚本,根据当前登录账号的userId,fullParent查询出当前账户的所有下级账户
                get_lower_account_sql = "select userId from user_info where fullParentId like" + \
                                        "'" + user_relation_id["fullParent"] + user_relation_id["userId"] + "%'" + ";"
                cur.execute(get_lower_account_sql)
                # 读取数据
                lower_account = cur.fetchall()
                lower_account_list = [user_relation_id["userId"]]
                for range1 in lower_account:
                    for range2 in range1:
                        lower_account_list.append(range2)
                lower_account_tuple = tuple(lower_account_list)

                get_total_sql = self.search_sql.search_account_sqls(lower_account_tuple, search_data)
                print(get_total_sql)
                cur.execute(get_total_sql)
                # 读取数据
                total_data = cur.fetchall()
                # 从数据tuple中获取最终查询记录统计条数
                total_list = []
                for range1 in total_data:
                    for range2 in range1:
                        total_list.append(range2)
                total = len(total_list)
                print('本次查询数据库的条数为:%s' % total)
                web_total = self.global_account_search_page.easy_search_results()
                print('本次查询页面的条数是:%s' % web_total)
                self.assertEqual(total, web_total)
                self.driver.default_frame()
            cur.close()
            connect.close()

        csv_file.close()
        self.global_dev_search_page.close_search()
class TestCase102GlobComplexSearchByAllCondi(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.global_complex_search_page = GlobalComplexSearchPage(
            self.driver, self.base_url)
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_glob_complex_search_complex_search(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录
        self.log_in_base.log_in()
        self.log_in_base.click_account_center_button()
        # 点击全局搜索栏-高级搜素按钮
        # 关闭
        self.global_dev_search_page.click_easy_search()
        self.global_dev_search_page.close_search()
        sleep(2)

        self.global_dev_search_page.click_easy_search()
        # self.global_dev_search_page.click_dev_searchs()
        self.global_dev_search_page.click_senior_search_button()

        csv_file = self.global_search_page_read_csv.read_csv(
            'complex_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 = {
                'account': row[0],
                'base_info': row[1],
                'info': row[2],
                'date_type': row[3],
                'date': row[4],
                'is_date': row[5],
                'arrearage': row[6],
                'no_active': row[7]
            }
            self.global_dev_search_page.swith_to_search_frame()
            self.global_dev_search_page.add_data_to_search_complex(search_data)
            connect = self.connect_sql.connect_tuqiang_sql()
            # 创建数据库游标
            cur = connect.cursor()

            # 执行sql脚本查询当前登录账号的userId,fullParent
            get_id_sql = "select o.account,o.userId,o.fullParentId from user_info o where o.account = '" + search_data[
                'account'] + "' ;"
            cur.execute(get_id_sql)
            # 读取数据
            user_relation = cur.fetchall()
            # 遍历数据
            for row in user_relation:
                user_relation_id = {
                    "account": row[0],
                    "userId": row[1],
                    "fullParent": row[2]
                }
                get_total_sql = self.search_sql.search_complex_sql(
                    user_relation_id['userId'], search_data)
                print(get_total_sql)
                cur.execute(get_total_sql)
                # 读取数据
                total_data = cur.fetchall()
                # 从数据tuple中获取最终查询记录统计条数
                total_list = []
                for range1 in total_data:
                    for range2 in range1:
                        total_list.append(range2)
                total = len(total_list)
                print('本次查询数据库的条数为:%s' % total)
                web_total = self.global_dev_search_page.easy_search_result()
                print('本次查询页面的条数是:%s' % web_total)
                self.assertEqual(total, web_total)
                self.driver.default_frame()
            cur.close()
            connect.close()

        csv_file.close()
Пример #3
0
class TestCase128DevAdvancedSearchWithDeleteUser(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.assert_text = AssertText()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_case_dev_advanced_search_with_delete_user(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        self.log_in_base.log_in()

        self.global_account_search_page.click_cust_manager_button()
        csv_file = self.global_search_page_read_csv.read_csv(
            'new_user_info.csv')
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            add_data = {
                'account_type': row[0],
                'account_name': row[1],
                'account': row[2]
            }
            self.global_account_search_page.click_add_new_user_button()
            self.global_account_search_page.click_close_add_user_page()
            self.global_account_search_page.click_add_new_user_button()
            self.global_dev_search_page.swith_to_search_frames()
            self.global_account_search_page.add_data_to_add_new_user(add_data)
            # 删除
            self.global_account_search_page.search_user_by_account_in_cust_manage(
                add_data['account'])

            self.log_in_base.click_account_center_button()
            self.global_dev_search_page.click_easy_search()
            # 关闭
            self.global_dev_search_page.close_search()
            sleep(2)
            self.global_dev_search_page.click_easy_search()
            # 选择设备搜索--高级搜索
            self.global_dev_search_page.swith_to_search_frame()
            self.global_dev_search_page.click_advanced_search_button()

            # 搜索已经删除的用户名称
            self.global_dev_search_page.click_search_button_in_dev_advanced_search_page(
            )
            # 输入删除的用户名称搜索
            self.global_dev_search_page.add_user_name_to_search_in_dev_advanced_search_page(
                add_data['account'])

            get_text = self.global_dev_search_page.get_text_after_click_search_button_in_dev_advanced_search_page(
            )
            self.assertIn(self.assert_text.account_center_page_no_data_text(),
                          get_text)
            break
        csv_file.close()
class TestCase112UserSearchByDeleteUser(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.assert_text = AssertText()
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_user_search_by_delete_user(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        self.log_in_base.log_in()
        # 分别新建 销售、代理商、用户并删除,然后搜索
        # 点击客户管理

        self.global_account_search_page.click_cust_manager_button()
        csv_file = self.global_search_page_read_csv.read_csv(
            'new_user_info.csv')
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            add_data = {
                'account_type': row[0],
                'account_name': row[1],
                'account': row[2]
            }
            self.global_account_search_page.click_add_new_user_button()
            self.global_account_search_page.click_close_add_user_page()
            self.global_account_search_page.click_add_new_user_button()
            self.global_dev_search_page.swith_to_search_frames()
            self.global_account_search_page.add_data_to_add_new_user(add_data)

            # 先搜索
            self.global_account_search_page.click_global_search_button()
            self.global_account_search_page.click_close_add_user_page()
            self.global_account_search_page.click_global_search_button()
            self.global_dev_search_page.swith_to_search_frames()

            self.global_account_search_page.search_user_by_account_in_global_search(
                add_data['account'])
            get_user_account = self.global_account_search_page.get_user_account_after_search(
            )
            self.assertEqual(get_user_account, add_data['account'])
            self.driver.default_frame()
            self.global_account_search_page.click_close_add_user_page()

            # 删除
            self.global_account_search_page.search_user_by_account_in_cust_manage(
                add_data['account'])

            # 打开全局搜索,搜索用户
            self.global_account_search_page.click_global_search_button()
            self.global_account_search_page.click_close_add_user_page()
            self.global_account_search_page.click_global_search_button()
            self.global_dev_search_page.swith_to_search_frames()

            self.global_account_search_page.search_user_by_account_in_global_search(
                add_data['account'])

            get_text = self.global_account_search_page.get_text_after_search()
            self.assertIn(self.assert_text.account_center_page_no_data_text(),
                          get_text)
            self.driver.default_frame()
            self.global_account_search_page.click_close_add_user_page()
        csv_file.close()