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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
 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 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.assert_text = AssertText()
     self.driver.wait(1)
     self.driver.clear_cookies()
     self.driver.wait(1)
Exemplo n.º 5
0
class TestCase730816CustManageEditUserCommandLimit(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.quit_browser()

    def test_edit_account_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 = {
                "passwd": row[4],
                "command": row[9],
                "working_mode": row[10],
                "wdit_account": row[11]
            }

            # 登录
            self.log_in_base.log_in()

            # 进入客户管理页面
            self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
            # 搜索账号
            self.cust_manage_lower_account_page.input_search_info(info["wdit_account"])
            # 搜索
            self.cust_manage_lower_account_page.click_search_btn()

            # 点击编辑用户
            self.cust_manage_basic_info_and_add_cust_page.click_edit_customer()
            self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()
            self.cust_manage_basic_info_and_add_cust_page.click_edit_customer()
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()

            # 是或否批量下发指令 和批量下发工作模式
            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.log_in_base.click_account_center_button()
            sleep(2)
            self.account_center_page_navi_bar.usr_logout()

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

            # 进入设备管理/指令管理页面,获取功能按钮
            facility_manage_data = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button()
            sleep(2)
            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.log_in_base.click_account_center_button()
            sleep(2)
            self.account_center_page_navi_bar.usr_logout()
            break
        csv_file.close()
Exemplo n.º 6
0
class TestCase58CustManageAddAcc(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.quit_browser()

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

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

        # 登录
        self.log_in_base.log_in()

        # 进入客户管理页面
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()

        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()
            # status = self.cust_manage_lower_account_page.edit_info_save_status()
            self.driver.default_frame()
            # self.assertEqual(self.assert_text2.cust_manage_add_user_type_prompt(), status, "提示显示不一致")

            # 右侧搜索栏中搜索并选中作为上级用户
            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()
Exemplo n.º 7
0
class TestCase7408171CustManagelResetPasswordVerify(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.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.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_cancel_and_ascertain_reset_password(self):
        '''客户管理-取消和确定重置密码操作'''
        account = ["xin_121313"]

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录
        self.log_in_base.log_in()
        self.driver.wait(1)
        # 进入客户管理页面
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        # 搜索账号
        self.cust_manage_lower_account_page.input_search_info(account[0])
        self.cust_manage_lower_account_page.click_search_btn()
        self.assertEqual(
            account[0],
            self.cust_manage_lower_account_page.get_search_result_account(),
            "搜索结果账号不一致")
        # 取消重置密码
        self.cust_manage_lower_account_page.click_reset_passwd_dismiss()

        # 取消重置密码后的验证
        self.log_in_base.click_account_center_button()
        sleep(2)
        self.account_center_page_navi_bar.usr_logout()
        self.log_in_base.log_in_with_csv(account[0], "jimi123")
        hello_usr = self.account_center_page_navi_bar.hello_user_account()
        self.assertIn(account[0], hello_usr, "登录成功后招呼栏账户名显示错误")
        sleep(1)
        self.account_center_page_navi_bar.usr_logout()

        #再次登录,重置密码
        self.log_in_base.log_in()
        self.driver.wait(1)
        # 进入客户管理页面
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.cust_manage_lower_account_page.input_search_info(account[0])
        self.cust_manage_lower_account_page.click_search_btn()
        # 点击单个用户的重置密码
        self.cust_manage_lower_account_page.acc_reset_passwd()

        # 获取重置密码弹框文本内容
        text = self.cust_manage_lower_account_page.reset_passwd_content()
        hint_password = text.split(":")[2]
        # 验证重密码是否正确显示
        self.assertEqual("888888", hint_password, "弹框中的重置密码显示的不是888888")

        # 确定重置密码
        self.cust_manage_lower_account_page.reset_passwd_ensure()
        # 获取重置状态
        reset_status = self.cust_manage_lower_account_page.reset_passwd_content(
        )
        # 验证操作状态是否成功
        self.assertIn(self.assert_text.account_center_page_operation_done(),
                      reset_status, "操作失败")
        # 退出登录
        sleep(1)
        self.log_in_base.click_account_center_button()
        sleep(2)
        self.account_center_page_navi_bar.usr_logout()

        # 修改用户的默认密码
        self.log_in_base.log_in_with_csv(account[0], hint_password)
        sleep(2)
        # 修改用户默认密码(jimi123)
        self.cust_manage_basic_info_and_add_cust_page.user_default_password_edit(
            "jimi123")
        sleep(2)
        # 获取密码修改成功
        self.driver.click_element("x,/html/body/div[16]/div[3]/a")
        # status = self.cust_manage_basic_info_and_add_cust_page.user_default_password_edit_prompt()
        # self.assertIn(self.assert_text2.home_page_edit_password_success(), status, "修改密码失败!")
        sleep(2)
        self.assertEqual(self.base_url + "/", self.driver.get_current_url(),
                         "修改默认密码后,没有返回到登录页")
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 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)
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 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 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()
Exemplo n.º 13
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 TestCase7508171CustManagelDeleteAccountVerify(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.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_cancel_and_ascertain_delete_account(self):
        '''客户管理-取消和确定删除账号操作'''

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录
        self.log_in_base.log_in_with_csv("dzltest", "jimi123")
        self.driver.wait(1)
        # 进入客户管理页面
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()

        # 删除有绑定或分配有设备的账号
        search_data = {
            'account': "csscgndh",
            "account_type": "",
            "info": "scybdsbhfpysbdh"
        }
        self.cust_manage_lower_account_page.add_data_to_search_account(
            search_data)
        self.assertEqual(
            search_data["info"],
            self.cust_manage_lower_account_page.get_search_result_account(),
            "搜索结果账号不一致")
        #确定删除
        self.cust_manage_lower_account_page.delete_acc()
        self.cust_manage_lower_account_page.delete_acc_ensure()
        self.assertEqual(
            self.assert_text2.cust_manage_exist_facility_cannot_del(),
            self.cust_manage_lower_account_page.get_del_status(), "删除提示不一致")
        sleep(3)

        # 删除有下级客户的账号
        account = ["csscgndh"]
        self.cust_manage_basic_info_and_add_cust_page.click_left_tree_current_user(
        )
        # 搜索账号
        self.cust_manage_lower_account_page.input_search_info(account[0])
        self.cust_manage_lower_account_page.click_search_btn()
        self.assertEqual(
            account[0],
            self.cust_manage_lower_account_page.get_search_result_account(),
            "搜索结果账号不一致")
        #确定删除
        self.cust_manage_lower_account_page.delete_acc()
        self.cust_manage_lower_account_page.delete_acc_ensure()
        #验证有下级客户的账号
        self.assertEqual(self.assert_text2.cust_manage_exist_user_cannot_del(),
                         self.cust_manage_lower_account_page.get_del_status(),
                         "删除提示不一致")
        sleep(2)

        #取消删除后的验证
        self.cust_manage_lower_account_page.delete_acc_x()
        #退出
        self.log_in_base.click_account_center_button()
        sleep(2)
        self.account_center_page_navi_bar.usr_logout()
        self.log_in_base.log_in_with_csv(account[0], "jimi123")
        self.driver.wait(1)
        hello_usr = self.account_center_page_navi_bar.hello_user_account()
        self.assertIn(account[0], hello_usr, "登录成功后招呼栏账户名显示错误")
        sleep(1)
        self.log_in_base.click_account_center_button()
        sleep(2)
        self.account_center_page_navi_bar.usr_logout()
class TestCase60CustManageLowerAccountEdit(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.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_cust_manage_lower_account_edit(self):
        '''客户管理-下级客户-单个客户编辑'''

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

        # 登录
        self.log_in_base.log_in()
        self.driver.wait(1)
        # 进入客户管理页面
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()

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

        for row in csv_data:
            edit_info = {
                "acc_type": row[0],
                "acc_name": row[1],
                "phone": row[2],
                "email": row[3],
                "conn": row[4],
                "com": row[5]
            }
            sleep(2)
            # 取消
            self.cust_manage_lower_account_page.edit_info_cancel()
            # 点击单个用户的编辑
            self.cust_manage_lower_account_page.click_acc_edit()

            # 选择客户类型
            sleep(3)
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.cust_manage_lower_account_page.acc_type_choose(edit_info["acc_type"])
            # 编辑信息
            self.cust_manage_lower_account_page.edit_acc_input_info_edit(edit_info["acc_name"],
                                                                         edit_info["phone"],
                                                                         edit_info["email"],
                                                                         edit_info["conn"],
                                                                         edit_info["com"])

            # 保存
            self.driver.default_frame()
            self.cust_manage_lower_account_page.edit_info_save()

            # 获取操作状态
            status = self.cust_manage_lower_account_page.edit_info_save_status()

            # 验证是否操作成功
            self.assertIn(self.assert_text.account_center_page_operation_done(), status, "操作失败")
Exemplo n.º 16
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 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()
Exemplo n.º 18
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 TestCase61CustManageLowerAccountOperate(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.assert_text = AssertText()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_cust_manage_lower_account_operate(self):
        '''客户管理-下级客户-单个客户操作'''

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录
        self.log_in_base.log_in()
        self.driver.wait(1)
        # 进入客户管理页面
        self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage()
        self.driver.wait()
        # account = self.cust_manage_basic_info_and_add_cust_page.get_account_text()

        # 点击单个用户的重置密码
        self.cust_manage_lower_account_page.acc_reset_passwd()

        # 获取重置密码弹框文本内容
        text = self.cust_manage_lower_account_page.reset_passwd_content()

        # 验证重置密码弹框文本内容是否正确显示
        self.assertIn(self.assert_text.cust_page_are_you_reset_this_password(),
                      text, "重置密码弹框文本内容显示错误")

        # 确定重置密码
        self.cust_manage_lower_account_page.reset_passwd_ensure()

        # 获取重置状态
        reset_status = self.cust_manage_lower_account_page.reset_passwd_content(
        )

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

        # 获取当前窗口句柄
        account_center_handle = self.driver.get_current_window_handle()
        # 点击单个用户的控制台
        self.cust_manage_lower_account_page.enter_console()
        self.driver.wait()

        expect_url = self.base_url + "/index"

        # 获取当前所有窗口句柄
        all_handles = self.driver.get_all_window_handles()
        for handle in all_handles:
            if handle != account_center_handle:
                self.driver.switch_to_window(handle)
                self.driver.wait(1)
                current_url = self.driver.get_current_url()

                self.assertEqual(expect_url, current_url, "控制台页面跳转错误!")

                # 关闭当前窗口
                self.driver.close_current_page()
                # 回到账户中心窗口
                self.driver.switch_to_window(account_center_handle)
                self.driver.wait()

        # 点击单个用户的删除
        self.cust_manage_lower_account_page.delete_acc()
        self.driver.click_element('c,layui-layer-btn1')