示例#1
0
class TestCase406CustomerManagementOperationControl(unittest.TestCase):
    # 测试客户管理 - 用户操作 - 控制台
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text = AssertText()
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_user_operation_control(self):
        self.base_page.open_page()

        self.log_in_base.log_in()

        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        # 搜索一个客户
        self.cust_manage_lower_account_page.input_search_info('bbb123')
        # 搜索
        self.cust_manage_lower_account_page.click_search_btn()

        # 点击控制台
        current_handle = self.driver.get_current_window_handle()
        # 点击控制台
        self.cust_manage_basic_info_and_add_cust_page.click_control_button()
        all_handles = self.driver.get_all_window_handles()
        for handle in all_handles:
            if handle != current_handle:
                self.driver.switch_to_window(handle)

                # 获取url
                except_url = self.driver.get_current_url()
                self.assertEqual(self.base_url + "/index", except_url)
示例#2
0
class TestCase407CustomerManagementOperationEditUser(unittest.TestCase):
    # 测试客户管理 - 用户操作 - 编辑
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text = AssertText()
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_user_operation_edit_user(self):
        self.base_page.open_page()

        self.log_in_base.log_in()

        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        csv_file = self.cust_manage_page_read_csv.read_csv(
            'edit_user_data.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            info = {
                "user_name": row[0],
                "phone": row[1],
                "email": row[2],
                "conn": row[3],
                "com": row[4]
            }
            # 搜索一个客户
            self.cust_manage_lower_account_page.input_search_info('abc12344')
            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()
            # 获取搜索出来的客户信息
            user_account = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page(
            )
            user_type = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page(
            )
            user_name = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page(
            )
            user_phone = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page(
            )
            user_contact = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page(
            )

            # 点击编辑 - 取消
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            # 点击取消
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
            # 点击编辑
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.add_data_to_edit_user(
                info)
            # 点击取消
            self.driver.default_frame()
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()

            user_account_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page(
            )
            user_type_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page(
            )
            user_name_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page(
            )
            user_phone_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page(
            )
            user_contact_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page(
            )
            self.assertEqual(user_account, user_account_01)
            self.assertEqual(user_type, user_type_01)
            self.assertEqual(user_name, user_name_01)
            self.assertEqual(user_phone, user_phone_01)
            self.assertEqual(user_contact, user_contact_01)

            # 点击编辑 - 取消
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            # 点击取消
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
            # 点击编辑
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.add_data_to_edit_user(
                info)
            # 点击关闭
            self.driver.default_frame()
            self.cust_manage_basic_info_and_add_cust_page.click_close_edit_accunt_button(
            )

            user_account_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page(
            )
            user_type_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page(
            )
            user_name_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page(
            )
            user_phone_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page(
            )
            user_contact_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page(
            )
            self.assertEqual(user_account, user_account_02)
            self.assertEqual(user_type, user_type_02)
            self.assertEqual(user_name, user_name_02)
            self.assertEqual(user_phone, user_phone_02)
            self.assertEqual(user_contact, user_contact_02)

            # 点击编辑 - 取消
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            # 点击取消
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
            # 点击编辑
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.add_data_to_edit_user(
                info)
            # 点击关闭
            self.driver.default_frame()
            self.cust_manage_basic_info_and_add_cust_page.click_ensure()

            user_account_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page(
            )
            user_type_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page(
            )
            user_name_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page(
            )
            user_phone_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page(
            )
            user_contact_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page(
            )
            self.assertEqual(user_account, user_account_03)
            self.assertEqual(user_type, user_type_03)
            self.assertEqual(info['user_name'], user_name_03)
            self.assertEqual(info['phone'], user_phone_03)
            self.assertEqual(info['conn'], user_contact_03)
        csv_file.close()
class TestCase415CustomerManagementEditUserResetPassword(unittest.TestCase):
    # 测试编辑客户 -- 重置密码
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(
            self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text2 = AssertText2()
        self.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

        # 进入客户管理页面
        sleep(2)
        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)
        account = "bbb123"
        # 搜索一个客户
        self.cust_manage_lower_account_page.input_search_info(account)
        # 搜索
        self.cust_manage_lower_account_page.click_search_btn()

        # 点击重置密码
        self.cust_manage_basic_info_and_add_cust_page.click_reset_password_button(
        )
        # 点击取消
        self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()

        # 退出登录
        self.account_center_page_navi_bar.usr_logout()

        self.log_in_base.log_in_with_csv(account, 'jimi123')
        sleep(2)
        hello_usr = self.account_center_page_navi_bar.usr_info_account()
        self.assertIn(account, hello_usr)
        # 退出登录
        self.account_center_page_navi_bar.usr_logout()

        # 登录
        self.log_in_base.log_in()
        # 进入客户管理页面
        current_handle_01 = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle_01)
        # 搜索一个客户
        self.cust_manage_lower_account_page.input_search_info(account)
        # 搜索
        self.cust_manage_lower_account_page.click_search_btn()

        # 点击重置密码
        self.cust_manage_basic_info_and_add_cust_page.click_reset_password_button(
        )
        # 点击取消
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()

        # 退出登录
        self.account_center_page_navi_bar.usr_logout()

        self.log_in_base.log_in_with_csv(account, '888888')

        # 输入新的密码 ,
        self.cust_manage_basic_info_and_add_cust_page.click_new_password(
            'jimi123')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()
        self.cust_manage_basic_info_and_add_cust_page.click_ensuress()
        sleep(4)
        self.log_in_base.log_in_with_csv(account, 'jimi123')
        sleep(2)
        hello_usr = self.account_center_page_navi_bar.usr_info_account()

        self.assertIn(account, hello_usr)
        # 退出登录
        self.account_center_page_navi_bar.usr_logout()
示例#4
0
class TestCase102LoginSuccessWithOrdinaryUser(unittest.TestCase):
    # 测试用户类型的客户
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_page_read_csv = LogInPageReadCsv()
        self.driver.set_window_max()
        self.assert_text = AssertText()
        self.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_ordinary_user_login_by_csv(self):
        '''通过csv测试普通用户账户成功登录和成功退出功能'''
        data = [" 首页", " 设备管理", " 控制台", " 统计报表", " 安全区域", " 设备分布"]

        csv_file = self.log_in_page_read_csv.read_csv(
            'login_with_ordinary_user.csv')
        csv_data = csv.reader(csv_file)

        for row in csv_data:
            user_to_login = {"account": row[0], "passwd": row[1]}

            # 打开途强在线首页-登录页
            self.base_page.open_page()
            # 输入用户信息进行登录
            self.login_page.user_login(user_to_login["account"],
                                       user_to_login["passwd"])
            self.driver.wait(1)
            # 点首页
            self.login_page.click_home_page()
            current_handle = self.driver.get_current_window_handle()
            self.base_page.change_windows_handle(current_handle)
            # 判断登录成功后跳转页面是否正确
            actual_url = self.driver.get_current_url()
            expect_url = self.base_url + "/nomalUserCenter"
            self.assertEqual(expect_url, actual_url, "登录成功后页面跳转错误")

            # 验证模块
            module = self.account_center_page_navi_bar.get_page_module()
            self.assertEqual(data, module, "用户账号登录,模块显示错误")

            # 判断登录成功后招呼栏的用户名是否正确
            usr_info_account = self.account_center_page_navi_bar.usr_info_account(
            )
            company_name = self.login_page.get_company_name()
            user_account = self.login_page.get_user_account()
            user_type = self.login_page.get_user_type()
            user_phone = self.login_page.get_user_phone()
            expect_usr = user_to_login["account"]
            self.assertEqual(expect_usr, usr_info_account)
            self.assertEqual(expect_usr, user_account)
            # 数据库获取登录账号信息
            connect = self.connect_sql.connect_tuqiang_sql()
            cursor = connect.cursor()

            sql = "SELECT o.account,o.type,o.phone,o.companyName FROM user_info o WHERE o.account = '" + user_to_login[
                "account"] + "';"
            cursor.execute(sql)
            user_info = cursor.fetchall()
            current_user_info = []
            for range1 in user_info:
                for range2 in range1:
                    current_user_info.append(range2)
            print(current_user_info)
            # 当前客户类型
            type = self.assert_text.log_in_page_account_type(
                current_user_info[1])
            self.assertEqual(type, user_type)
            # 当前客户公司名
            if current_user_info[3] == '':
                self.assertEqual('', company_name)
            else:
                self.assertEqual(current_user_info[3], company_name)
            # 当前客户电话
            if current_user_info[2] == '':
                self.assertEqual('', user_phone)
            else:
                self.assertEqual(current_user_info[2], user_phone)

            get_account_user_info_sql = "SELECT o.parentId from user_info o WHERE o.account = '" + user_to_login[
                "account"] + "';"
            cursor.execute(get_account_user_info_sql)
            get_account_user_info = cursor.fetchall()
            current_user_info = []
            for range1 in get_account_user_info:
                for range2 in range1:
                    current_user_info.append(range2)

            get_up_account_info_sql = "SELECT o.account,o.contact,o.phone FROM user_info o WHERE o.userId = '" + \
                                      current_user_info[0] + "';"
            cursor.execute(get_up_account_info_sql)
            get_up_user_info = cursor.fetchall()
            up_user_info = []
            for range1 in get_up_user_info:
                for range2 in range1:
                    up_user_info.append(range2)
            print(up_user_info)

            # 获取上级客户的信息
            up_user_account = self.login_page.get_up_user_account()
            up_user_contact = self.login_page.get_up_user_contact()
            up_user_phone = self.login_page.get_up_user_phone()
            self.assertEqual(up_user_info[0], up_user_account)
            self.assertEqual(up_user_info[1], up_user_contact)
            self.assertEqual(up_user_info[2], up_user_phone)

            # 成功退出系统
            sleep(2)
            self.account_center_page_navi_bar.usr_log_out()

            # 判断是否成功退出到登录页
            self.assertEqual(self.base_url + "/",
                             self.driver.get_current_url(), "退出系统失败")
            cursor.close()
            connect.close()
        csv_file.close()
示例#5
0
class TestCase203UserCenterModifyPasswd(unittest.TestCase):
    # 测试个人中心-修改密码
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_user_center_modify_info(self):
        # 通过csv测试修改密码功能
        csv_file = self.account_center_page_read_csv.read_csv(
            'user_to_modify_passwd.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            user_to_modify_passwd = {
                "account": row[0],
                "old_passwd": row[1],
                "new_passwd": row[2],
            }

            # 打开途强在线首页-登录页
            self.base_page.open_page()
            # 登录账号
            self.login_page.user_login(user_to_modify_passwd["account"],
                                       user_to_modify_passwd["old_passwd"])
            self.driver.wait()
            current_handle_01 = self.driver.get_current_window_handle()
            self.account_center_page_navi_bar.click_account_center_button()
            self.base_page.change_windows_handle(current_handle_01)
            # 招呼栏修改资料
            modify_status = self.account_center_page_navi_bar.modify_user_passwd(
                user_to_modify_passwd["old_passwd"],
                user_to_modify_passwd["new_passwd"])
            self.account_center_page_navi_bar.modify_passwd_success_comfrim()
            # 判断点击确定后是否关闭弹框并回到登录页
            self.assertEqual(self.base_url + "/",
                             self.driver.get_current_url(), "修改成功后页面跳转错误")

            # 使用旧密码登录
            self.login_page.user_login(user_to_modify_passwd["account"],
                                       user_to_modify_passwd["old_passwd"])
            self.assertEqual(self.assert_text.log_in_page_password_error(),
                             self.login_page.get_exception_text())

            # 新密码登录账号
            self.login_page.user_login(user_to_modify_passwd["account"],
                                       user_to_modify_passwd["new_passwd"])

            self.driver.wait()
            current_handle_02 = self.driver.get_current_window_handle()
            self.account_center_page_navi_bar.click_account_center_button()
            self.base_page.change_windows_handle(current_handle_02)
            # 招呼栏修改资料
            modify_status = self.account_center_page_navi_bar.modify_user_passwd(
                user_to_modify_passwd["new_passwd"],
                user_to_modify_passwd["old_passwd"])
            self.account_center_page_navi_bar.modify_passwd_success_comfrim()
            # 判断点击确定后是否关闭弹框并回到登录页
            self.assertEqual(self.base_url + "/",
                             self.driver.get_current_url(), "修改成功后页面跳转错误")
        csv_file.close()
示例#6
0
class TestCase410CustomerManagementEditUserWebLoginLimit(unittest.TestCase):
    # 测试编辑客户 -- 修改用户web登录权限
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(
            self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text2 = AssertText2()
        self.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

        # 进入客户管理页面
        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        # 搜索一个客户
        self.cust_manage_lower_account_page.input_search_info('abc12344')
        # 搜索
        self.cust_manage_lower_account_page.click_search_btn()
        user_account = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page(
        )

        # 点击编辑 - 取消
        self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
        )
        # 点击取消
        self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
        # 点击编辑
        self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
        )

        # 获取web登录权限的
        self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
        web_login_status = self.cust_manage_basic_info_and_add_cust_page.get_web_login_status(
        )
        self.driver.default_frame()

        if web_login_status == True:
            # 点击
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.click_web_login_status_ins(
            )
            self.driver.default_frame()

            # 确定
            self.cust_manage_basic_info_and_add_cust_page.click_ensure()

            # 退出登录
            self.account_center_page_navi_bar.usr_logout()

            # 登录刚刚的账号
            self.log_in_base.log_in_with_csv(user_account, 'jimi123')

            self.assertEqual(self.assert_text2.login_no_permissions(),
                             self.login_page.get_exception_text())

            # 登录
            self.log_in_base.log_in()

            current_handle_01 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            self.base_page.change_windows_handle(current_handle_01)

            # 搜索一个客户
            self.cust_manage_lower_account_page.input_search_info('abc12344')
            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()
            # 点击编辑 - 取消
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            # 点击取消
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
            # 点击编辑
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )

            # 点击
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.click_web_login_status_ins(
            )
            self.driver.default_frame()

            self.cust_manage_basic_info_and_add_cust_page.click_ensure()

            # 退出登录
            self.account_center_page_navi_bar.usr_logout()

            # 登录刚刚的账号
            self.log_in_base.log_in_with_csv(user_account, 'jimi123')

            hello_usr = self.account_center_page_navi_bar.usr_info_account()
            self.assertIn(user_account, hello_usr)

        elif web_login_status == False:
            # 点击
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.click_web_login_status_ins(
            )
            self.driver.default_frame()
            self.cust_manage_basic_info_and_add_cust_page.click_ensure()
            # 退出登录
            self.account_center_page_navi_bar.usr_logout()
            # 登录刚刚的账号
            self.log_in_base.log_in_with_csv(user_account, 'jimi123')
            hello_usr = self.account_center_page_navi_bar.usr_info_account()
            self.assertIn(user_account, hello_usr)

            # 退出登录
            self.account_center_page_navi_bar.usr_logout()
            self.log_in_base.log_in()

            current_handle_02 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            self.base_page.change_windows_handle(current_handle_02)

            # 搜索一个客户
            self.cust_manage_lower_account_page.input_search_info('abc12344')
            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()
            # 点击编辑 - 取消
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            # 点击取消
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
            # 点击编辑
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )

            # 点击
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.click_web_login_status_ins(
            )
            self.driver.default_frame()

            # 确定
            self.cust_manage_basic_info_and_add_cust_page.click_ensure()
            # 退出登录
            self.account_center_page_navi_bar.usr_logout()
            # 登录刚刚的账号
            self.log_in_base.log_in_with_csv(user_account, 'jimi123')
            self.assertEqual(self.assert_text2.login_no_permissions(),
                             self.login_page.get_exception_text())

            self.log_in_base.log_in()

            current_handle_03 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            self.base_page.change_windows_handle(current_handle_03)

            # 搜索一个客户
            self.cust_manage_lower_account_page.input_search_info('abc12344')
            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()
            # 点击编辑 - 取消
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            # 点击取消
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
            # 点击编辑
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )

            # 点击
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.click_web_login_status_ins(
            )
            self.driver.default_frame()

            # 确定
            self.cust_manage_basic_info_and_add_cust_page.click_ensure()
class TestCase210UserCenterLoginLog(unittest.TestCase):
    # 测试登录日志查询
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.help_page = HelpPage(self.driver, self.base_url)
        self.account_center_page_operation_log = AccountCenterOperationLogPage(
            self.driver, self.base_url)
        self.help_page_sql = HelpPageSql()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.connect_sql = ConnectSql()
        self.connect_es = ConnectEs()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_user_center_login_log(self):
        self.base_page.open_page()
        self.log_in_base.log_in()
        sleep(3)
        current_handle = self.driver.get_current_window_handle()
        self.log_in_base.click_account_center_button()
        self.base_page.change_windows_handle(current_handle)

        # 获取登录账号的用户名
        current_account = self.log_in_base.get_log_in_account()

        # 点击招呼栏-业务日志
        self.account_center_page_operation_log.click_help_button()
        self.help_page.click_log_in_log()
        # 判断当前页面是否正确跳转至业务日志页面
        expect_url = self.base_url + "/userFeedback/toHelp"
        self.assertEqual(expect_url, self.driver.get_current_url(), "当前页面跳转错误")

        i = 0
        csv_file = self.account_center_page_read_csv.read_csv(
            'search_log_in_log_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],
                'begin_time': row[1],
                'end_time': row[2]
            }
            self.help_page.search_login_log(search_data)

            # 获取当前登录账号和下级账号全部的userid
            all_user_id = self.help_page.get_all_user_id(current_account)
            print(all_user_id)
            '''connect = self.connect_sql.connect_tuqiang_sql()
            cursor = connect.cursor()
            get_total_sql = self.help_page_sql.search_log_in_sql(all_user_id, search_data)
            cursor.execute(get_total_sql)
            total_list = cursor.fetchall()
            cursor.close()
            connect.close()'''
            # 连接Elastic search
            es = self.connect_es.connect_es()
            # 搜索的数据
            query_data = self.help_page.get_search_log_in_log_query_data(
                all_user_id, search_data)
            res_01 = es.search(index='userlogin_log_2',
                               body={
                                   'query': query_data,
                                   'size': 20000
                               })
            res_02 = es.search(index='userlogin_log_12',
                               body={
                                   'query': query_data,
                                   'size': 20000
                               })
            res_03 = es.search(index='userlogin_log_1',
                               body={
                                   'query': query_data,
                                   'size': 20000
                               })
            total = len(res_01['hits']['hits']) + len(
                res_02['hits']['hits']) + len(res_03['hits']['hits'])
            i += 1
            print('第%s次查询数据库的条数为:%s' % (i, total))
            web_total = self.help_page.get_current_login_log()
            print('第%s次查询页面的条数是:%s' % (i, web_total))
            if total != 0:
                total += 10
            self.assertEqual(total, web_total)

        csv_file.close()
class TestCase206UserCenterDevLog(unittest.TestCase):
    # 测试个人中心 - 帮助 - 业务日志 - 设备管理日志(设备修改和设备分配)
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.help_page = HelpPage(self.driver, self.base_url)
        self.account_center_page_operation_log = AccountCenterOperationLogPage(
            self.driver, self.base_url)
        self.help_page_sql = HelpPageSql()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.connect_sql = ConnectSql()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.user_center_page = UserCenterPage(self.driver, self.base_url)
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_user_center_dev_log(self):
        self.base_page.open_page()
        self.log_in_base.log_in()
        user_account = self.log_in_base.get_log_in_account()

        # 点击设备管理
        current_handle = self.driver.get_current_window_handle()
        self.user_center_page.click_dev_management_button()
        sleep(3)
        self.base_page.change_windows_handle(current_handle)
        # 获取列表第一个imei号
        sleep(3)
        imei = self.user_center_page.get_dev_list_first_imei()
        # 点击编辑
        self.user_center_page.click_edit_dev_button()
        # 点击确定
        self.user_center_page.click_ensure_button()

        # 销售
        self.user_center_page.click_sale_button()

        # 进入帮助 - 业务日志页面
        current_handle_01 = self.driver.get_current_window_handle()
        self.user_center_page.click_user_center_button()
        self.base_page.change_windows_handle(current_handle_01)
        # 点击帮助
        self.user_center_page.click_help_button()
        # 切换到业务日志的frame里面
        self.user_center_page.switch_to_business_frame()

        self.user_center_page.click_search_button_in_business_log()

        # 获取第一条数据的操作人、目标账号、操作平台、描述
        sleep(3)
        operation = self.user_center_page.get_operation_in_business_log()
        target_account = self.user_center_page.get_target_account_in_business_log(
        )
        operation_platform = self.user_center_page.get_operation_platform_in_business_log(
        )
        desc = self.user_center_page.get_desc_in_business_log()
        self.assertEqual(' ' + user_account, operation)
        self.assertEqual(target_account, user_account)
        self.assertEqual('网页端', operation_platform)

        web_desc = "%s修改设备%s" % (user_account, imei)
        self.assertEqual(web_desc, desc)

        # 选择设备分配搜索
        self.user_center_page.search_dev_sale_in_business_log()
        # 点击搜索
        self.user_center_page.click_search_button_in_business_log()

        operation_01 = self.user_center_page.get_operation_in_business_log()
        target_account_01 = self.user_center_page.get_target_account_in_business_log(
        )
        operation_platform_01 = self.user_center_page.get_operation_platform_in_business_log(
        )
        desc_01 = self.user_center_page.get_desc_in_business_log()

        self.assertEqual(' ' + user_account, operation_01)
        self.assertEqual(target_account_01, user_account)
        self.assertEqual('网页端', operation_platform_01)

        web_desc_01 = "%s将设备%s从%s分配给%s" % (user_account, imei, user_account,
                                           user_account)
        self.assertEqual(web_desc_01, desc_01)
        self.driver.default_frame()
class TestCase105LoginWithRememberMe(unittest.TestCase):
    # 测试记住密码
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.driver.set_window_max()
        self.driver.wait(1)

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

    def test_login_with_remember_me(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        self.log_in_base.log_in()
        # 点账户中心
        current_handle = self.driver.get_current_window_handle()
        self.account_center_page_navi_bar.click_account_center_button()
        self.base_page.change_windows_handle(current_handle)

        # 判断登录成功后跳转页面是否正确
        actual_url = self.driver.get_current_url()
        expect_url = self.base_url + "/customer/toAccountCenter"
        self.assertEqual(expect_url, actual_url, "登录成功后页面跳转错误")

        sleep(1)
        # 成功退出系统
        self.account_center_page_navi_bar.usr_logout()
        # 判断是否成功退出系统
        self.assertEqual(self.base_url + "/", self.driver.get_current_url(), "退出系统失败")
        # 验证退出系统后“记住我”是否是已勾选状态
        box_status = self.login_page.check_remember_me()
        self.assertEqual(True, box_status, '记住密码失败')

        # 点击登录按钮
        self.login_page.click_log_in_button()
        # 点账户中心
        current_handle = self.driver.get_current_window_handle()
        self.account_center_page_navi_bar.click_account_center_button()
        self.base_page.change_windows_handle(current_handle)

        actual_url = self.driver.get_current_url()
        expect_url = self.base_url + "/customer/toAccountCenter"
        self.assertEqual(expect_url, actual_url, "登录成功后页面跳转错误")

        # 再次退出
        # 成功退出系统
        self.account_center_page_navi_bar.usr_logout()
        # 判断是否成功退出系统
        self.assertEqual(self.base_url + "/", self.driver.get_current_url(), "退出系统失败")
        # 验证退出系统后“记住我”是否是已勾选状态
        box_status = self.login_page.check_remember_me()
        self.assertEqual(True, box_status, '记住密码失败')

        # 点击记住我的框,取消登录时记住我
        self.account_center_page_navi_bar.click_remember_me_button()
        box_status = self.login_page.check_remember_me()
        self.assertEqual(False, box_status, '记住密码失败')

        # 点击登录按钮
        self.login_page.click_log_in_button()
        # 点账户中心
        current_handle = self.driver.get_current_window_handle()
        self.account_center_page_navi_bar.click_account_center_button()
        self.base_page.change_windows_handle(current_handle)

        actual_url = self.driver.get_current_url()
        expect_url = self.base_url + "/customer/toAccountCenter"
        self.assertEqual(expect_url, actual_url, "登录成功后页面跳转错误")

        self.account_center_page_navi_bar.usr_logout()
        # 判断是否成功退出系统
        self.assertEqual(self.base_url + "/", self.driver.get_current_url(), "退出系统失败")
        # 验证退出系统后“记住我”是否是已勾选状态
        box_status = self.login_page.check_remember_me()
        self.assertEqual(False, box_status, '记住密码失败')
示例#10
0
class TestCase403CustomerManagementAddUser(unittest.TestCase):
    # 测试 客户管理 新增客户
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(
            self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.assert_text2 = AssertText2()
        self.search_sql = SearchSql()
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.connect_sql = ConnectSql()
        self.assert_text = AssertText()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_cust_manage_add_acc(self):
        '''测试客户管理-新增用户'''

        # 打开途强在线首页-登录页
        self.base_page.open_page()

        # 登录
        self.log_in_base.log_in()

        # 进入客户管理页面
        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        self.cust_manage_basic_info_and_add_cust_page.add_acc()
        self.cust_manage_basic_info_and_add_cust_page.close_add_account()

        csv_file = self.cust_manage_page_read_csv.read_csv('acc_add.csv')
        csv_data = csv.reader(csv_file)

        for row in csv_data:
            add_info = {
                "keyword": row[0],
                "acc_type": row[1],
                "acc_name": row[2],
                "account": row[3],
                "passwd": row[4],
                "phone": row[5],
                "email": row[6],
                "conn": row[7],
                "com": row[8],
                "search_user": row[9]
            }

            # 左侧客户列表搜索并选中唯一客户
            self.cust_manage_cust_list_page.acc_exact_search(
                add_info["keyword"])

            # 点击新增用户
            self.cust_manage_basic_info_and_add_cust_page.add_acc()
            sleep(2)

            # 验证所选中的上级用户类型来显示可创建的下级类型
            user_list = add_info["search_user"].split("/")
            for type in user_list:
                self.cust_manage_basic_info_and_add_cust_page.acc_search(type)
                type_list = self.cust_manage_basic_info_and_add_cust_page.get_acc_user_type_list(
                )
                sql_data = self.search_sql.search_current_account_data(type)
                user_type = self.assert_text.log_in_page_account_type(
                    sql_data[2])
                print(user_type)

                if user_type == "销售":
                    self.assertEqual(3, type_list["length"])
                    self.assertIn(
                        self.assert_text.log_in_page_account_type(11),
                        type_list["sale"])
                    self.assertIn(self.assert_text.log_in_page_account_type(8),
                                  type_list["distributor"])
                    self.assertIn(self.assert_text.log_in_page_account_type(9),
                                  type_list["user"])

                elif user_type == "代理商":
                    self.assertEqual(2, type_list["length"])
                    self.assertIn(self.assert_text.log_in_page_account_type(8),
                                  type_list["distributor"])
                    self.assertIn(self.assert_text.log_in_page_account_type(9),
                                  type_list["user"])

                elif user_type == "用户":
                    self.assertNotEqual(1, type_list["length"])
                    # self.assertIn(self.assert_text.log_in_page_account_type(9),type_list["user"])
                sleep(1)
            # 添加用户类型获取提示
            self.cust_manage_basic_info_and_add_cust_page.acc_search(
                "yonghu222")
            sleep(2)
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.driver.default_frame()

            # 右侧搜索栏中搜索并选中作为上级用户
            self.cust_manage_basic_info_and_add_cust_page.acc_search(
                add_info["keyword"])
            # 选择客户类型
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.acc_type_choose(
                add_info["acc_type"])
            # 编辑用户输入框信息
            self.cust_manage_basic_info_and_add_cust_page.add_acc_input_info_edit(
                add_info["acc_name"], add_info["account"], add_info["passwd"],
                add_info["phone"], add_info["email"], add_info["conn"],
                add_info["com"])
            # 修改用户登录权限
            self.cust_manage_basic_info_and_add_cust_page.acc_login_limit_modi(
            )
            self.driver.default_frame()
            self.cust_manage_basic_info_and_add_cust_page.acc_add_save()

            # 获取保存操作状态
            status = self.cust_manage_basic_info_and_add_cust_page.acc_info_save_status(
            )
            # 验证是否操作成功
            self.assertIn(
                self.assert_text.account_center_page_operation_done(), status,
                "操作失败")

            # 搜索新增客户
            sleep(4)
            self.cust_manage_lower_account_page.input_search_info(
                add_info["account"])

            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()

            # 删除该新增客户
            self.cust_manage_lower_account_page.delete_acc()

            # 确定删除
            self.cust_manage_lower_account_page.delete_acc_ensure()

            # 获取删除操作状态
            del_status = self.cust_manage_lower_account_page.get_del_status()

            # 验证是否操作成功
            self.assertIn(
                self.assert_text.account_center_page_operation_done(),
                del_status, "操作失败")

        csv_file.close()
示例#11
0
class TestCase204UserCenterModifyPassword2(unittest.TestCase):
    # 测试个人中心 - 修改密码异常
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.clear_cookies()

    def test_modify_password_exception(self):

        self.log_in_base.log_in()
        current_handle = self.driver.get_current_window_handle()
        self.account_center_page_navi_bar.click_account_center_button()
        self.base_page.change_windows_handle(current_handle)
        self.driver.wait(1)
        # 点击招呼栏的修改密码
        self.account_center_page_navi_bar.click_modify_usr_password()

        csv_find = self.account_center_page_read_csv.read_csv(
            "modify_password_exception.csv")
        csv_data = csv.reader(csv_find)
        for row in csv_data:
            data = {
                "old_password": row[0],
                "new_password": row[1],
                "new_password2": row[2],
                "old_pwd_prompt": row[3],
                "new_pwd_prompt": row[4],
                "new_pwd2_prompt": row[5]
            }

            all_prompt = self.account_center_page_navi_bar.get_modify_pwd_exception_prompt(
                data)

            self.assertEqual(data["old_pwd_prompt"], all_prompt["old_Pwd"],
                             "修改密码,旧密码错误提示语显示不一致")

            self.assertEqual(data["new_pwd_prompt"], all_prompt["new_Pwd"],
                             "修改密码,新密码提示语显示不一致")

            self.assertEqual(data["new_pwd2_prompt"], all_prompt["new_Pwd2"],
                             "修改密码,确认新密码提示语显示不一致")

            try:
                self.assertEqual("原密码不正确", all_prompt["text"], "修改密码,提示语显示不一致")
            except:
                print("没有原密码不正确的提示")

        csv_find.close()
        # 关闭修改资料框
        self.account_center_page_navi_bar.click_password_cancel()
        self.driver.wait(1)
        # 退出
        self.account_center_page_navi_bar.usr_logout()

    def tearDown(self):
        self.driver.quit_browser()
class TestCase103LoginSuccessWithphAppUser(unittest.TestCase):
    # 测试app用户登录
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url)
        self.log_in_read_csv = LogInPageReadCsv()
        self.connect_sql = ConnectSql()
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_app_user_login_by_csv(self):
        '''通过csv测试app账户成功登录和成功退出功能'''
        data = [" 首页", " 设备管理", " 控制台", " 统计报表", " 安全区域", " 设备分布"]

        csv_file = self.log_in_read_csv.read_csv('login_with_app_user.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            user_to_login = {
                "account": row[0],
                "passwd": row[1]
            }
            # 打开途强在线首页-登录页
            self.base_page.open_page()
            # 输入用户信息进行登录
            self.login_page.user_login(user_to_login["account"], user_to_login["passwd"])
            # 点首页
            current_handle = self.driver.get_current_window_handle()
            self.login_page.click_home_page()
            self.base_page.change_windows_handle(current_handle)
            # 判断登录成功后跳转页面是否正确
            actual_url = self.driver.get_current_url()
            expect_url = self.base_url + "/nomalUserCenter"
            self.assertEqual(expect_url, actual_url, "登录成功后页面跳转错误")

            # 验证模块
            module = self.account_center_page_navi_bar.get_page_module()
            self.assertEqual(data, module, "用户账号登录,模块显示错误")

            # 判断登录成功后招呼栏的用户名是否正确
            hello_usr = self.account_center_page_navi_bar.hello_user_account()
            expect_usr = user_to_login["account"]
            self.assertEqual(expect_usr, hello_usr, "登录成功后招呼栏账户名显示错误")

            # 获取登录app用户的信息
            user_account = self.login_page.get_user_account()
            user_type = self.login_page.get_user_type()
            user_phone = self.login_page.get_user_phone()
            connect = self.connect_sql.connect_tuqiang_sql()
            cursor = connect.cursor()

            sql = "SELECT o.account,o.type,o.phone,o.companyName FROM user_info o WHERE o.account = '" + user_to_login[
                "account"] + "';"
            cursor.execute(sql)
            user_info = cursor.fetchall()
            current_user_info = []
            for range1 in user_info:
                for range2 in range1:
                    current_user_info.append(range2)
            print(current_user_info)
            # 当前客户类型
            type = self.assert_text.log_in_page_account_type(current_user_info[1])
            self.assertEqual(type, user_type)
            # 当前客户电话
            if current_user_info[2] == '':
                self.assertEqual('', user_phone)
            else:
                self.assertEqual(current_user_info[2], user_phone)


            # 获取当前app账号有几个服务商
            service_number = self.account_center_page_details.get_current_account_service_number()

            # 获取数据库服务商的个数
            get_up_account_info_sql = "select userId from user_info where account = '%s';" % user_to_login['account']

            cursor.execute(get_up_account_info_sql)
            get_up_user_info = cursor.fetchall()
            get_current_id = []
            for range1 in get_up_user_info:
                for range2 in range1:
                    get_current_id.append(range2)
            print(get_current_id)

            get_service_sql = "select userId from equipment_mostly where bindUserId = '" + get_current_id[
                0] + "' group by userId ;"
            cursor.execute(get_service_sql)
            get_service = cursor.fetchall()
            service_number_list = []
            for range1 in get_service:
                for range2 in range1:
                    service_number_list.append(range2)
            service_total = len(service_number_list)
            cursor.close()
            connect.close()
            # 断言
            self.assertEqual(service_number, service_total)

            # 成功退出系统
            sleep(2)
            self.account_center_page_navi_bar.app_usr_logout()
            # 判断是否成功退出到登录页
            self.assertEqual(self.base_url + "/", self.driver.get_current_url(), "退出系统失败")
        csv_file.close()
示例#13
0
class TestCase101LoginSuccessWithSalesAndAgent(unittest.TestCase):
    # 测试登录代理商和销售类型的客户
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url)
        self.log_in_read_csv = LogInPageReadCsv()
        self.connect_sql = ConnectSql()
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_sales_and_agent_login_by_csv(self):
        # 通过csv测试销售和代理商账户成功登录和成功退出功能

        csv_file = self.log_in_read_csv.read_csv('login_with_sales_and_agent_user.csv')
        csv_data = csv.reader(csv_file)
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            user_to_login = {
                "account": row[0],
                "passwd": row[1]
            }
            # 打开途强在线首页-登录页
            self.base_page.open_page()
            # 输入用户信息进行登录
            self.login_page.user_login(user_to_login["account"], user_to_login["passwd"])
            # 点账户中心
            current_handle = self.driver.get_current_window_handle()
            print('handle', current_handle)
            self.account_center_page_navi_bar.click_account_center_button()
            self.base_page.change_windows_handle(current_handle)

            # 判断登录成功后跳转页面是否正确
            actual_url = self.driver.get_current_url()
            expect_url = self.base_url + "/customer/toAccountCenter"
            self.assertEqual(expect_url, actual_url, "登录成功后页面跳转错误")
            sleep(1)
            # 断言当前登录账号的用户名
            usr_info_account = self.account_center_page_navi_bar.usr_info_account()
            expect_usr_info_account = user_to_login["account"]
            self.assertIn(expect_usr_info_account, usr_info_account, "账户总览左下方显示的账户错误")

            connect = self.connect_sql.connect_tuqiang_sql()
            cursor = connect.cursor()
            get_account_user_info_sql = "SELECT o.type,o.phone,o.parentId,o.nickName,o.companyName from user_info o WHERE o.account = '" + \
                                        user_to_login['account'] + "';"
            cursor.execute(get_account_user_info_sql)
            get_account_user_info = cursor.fetchall()
            current_user_info = []
            for range1 in get_account_user_info:
                for range2 in range1:
                    current_user_info.append(range2)
            cursor.close()
            connect.close()
            print("当前号", current_user_info)

            # 客户名称
            user_name = self.login_page.get_user_name()
            self.assertEqual(user_name, current_user_info[3])

            # 获取登录之后用户的公司名称
            company_name = self.login_page.get_company_name()
            if current_user_info[4] == '':
                self.assertEqual('', company_name)
            else:
                self.assertEqual(current_user_info[4], company_name)

            # 客户类型
            type = self.assert_text.log_in_page_account_type(current_user_info[0])
            usr_info_type = self.login_page.get_account_user_type()
            self.assertEqual(type, usr_info_type, "账户总览左下方显示的客户类型错误")

            # 电话
            usr_info_phone = self.login_page.get_account_user_telephone()
            expect_usr_info_phone = current_user_info[1]
            if expect_usr_info_phone == None:
                self.assertEqual("", usr_info_phone, "账户总览左下方显示的客户电话错误")
            else:
                self.assertEqual(expect_usr_info_phone, usr_info_phone, "账户总览左下方显示的客户电话错误")
            # 成功退出系统
            sleep(2)

            self.account_center_page_navi_bar.usr_logout()
            # 判断是否成功退出到登录页
            self.assertEqual(self.base_url + "/", self.driver.get_current_url(), "退出系统失败")
        csv_file.close()
示例#14
0
class TestCase409CustomerManagementEditUserExpection(unittest.TestCase):
    # 测试编辑客户--异常操作验证
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(
            self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text = AssertText()
        self.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

        # 进入客户管理页面
        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        # 搜索一个客户
        self.cust_manage_lower_account_page.input_search_info('abc12344')
        # 搜索
        self.cust_manage_lower_account_page.click_search_btn()

        # 点击编辑 - 取消
        self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
        )
        # 点击取消
        self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
        # 点击编辑
        self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
        )

        # 验证上级客户input的属性是否为readonly
        readonly_value = self.cust_manage_basic_info_and_add_cust_page.get_up_account_value(
        )
        self.assertEqual('true', readonly_value)

        # 验证新增客户的名称
        # 1 为空
        self.cust_manage_basic_info_and_add_cust_page.add_account_name('')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()
        text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_name_exception_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_name_not_null(), text)

        # 2 长度小于三位
        self.cust_manage_basic_info_and_add_cust_page.add_account_name('1')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()
        text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_name_exception_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_name_more_than_3(),
                         text)

        # 3 验证最大长度
        max_len = self.cust_manage_basic_info_and_add_cust_page.get_account_name_max_len(
        )
        self.assertEqual('50', max_len)

        # 验证电话、邮箱、联系人、公司名的最大长度
        phone_max_len = self.cust_manage_basic_info_and_add_cust_page.get_phone_max_len(
        )
        self.assertEqual('20', phone_max_len)

        email_max_len = self.cust_manage_basic_info_and_add_cust_page.get_email_max_len(
        )
        self.assertEqual('50', email_max_len)
        # 验证邮箱格式
        self.cust_manage_basic_info_and_add_cust_page.add_email_format(
            '123123')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()
        get_text_email = self.cust_manage_basic_info_and_add_cust_page.get_text_email_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_email_formate_error(),
                         get_text_email)

        connect_max_len = self.cust_manage_basic_info_and_add_cust_page.get_connect_max_len(
        )
        self.assertEqual('50', connect_max_len)

        comp_max_len = self.cust_manage_basic_info_and_add_cust_page.get_comp_max_len(
        )
        self.assertEqual('50', comp_max_len)
class TestCase208UserCenterSafeAreaLog(unittest.TestCase):
    # 测试个人中心 - 帮助 - 业务日志 - 安全区域管理日志(编辑、删除、关联、删除关联)
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.help_page = HelpPage(self.driver, self.base_url)
        self.account_center_page_operation_log = AccountCenterOperationLogPage(self.driver, self.base_url)
        self.help_page_sql = HelpPageSql()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.connect_sql = ConnectSql()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.user_center_page = UserCenterPage(self.driver, self.base_url)
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_user_center_safe_area_log(self):
        self.base_page.open_page()
        self.log_in_base.log_in()
        user_account = self.log_in_base.get_log_in_account()

        # 点击安全区域
        current_handle = self.driver.get_current_window_handle()
        self.user_center_page.click_safe_area_button()
        self.base_page.change_windows_handle(current_handle)

        # 搜索平台围栏
        self.user_center_page.search_platform_fence()
        # 获取第一个围栏的名称
        fence_name = self.user_center_page.get_first_fence_name()

        # 点击编辑
        self.user_center_page.click_edit_fence_button()
        # 点击保存
        self.user_center_page.click_ensure_button()

        # 点击关联
        self.user_center_page.click_relevance_fence_button()
        # 选择设备进行关联
        imei_01 = self.user_center_page.click_dev_relevance_fence()
        # 点击保存
        self.user_center_page.click_ensure_button()

        # 取消关联
        self.user_center_page.click_relevance_fence_button()
        # 选择设备进行关联
        imei_02 = self.user_center_page.click_dev_relevance_fence()
        # 点击保存
        self.user_center_page.click_ensure_button()

        # 进入帮助 - 业务日志页面
        self.user_center_page.click_user_center_button()
        # 点击帮助
        self.user_center_page.click_help_button()
        # 切换到业务日志的frame里面
        self.user_center_page.switch_to_business_frame()

        # 选择安全区域查询 - 新增、编辑
        self.user_center_page.select_safe_area_search()
        self.user_center_page.select_edit_safe_area_search()
        sleep(5)

        operation_01 = self.user_center_page.get_operation_in_business_log()
        target_account_01 = self.user_center_page.get_target_account_in_business_log()
        operation_platform_01 = self.user_center_page.get_operation_platform_in_business_log()
        desc_01 = self.user_center_page.get_desc_in_business_log()

        self.assertEqual(operation_01, ' ' + user_account)
        self.assertEqual(target_account_01, user_account)
        self.assertEqual('网页端', operation_platform_01)
        web_desc_01 = "用户修改了(%s)围栏信息" % (fence_name)
        self.assertEqual(desc_01, web_desc_01)

        # 选择关联设备
        self.user_center_page.select_relevant_safe_area_search()
        sleep(5)

        operation_02 = self.user_center_page.get_operation_in_business_log_02()
        target_account_02 = self.user_center_page.get_target_account_in_business_log_02()
        operation_platform_02 = self.user_center_page.get_operation_platform_in_business_log_02()
        desc_02 = self.user_center_page.get_desc_in_business_log_02()

        self.assertEqual(operation_02, ' ' + user_account)
        self.assertEqual(target_account_02, user_account)
        self.assertEqual('网页端', operation_platform_02)
        web_desc_02 = "%s关联设备%s与区域信息%s" % (user_account, imei_01, fence_name)
        self.assertEqual(desc_02, web_desc_02)

        self.driver.default_frame()
示例#16
0
class TestCase202UserCenterModifyInfo2(unittest.TestCase):
    # 测试个人中心修改资料,包括特殊符号、异常
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.user_center_page = UserCenterPage(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.clear_cookies()
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        sleep(1)
        # 登录账号
        self.log_in_base.log_in()

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

    def test_user_center_modify_info2(self):
        # 通过csv测试修改资料功能
        current_handle = self.driver.get_current_window_handle()
        self.account_center_page_navi_bar.click_account_center_button()
        self.base_page.change_windows_handle(current_handle)
        # 点击个人中心 - 修改资料
        self.user_center_page.click_user_center_button()
        self.user_center_page.click_modify_user_info()

        # 1.特殊字符
        special_char = "/\^<>!~%*"
        # 在客户名称、电话中输入特殊字符
        self.user_center_page.input_user_name_in_modify_info(special_char)
        self.user_center_page.input_user_phone_in_modify_info(special_char)
        # 点击保存
        self.user_center_page.click_ensure_button()

        # 验证
        # 获取主页上的用户名称和电话
        user_name = self.user_center_page.get_user_name_in_main_page()
        user_phone = self.user_center_page.get_user_phone_in_main_page()
        self.assertNotEqual(special_char, user_name)
        self.assertNotEqual(special_char, user_phone)

        # 2.验证客户名称必填
        self.user_center_page.input_user_name_in_modify_info('')
        self.user_center_page.input_user_phone_in_modify_info('')
        # 点击保存
        self.user_center_page.click_ensure_button()
        # 获取到客户名称的异常提醒
        user_name_exception = self.user_center_page.get_user_name_exception_in_modify_info_page()
        self.assertEqual(self.assert_text.user_name_not_null(), user_name_exception)

        # 3.长度限制
        long_char = 'fsaffsdafsadfvczxfsdsafdfasdfasdfsdfsdfasdfasdffffffffffffffffffffffarfwqefsadfasdfasdcfsaasdcascsdc'
        self.user_center_page.input_user_name_in_modify_info(long_char)
        # 点击保存
        self.user_center_page.click_ensure_button()
        # 获取到客户名称的异常提醒
        user_name_exception = self.user_center_page.get_user_name_exception_in_modify_info_page()
        self.assertEqual(self.assert_text.user_name_not_to_long(), user_name_exception)

        shot_char = '12'
        self.user_center_page.input_user_name_in_modify_info(shot_char)
        # 点击保存
        self.user_center_page.click_ensure_button()
        # 获取到客户名称的异常提醒
        user_name_exception = self.user_center_page.get_user_name_exception_in_modify_info_page()
        self.assertEqual(self.assert_text.user_name_not_to_shot(), user_name_exception)

        # 4.邮箱格式限制
        email_format = "fdsaffadsfasdf"
        self.user_center_page.input_user_email_in_modify_info(email_format)
        # 点击保存
        self.user_center_page.click_ensure_button()
        # 获取到客户邮箱的异常提示
        user_email_exception = self.user_center_page.get_user_email_exception_in_modify_info_page()
        self.assertEqual(self.assert_text.user_email_format_error(), user_email_exception)
class TestCase412CustomerManagementEditUserSendWorkTemplateLimit(
        unittest.TestCase):
    # 测试编辑客户 -- 修改用户 批量下发工作模式
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(
            self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text2 = AssertText2()
        self.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

        # 进入客户管理页面
        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        # 搜索一个客户
        self.cust_manage_lower_account_page.input_search_info('abc12344')
        # 搜索
        self.cust_manage_lower_account_page.click_search_btn()
        user_account = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page(
        )

        # 点击编辑 - 取消
        self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
        )
        # 点击取消
        self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
        # 点击编辑
        self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
        )

        # 获取批量下发指令的状态
        self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
        web_login_status = self.cust_manage_basic_info_and_add_cust_page.get_send_work_template_status(
        )
        self.driver.default_frame()

        if web_login_status == True:
            # 点击
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.click_send_work_template_status_ins(
            )
            self.driver.default_frame()

            # 确定
            self.cust_manage_basic_info_and_add_cust_page.click_ensure()

            # 退出登录
            self.account_center_page_navi_bar.usr_logout()

            # 登录刚刚的账号
            self.log_in_base.log_in_with_csv(user_account, 'jimi123')
            # 进入设备管理 获取设备管理页面操的文本
            current_handle_01 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.click_dev_management_button(
            )
            self.base_page.change_windows_handle(current_handle_01)

            dev_operation_text = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button(
            )

            working_mode = self.assert_text2.dev_manage_setting_working_mode()
            all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode(
            )
            self.assertNotIn(working_mode, dev_operation_text)
            self.assertNotIn(all_working_mode, dev_operation_text)

            # 登录
            self.log_in_base.log_in()

            current_handle_02 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            self.base_page.change_windows_handle(current_handle_02)

            # 搜索一个客户
            self.cust_manage_lower_account_page.input_search_info('abc12344')
            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()
            # 点击编辑 - 取消
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            # 点击取消
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
            # 点击编辑
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )

            # 点击
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.click_send_work_template_status_ins(
            )
            self.driver.default_frame()

            self.cust_manage_basic_info_and_add_cust_page.click_ensure()

            # 退出登录
            self.account_center_page_navi_bar.usr_logout()

            # 登录刚刚的账号
            self.log_in_base.log_in_with_csv(user_account, 'jimi123')

            hello_usr = self.account_center_page_navi_bar.usr_info_account()
            self.assertIn(user_account, hello_usr)

            # 进入设备管理 获取设备管理页面操的文本
            current_handle_03 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.click_dev_management_button(
            )
            self.base_page.change_windows_handle(current_handle_03)

            dev_operation_text = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button(
            )

            working_mode = self.assert_text2.dev_manage_setting_working_mode()
            all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode(
            )
            self.assertIn(working_mode, dev_operation_text)
            self.assertIn(all_working_mode, dev_operation_text)

        elif web_login_status == False:
            # 点击
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.click_send_work_template_status_ins(
            )
            self.driver.default_frame()
            self.cust_manage_basic_info_and_add_cust_page.click_ensure()
            # 退出登录
            self.account_center_page_navi_bar.usr_logout()
            # 登录刚刚的账号
            self.log_in_base.log_in_with_csv(user_account, 'jimi123')
            hello_usr = self.account_center_page_navi_bar.usr_info_account()
            self.assertIn(user_account, hello_usr)
            # 进入设备管理 获取设备管理页面操的文本
            current_handle_04 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.click_dev_management_button(
            )
            self.base_page.change_windows_handle(current_handle_04)

            dev_operation_text = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button(
            )

            working_mode = self.assert_text2.dev_manage_setting_working_mode()
            all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode(
            )
            self.assertIn(working_mode, dev_operation_text)
            self.assertIn(all_working_mode, dev_operation_text)

            # 退出登录
            self.account_center_page_navi_bar.usr_logout()
            self.log_in_base.log_in()
            current_handle_05 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            self.base_page.change_windows_handle(current_handle_05)
            # 搜索一个客户
            self.cust_manage_lower_account_page.input_search_info('abc12344')
            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()
            # 点击编辑 - 取消
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )
            # 点击取消
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
            # 点击编辑
            self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons(
            )

            # 点击
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.click_send_work_template_status_ins(
            )
            self.driver.default_frame()

            # 确定
            self.cust_manage_basic_info_and_add_cust_page.click_ensure()
            # 退出登录
            self.account_center_page_navi_bar.usr_logout()
            # 登录刚刚的账号
            self.log_in_base.log_in_with_csv(user_account, 'jimi123')

            # 进入设备管理 获取设备管理页面操的文本
            current_handle_06 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.click_dev_management_button(
            )
            self.base_page.change_windows_handle(current_handle_06)

            dev_operation_text = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button(
            )

            working_mode = self.assert_text2.dev_manage_setting_working_mode()
            all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode(
            )
            self.assertNotIn(working_mode, dev_operation_text)
            self.assertNotIn(all_working_mode, dev_operation_text)
示例#18
0
class TestCase408CustomerManagementAddUserExpection(unittest.TestCase):
    # 测试新增客户--异常操作验证
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(
            self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text = AssertText()
        self.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

        # 进入客户管理页面
        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        self.cust_manage_basic_info_and_add_cust_page.add_acc()
        self.cust_manage_basic_info_and_add_cust_page.cancel_add_account()

        self.cust_manage_basic_info_and_add_cust_page.add_acc()

        # 验证上级客户input的属性是否为readonly
        readonly_value = self.cust_manage_basic_info_and_add_cust_page.get_up_account_value(
        )
        self.assertEqual('true', readonly_value)

        # 验证新增客户的名称
        # 1 为空
        self.cust_manage_basic_info_and_add_cust_page.add_account_name('')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()
        text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_name_exception_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_name_not_null(), text)

        # 2 长度小于三位
        self.cust_manage_basic_info_and_add_cust_page.add_account_name('1')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()
        text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_name_exception_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_name_more_than_3(),
                         text)

        # 3 验证最大长度
        max_len = self.cust_manage_basic_info_and_add_cust_page.get_account_name_max_len(
        )
        self.assertEqual('50', max_len)

        # 验证新增客户账号
        # 1 为空
        self.cust_manage_basic_info_and_add_cust_page.add_account('')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()
        text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_exception_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_account_not_null(),
                         text)

        # 2 长度小于3位
        self.cust_manage_basic_info_and_add_cust_page.add_account('1')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()
        text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_exception_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_account_len(), text)

        # 3 验证最大长度
        account_max_len = self.cust_manage_basic_info_and_add_cust_page.get_account_max_len(
        )
        self.assertEqual('30', account_max_len)

        # 验证密码
        # 1 为空
        self.cust_manage_basic_info_and_add_cust_page.add_password_first('')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()

        get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_first_password(
        )
        self.assertEqual(self.assert_text.cust_page_user_password_not_null(),
                         get_password_first_text)

        # 2 小于6位
        self.cust_manage_basic_info_and_add_cust_page.add_password_first('12e')
        self.cust_manage_basic_info_and_add_cust_page.add_password_second(
            '12e')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()

        get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_first_password(
        )
        self.assertEqual(self.assert_text.cust_page_user_password_len(),
                         get_password_first_text)

        # 3 全字母
        self.cust_manage_basic_info_and_add_cust_page.add_password_first(
            'abcdefg')
        self.cust_manage_basic_info_and_add_cust_page.add_password_second(
            'abcdefg')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()

        get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_first_password(
        )
        self.assertEqual(self.assert_text.cust_page_user_password_formate(),
                         get_password_first_text)

        # 4 全数字
        self.cust_manage_basic_info_and_add_cust_page.add_password_first(
            '123456')
        self.cust_manage_basic_info_and_add_cust_page.add_password_second(
            '123456')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()

        get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_first_password(
        )
        self.assertEqual(self.assert_text.cust_page_user_password_formate(),
                         get_password_first_text)

        # 5 只输入确认密码
        self.cust_manage_basic_info_and_add_cust_page.add_password_first('')
        self.cust_manage_basic_info_and_add_cust_page.add_password_second(
            'a123456')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()

        get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_second_password(
        )
        self.assertEqual(self.assert_text.cust_page_password_unlike(),
                         get_password_first_text)

        # 6两次密码不一致
        self.cust_manage_basic_info_and_add_cust_page.add_password_first(
            '123456ee')
        self.cust_manage_basic_info_and_add_cust_page.add_password_second(
            '123456ff')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()

        get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_second_password(
        )
        self.assertEqual(self.assert_text.cust_page_password_unlike(),
                         get_password_first_text)

        # 验证电话、邮箱、联系人、公司名的最大长度
        phone_max_len = self.cust_manage_basic_info_and_add_cust_page.get_phone_max_len(
        )
        self.assertEqual('20', phone_max_len)

        email_max_len = self.cust_manage_basic_info_and_add_cust_page.get_email_max_len(
        )
        self.assertEqual('50', email_max_len)
        # 验证邮箱格式
        self.cust_manage_basic_info_and_add_cust_page.add_email_format(
            '123123')
        self.cust_manage_basic_info_and_add_cust_page.click_ensure()
        get_text_email = self.cust_manage_basic_info_and_add_cust_page.get_text_email_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_email_formate_error(),
                         get_text_email)

        connect_max_len = self.cust_manage_basic_info_and_add_cust_page.get_connect_max_len(
        )
        self.assertEqual('50', connect_max_len)

        comp_max_len = self.cust_manage_basic_info_and_add_cust_page.get_comp_max_len(
        )
        self.assertEqual('50', comp_max_len)
class TestCase405CustomerManagementAddUserCommandLimit(unittest.TestCase):
    # 测试客户管理-新增用户-验证指令权限
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text = AssertText()
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_add_user_command_limit_verify(self):
        '''测试客户管理-指令权限验证'''

        self.base_page.open_page()

        csv_file = self.cust_manage_page_read_csv.read_csv('add_user_command_limit_data.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            info = {
                "keyword": row[0],
                "type": row[1],
                "name": row[2],
                "account": row[3],
                "passwd": row[4],
                "phone": row[5],
                "email": row[6],
                "conn": row[7],
                "com": row[8],
                "command": row[9],
                "working_mode": row[10]
            }

            # 登录
            self.log_in_base.log_in()

            # 进入客户管理页面
            current_handle = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            sleep(1)
            self.base_page.change_windows_handle(current_handle)

            self.cust_manage_basic_info_and_add_cust_page.add_acc()
            self.cust_manage_basic_info_and_add_cust_page.close_add_account()

            self.cust_manage_basic_info_and_add_cust_page.add_acc()
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.add_acc_input_info_edit(info["name"], info["account"],
                                                                                  info["passwd"],
                                                                                  info["phone"], info["email"],
                                                                                  info["conn"], info["com"])
            # 是或否批量下发指令 和批量下发工作模式
            command_status = self.cust_manage_basic_info_and_add_cust_page.setting_command_permissions(info["command"])
            working_mode_status = self.cust_manage_basic_info_and_add_cust_page.setting_working_mode_permissions(
                info["working_mode"])
            self.assertEqual(info["command"], str(command_status), "勾选状态与期望不一致")
            self.assertEqual(info["working_mode"], str(working_mode_status), "勾选状态与期望不一致")
            self.driver.default_frame()
            sleep(2)
            self.cust_manage_basic_info_and_add_cust_page.acc_add_save()
            sleep(1)
            # 退出登录
            self.account_center_page_navi_bar.usr_logout()

            self.log_in_base.log_in_with_csv(info["account"], info["passwd"])
            hello_usr = self.account_center_page_navi_bar.usr_info_account()
            self.assertIn(info["account"], hello_usr, "登录成功后招呼栏账户名显示错误")
            sleep(1)

            # 进入设备管理/指令管理页面,获取功能按钮
            current_handle_02 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.click_dev_management_button()
            self.base_page.change_windows_handle(current_handle_02)

            facility_manage_data = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button()
            sleep(3)
            # command_manage_data = self.cust_manage_basic_info_and_add_cust_page.get_command_page_module()

            # 获取中文,依次是:选中发送指令、本次查询全部发送指令、选中设置工作模式、本次查询全部设置工作模式
            # 工作模式模板管理, 下发工作模式任务管理, 下发工作模式管理, 下发指令任务管理, 下发指令管理
            send_command = self.assert_text2.dev_manage_select_send_command()
            all_send_command = self.assert_text2.dev_manage_select_all_send_command()
            working_mode = self.assert_text2.dev_manage_setting_working_mode()
            all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode()
            template_manage = self.assert_text.command_manager_page_work_type_template_management()
            working_mode_task_manage = self.assert_text2.comm_manage_send_working_mode_task_manage()
            working_mode_manage = self.assert_text2.comm_manage_send_working_mode_manage()
            task_manage = self.assert_text2.comm_manage_command_task_manage()
            comm_manager = self.assert_text.command_manager_page_issued_command_manager()

            command_list = []
            working_mode_list = []
            # 循环设备管理页面的数据
            for b in facility_manage_data:
                # 选中发送指令 和 本次查询全部发送指令
                if send_command in b or all_send_command in b:
                    command_list.append(b)
                # 选中设置工作模式 和 本次查询全部设置工作模式
                elif working_mode in b or all_working_mode in b:
                    working_mode_list.append(b)

            # 循环指令管理页面的数据
            '''for c in command_manage_data:
                # 下发指令任务管理 和 下发指令管理
                if task_manage in c or comm_manager in c:
                    command_list.append(c)
                # 工作模式模板管理, 下发工作模式任务管理, 下发工作模式管理
                elif template_manage in c or working_mode_task_manage in c or working_mode_manage in c:
                    working_mode_list.append(c)'''

            print("指令", command_list)
            print("工作模式", working_mode_list)

            # 验证设备、指令管理页面功能按钮
            if command_status == True and working_mode_status == True:
                # 指令(设备页+指令管理页)
                self.assertEqual(send_command, command_list[0])
                self.assertEqual(all_send_command, command_list[1])
                self.assertEqual(task_manage, command_list[2])
                self.assertEqual(comm_manager, command_list[3])

                # 工作模式(设备页+指令管理页)
                self.assertEqual(working_mode, working_mode_list[0])
                self.assertEqual(all_working_mode, working_mode_list[1])
                self.assertEqual(template_manage, working_mode_list[2])
                self.assertEqual(working_mode_task_manage, working_mode_list[3])
                self.assertEqual(working_mode_manage, working_mode_list[4])

            elif command_status == False and working_mode_status == False:
                # self.assertEqual(comm_manager, command_list[0])
                self.assertEqual(0, len(working_mode_list))

            elif command_status == True and working_mode_status == False:
                self.assertEqual(send_command, command_list[0])
                self.assertEqual(all_send_command, command_list[1])
                self.assertEqual(task_manage, command_list[2])
                self.assertEqual(comm_manager, command_list[3])
                self.assertEqual(0, len(working_mode_list))

            elif command_status == False and working_mode_status == True:
                self.assertEqual(comm_manager, command_list[0])
                self.assertEqual(working_mode, working_mode_list[0])
                self.assertEqual(all_working_mode, working_mode_list[1])
                self.assertEqual(template_manage, working_mode_list[2])
                self.assertEqual(working_mode_task_manage, working_mode_list[3])
                self.assertEqual(working_mode_manage, working_mode_list[4])

            sleep(1)
            self.account_center_page_navi_bar.usr_logout()

            self.log_in_base.log_in()

            current_handle_01 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            self.base_page.change_windows_handle(current_handle_01)

            # 搜索新增客户
            self.cust_manage_lower_account_page.input_search_info(info["account"])
            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()
            # 删除该新增客户
            self.cust_manage_lower_account_page.delete_acc()
            self.cust_manage_lower_account_page.delete_acc_ensure()
            # 获取删除操作状态
            del_status = self.cust_manage_lower_account_page.get_del_status()
            self.assertIn(self.assert_text.account_center_page_operation_done(), del_status, "操作失败")

            # 退出登录
            sleep(1)
            self.account_center_page_navi_bar.usr_logout()
        csv_file.close()
class TestCase404CustomerManagementAddAUserWebLimit(unittest.TestCase):
    # 测试客户管理-新增用户-验证web登陆权限
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text = AssertText()
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_add_user_web_limit_verify(self):
        '''测试客户管理-web权限验证'''

        self.base_page.open_page()

        csv_file = self.cust_manage_page_read_csv.read_csv(
            'add_user_web_limit_data.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            info = {
                "keyword": row[0],
                "type": row[1],
                "name": row[2],
                "account": row[3],
                "passwd": row[4],
                "phone": row[5],
                "email": row[6],
                "conn": row[7],
                "com": row[8],
                "web_setting": row[9],
                "app_setting": row[10]
            }

            # 登录
            self.log_in_base.log_in()

            # 进入客户管理页面
            current_handle = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            self.base_page.change_windows_handle(current_handle)

            self.cust_manage_basic_info_and_add_cust_page.add_acc()
            self.cust_manage_basic_info_and_add_cust_page.close_add_account()

            self.cust_manage_basic_info_and_add_cust_page.add_acc()
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_basic_info_and_add_cust_page.add_acc_input_info_edit(
                info["name"], info["account"], info["passwd"], info["phone"],
                info["email"], info["conn"], info["com"])
            # 是或否勾选web和app登录权限
            web_status = self.cust_manage_basic_info_and_add_cust_page.setting_web_login_permissions(
                info["web_setting"])
            app_status = self.cust_manage_basic_info_and_add_cust_page.setting_app_login_permissions(
                info["app_setting"])
            self.assertEqual(info["web_setting"], str(web_status),
                             "勾选状态与期望不一致")
            self.assertEqual(info["app_setting"], str(app_status),
                             "勾选状态与期望不一致")
            self.driver.default_frame()
            sleep(2)
            self.cust_manage_basic_info_and_add_cust_page.acc_add_save()
            sleep(1)

            self.account_center_page_navi_bar.usr_logout()

            # 没有web登录权限验证
            if web_status == False:
                self.log_in_base.log_in_with_csv(info["account"],
                                                 info["passwd"])
                self.assertEqual(self.assert_text2.login_no_permissions(),
                                 self.login_page.get_exception_text(),
                                 "没有获取到没有权限登录的提示")
            # 有web登录权限验证
            elif web_status == True:
                self.log_in_base.log_in_with_csv(info["account"],
                                                 info["passwd"])
                sleep(2)
                hello_usr = self.account_center_page_navi_bar.usr_info_account(
                )
                self.assertIn(info["account"], hello_usr, "登录成功后招呼栏账户名显示错误")
                sleep(1)
                self.log_in_base.click_account_center_button()
                self.account_center_page_navi_bar.usr_logout()

            self.log_in_base.log_in()

            current_handle_01 = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            self.base_page.change_windows_handle(current_handle_01)

            # 搜索新增客户
            self.cust_manage_lower_account_page.input_search_info(
                info["account"])
            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()
            # 删除该新增客户
            self.cust_manage_lower_account_page.delete_acc()
            self.cust_manage_lower_account_page.delete_acc_ensure()
            # 获取删除操作状态
            del_status = self.cust_manage_lower_account_page.get_del_status()
            self.assertIn(
                self.assert_text.account_center_page_operation_done(),
                del_status, "操作失败")

            # 退出登录
            sleep(1)
            self.account_center_page_navi_bar.usr_logout()
        csv_file.close()
示例#21
0
class TestCase401CustomerManagementCheckAccount(unittest.TestCase):
    # 测试 客户管理 检查客户管理抬头用户信息
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(
            self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.connect_sql = ConnectSql()
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text = AssertText()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_customer_management_check_account(self):

        # 打开途强在线首页-登录页
        self.base_page.open_page()

        # 登录
        self.log_in_base.log_in()

        # 进入客户管理页面
        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        csv_file = self.cust_manage_page_read_csv.read_csv(
            'check_account_data.csv')
        csv_data = csv.reader(csv_file)

        for row in csv_data:
            data = {'account': row[0]}
            self.cust_manage_basic_info_and_add_cust_page.add_data_to_search_account(
                data)

            connect = self.connect_sql.connect_tuqiang_sql()
            cursor = connect.cursor()

            get_account_sql = "SELECT o.type,o.phone,o.nickName from user_info o WHERE o.account = '" + data[
                'account'] + "';"

            cursor.execute(get_account_sql)
            get_account_user_info = cursor.fetchall()
            current_user_info = []
            for range1 in get_account_user_info:
                for range2 in range1:
                    current_user_info.append(range2)
            print(current_user_info)
            type = self.assert_text.log_in_page_account_type(
                current_user_info[0])
            # 断言客户类型
            account_type = self.cust_manage_basic_info_and_add_cust_page.get_account_type(
            )
            self.assertEqual(type, account_type)

            # 断言账号
            account = self.cust_manage_basic_info_and_add_cust_page.get_account(
            )
            self.assertEqual(data['account'], account)

            # 断言电话
            account_phone = self.cust_manage_basic_info_and_add_cust_page.get_account_phone(
            )
            if current_user_info[1] == None:
                self.assertEqual("", account_phone, "手机号不一致")
            else:
                self.assertEqual(current_user_info[1], account_phone)

            # 断言昵称
            account_name = self.cust_manage_basic_info_and_add_cust_page.get_account_name(
            )
            if current_user_info[2] == None:
                self.assertEqual("", account_name, "昵称不一致")
            else:
                self.assertEqual(current_user_info[2], account_name)

            # 点击监控用户
            current_window = self.driver.get_current_window_handle()
            self.cust_manage_basic_info_and_add_cust_page.click_monitoring_account_button(
            )
            all_handles = self.driver.get_all_window_handles()
            for handle in all_handles:
                if handle != current_window:
                    self.driver.switch_to_window(handle)

                    expect_url = self.base_url + '/index'
                    self.assertEqual(expect_url, self.driver.get_current_url())

                    self.driver.close_current_page()
                    sleep(2)
                    self.driver.switch_to_window(current_window)

            # 点击编辑用户
            style_value = self.cust_manage_basic_info_and_add_cust_page.edit_button_style_value(
            )
            if style_value == 'display: inline;':
                self.cust_manage_basic_info_and_add_cust_page.click_edit_account_button(
                )
                # 点击关闭
                self.cust_manage_basic_info_and_add_cust_page.click_close_edit_accunt_button(
                )

                # 点击编辑
                self.cust_manage_basic_info_and_add_cust_page.click_edit_account_button(
                )

                # 查询用户上一级信息
                connect_02 = self.connect_sql.connect_tuqiang_sql()
                cursor_02 = connect_02.cursor()
                get_id_sql = "SELECT o.parentId from user_info o WHERE o.account = '" + account + "';"
                cursor_02.execute(get_id_sql)
                get_id_info = cursor_02.fetchall()
                current_user = []
                for range1 in get_id_info:
                    for range2 in range1:
                        current_user.append(range2)
                print(current_user)

                get_up_account_info_sql = "SELECT o.nickName FROM user_info o WHERE o.userId = '" + current_user[
                    0] + "';"
                cursor_02.execute(get_up_account_info_sql)
                get_up_user_info = cursor_02.fetchall()
                up_user_info = []
                for range1 in get_up_user_info:
                    for range2 in range1:
                        up_user_info.append(range2)
                account_name = up_user_info[0]
                get_web_account_name = self.cust_manage_basic_info_and_add_cust_page.get_account_name_after_click_edit(
                )
                self.assertEqual(account_name, get_web_account_name,
                                 '用户上级显示错误!')
                self.cust_manage_basic_info_and_add_cust_page.click_close_edit_accunt_button(
                )

                # 断言账号类型
                cursor_02.close()
                connect_02.close()
            cursor.close()
            connect.close()
        csv_file.close()
class TestCase414CustomerManagementEditDelete(unittest.TestCase):
    # 测试编辑客户 -- 删除
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text2 = AssertText2()
        self.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

        # 进入客户管理页面
        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        # 搜索一个客户
        self.cust_manage_lower_account_page.input_search_info('abc12344')
        # 搜索
        self.cust_manage_lower_account_page.click_search_btn()
        user_account = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page()
        user_type = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page()
        user_name = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page()
        user_phone = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page()
        user_contact = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page()

        # 点击删除
        self.cust_manage_basic_info_and_add_cust_page.click_delete_user_button()
        # 点击取消
        self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
        user_account_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page()
        user_type_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page()
        user_name_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page()
        user_phone_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page()
        user_contact_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page()

        self.assertEqual(user_account, user_account_01)
        self.assertEqual(user_type, user_type_01)
        self.assertEqual(user_name, user_name_01)
        self.assertEqual(user_phone, user_phone_01)
        self.assertEqual(user_contact, user_contact_01)

        # 点击删除
        self.cust_manage_basic_info_and_add_cust_page.click_delete_user_button()
        # 点击取消
        self.cust_manage_basic_info_and_add_cust_page.click_close_edit_accunt_button()
        user_account_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page()
        user_type_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page()
        user_name_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page()
        user_phone_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page()
        user_contact_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page()

        self.assertEqual(user_account, user_account_02)
        self.assertEqual(user_type, user_type_02)
        self.assertEqual(user_name, user_name_02)
        self.assertEqual(user_phone, user_phone_02)
        self.assertEqual(user_contact, user_contact_02)
class TestCase402CustomerManagementLowerUserSearch(unittest.TestCase):
    # 测试客户管理 搜索 客户
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(
            self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(
            self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.search_sql = SearchSql()
        self.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

        # 登录
        self.log_in_base.log_in()
        # 点击账户中心
        # self.account_center_page_navi_bar.click_account_center_button()
        # current_account = self.log_in_base.get_log_in_account()

        # 进入客户管理页面
        current_handle = self.driver.get_current_window_handle()
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.base_page.change_windows_handle(current_handle)

        csv_file = self.cust_manage_page_read_csv.read_csv('acc_search.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],
                "account_type": row[1],
                "info": row[2]
            }
            print(search_data)
            sleep(1)
            self.cust_manage_lower_account_page.add_data_to_search_account(
                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]
                }
                # 执行sql脚本,根据当前登录账号的userId,fullParent查询出当前账户的所有下级账户
                get_lower_account_sql = "select userId from user_info where fullParentId = " + \
                                        "'" + user_relation_id["fullParent"] + user_relation_id[
                                            "userId"] + ",'" + ";"

                cur.execute(get_lower_account_sql)
                # 读取数据
                lower_account = cur.fetchall()

                print(lower_account)

                lower_account_list = []
                for range1 in lower_account:
                    for range2 in range1:
                        lower_account_list.append(range2)
                lower_account_tuple = tuple(lower_account_list)
                print(lower_account_tuple)

                get_total_sql = self.search_sql.search_account_sql(
                    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.cust_manage_lower_account_page.get_account_number(
                )
                print('本次查询页面的条数是:%s' % web_total)
                self.assertEqual(total, web_total)

            cur.close()
            connect.close()

        csv_file.close()
class TestCase207UserCenterCustomerLog(unittest.TestCase):
    # 测试个人中心 - 帮助 - 业务日志 - 客户管理日志(新增客户、修改客户信息、删除客户、修改密码、重置密码、转移客户)
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.help_page = HelpPage(self.driver, self.base_url)
        self.account_center_page_operation_log = AccountCenterOperationLogPage(
            self.driver, self.base_url)
        self.help_page_sql = HelpPageSql()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.connect_sql = ConnectSql()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.user_center_page = UserCenterPage(self.driver, self.base_url)
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_user_center_customer_log(self):
        self.base_page.open_page()
        self.log_in_base.log_in()
        user_account = self.log_in_base.get_log_in_account()

        # 点击客户管理
        new_customer_data = ['新增的客户', 'new_1226']

        current_handle = self.driver.get_current_window_handle()
        self.user_center_page.click_customer_mangement()
        self.base_page.change_windows_handle(current_handle)

        # 新增客户按钮
        self.user_center_page.click_add_new_customer_buttons()
        # 点击切换到frame
        self.user_center_page.switch_to_add_new_customer_frame()
        # 填写用户名称和账号
        self.user_center_page.add_user_name_and_user_account(new_customer_data)
        self.driver.default_frame()
        # 点击确定
        self.user_center_page.click_ensure_button()

        # 搜索新增的用户
        self.user_center_page.search_user_in_customer_management(
            new_customer_data[1])

        # 修改用户信息 - 点击编辑
        self.user_center_page.click_edit_customer_button()
        # 点击保存
        self.user_center_page.click_ensure_button()

        # 点击重置密码
        self.user_center_page.click_reset_password_button()
        # 点击保存
        self.user_center_page.click_ensure_button()

        # 点击转移客户
        self.user_center_page.click_transfer_customer_button()
        # 点击保存
        self.user_center_page.click_ensure_button()

        # 点击删除客户
        self.user_center_page.click_delete_customer_button()
        # 点击保存
        self.user_center_page.click_ensure_button()

        # 进入帮助 - 业务日志页面
        self.user_center_page.click_user_center_button()
        # 点击帮助
        self.user_center_page.click_help_button()
        # 切换到业务日志的frame里面
        self.user_center_page.switch_to_business_frame()

        # 查询 客户管理 - 新增客户
        self.user_center_page.select_customer_management_condition()
        self.user_center_page.select_add_new_customer_log()
        # 点击搜索
        self.user_center_page.click_search_button_in_business_log()

        operation_01 = self.user_center_page.get_operation_in_business_log()
        target_account_01 = self.user_center_page.get_target_account_in_business_log(
        )
        operation_platform_01 = self.user_center_page.get_operation_platform_in_business_log(
        )
        desc_01 = self.user_center_page.get_desc_in_business_log()

        self.assertEqual(" " + user_account, operation_01)
        self.assertEqual(new_customer_data[1], target_account_01)
        self.assertEqual('网页端', operation_platform_01)
        web_desc_01 = "用户%s执行添加客户操作" % user_account
        self.assertEqual(web_desc_01, desc_01)

        # 查询修改用户信息
        self.user_center_page.select_edit_customer_log()
        # 点击搜索
        self.user_center_page.click_search_button_in_business_log()

        operation_02 = self.user_center_page.get_operation_in_business_log()
        target_account_02 = self.user_center_page.get_target_account_in_business_log(
        )
        operation_platform_02 = self.user_center_page.get_operation_platform_in_business_log(
        )
        desc_02 = self.user_center_page.get_desc_in_business_log()

        self.assertEqual(" " + user_account, operation_02)
        self.assertEqual(new_customer_data[1], target_account_02)
        self.assertEqual('网页端', operation_platform_02)
        web_desc_02 = "用户%s执行修改用户信息操作" % user_account
        self.assertEqual(web_desc_02, desc_02)

        # 查询删除用户信息
        self.user_center_page.select_delete_customer_log()
        # 点击搜索
        self.user_center_page.click_search_button_in_business_log()

        operation_03 = self.user_center_page.get_operation_in_business_log()
        target_account_03 = self.user_center_page.get_target_account_in_business_log(
        )
        operation_platform_03 = self.user_center_page.get_operation_platform_in_business_log(
        )
        desc_03 = self.user_center_page.get_desc_in_business_log()

        self.assertEqual(" " + user_account, operation_03)
        self.assertEqual(new_customer_data[1], target_account_03)
        self.assertEqual('网页端', operation_platform_03)
        web_desc_03 = "用户%s执行删除用户信息操作" % user_account
        self.assertEqual(web_desc_03, desc_03)

        # 查询重置密码信息
        self.user_center_page.select_reset_password_log()
        # 点击搜索
        self.user_center_page.click_search_button_in_business_log()

        operation_04 = self.user_center_page.get_operation_in_business_log()
        target_account_04 = self.user_center_page.get_target_account_in_business_log(
        )
        operation_platform_04 = self.user_center_page.get_operation_platform_in_business_log(
        )
        desc_04 = self.user_center_page.get_desc_in_business_log()

        self.assertEqual(" " + user_account, operation_04)
        self.assertEqual(new_customer_data[1], target_account_04)
        self.assertEqual('网页端', operation_platform_04)
        web_desc_04 = "用户%s执行重置密码操作" % user_account
        self.assertEqual(web_desc_04, desc_04)

        # 查询转移客户信息
        self.user_center_page.select_transfer_customer_log()
        # 点击搜索
        self.user_center_page.click_search_button_in_business_log()

        operation_05 = self.user_center_page.get_operation_in_business_log()
        target_account_05 = self.user_center_page.get_target_account_in_business_log(
        )
        operation_platform_05 = self.user_center_page.get_operation_platform_in_business_log(
        )
        desc_05 = self.user_center_page.get_desc_in_business_log()

        self.assertEqual(" " + user_account, operation_05)
        self.assertEqual(new_customer_data[1], target_account_05)
        self.assertEqual('网页端', operation_platform_05)
        web_desc_05 = "对用户%s从%s到%s执行转移客户操作" % (new_customer_data[1],
                                               user_account, user_account)
        self.assertEqual(web_desc_05, desc_05)

        self.driver.default_frame()