def setUp(self):
     self.driver = AutomateDriver()
     self.base_url = self.driver.base_url
     self.base_page = BasePage(self.driver, self.base_url)
     self.login_page = LoginPage(self.driver, self.base_url)
     self.user_center = UserCenter(self.driver, self.base_url)
     self.log_in_page_read_csv = LogInPageReadCsv()
     self.driver.set_window_max()
     self.connect_sql = ConnectSql()
     self.driver.wait(1)
     self.driver.clear_cookies()
     self.driver.wait(1)
Example #2
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.account_center_page_navi_bar = AccountCenterNaviBarPage(
         self.driver, self.base_url)
     self.log_in_page_read_csv = LogInPageReadCsv()
     self.driver.set_window_max()
     self.connect_sql = ConnectSql()
     self.driver.wait(1)
     self.driver.clear_cookies()
     self.driver.wait(1)
Example #3
0
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.user_center = UserCenter(self.driver, self.base_url)
        self.log_in_page_read_csv = LogInPageReadCsv()
        self.user_center_read_csv = UserCenterReadCsv()
        self.driver.set_window_max()
        self.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        sleep(1)
        # 登录账号
        self.login_page.test_user_login()
class TestCase124LoginSuccessWithphAppUser(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_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"])
            # 点首页
            # self.login_page.click_home_page()
            # 判断登录成功后跳转页面是否正确
            actual_url = self.driver.get_current_url()
            expect_url = self.base_url + "/nomalUserCenter"
            self.assertEqual(expect_url, actual_url, "登录成功后页面跳转错误")

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

            # 验证模块
            module = self.account_center_page_navi_bar.get_page_module()
            for m in range(len(module)):
                self.assertIn(data[m], module[m], "用户账号登录,模块显示错误")

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

            # 获取数据库服务商的个数
            connect = self.connect_sql.connect_tuqiang_sql()
            cursor = connect.cursor()
            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 - 1, service_total)
            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(), "退出系统失败")
            break
        csv_file.close()
Example #5
0
class TestCase117LoginSuccessWithOrdinaryUser(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.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()
            # 判断登录成功后跳转页面是否正确
            actual_url = self.driver.get_current_url()
            expect_url = self.base_url + "/nomalUserCenter"
            self.assertEqual(expect_url, actual_url, "登录成功后页面跳转错误")

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

            # 验证模块
            '''module = self.account_center_page_navi_bar.get_page_module()
            for m in range(len(module)):
                self.assertIn(data[m], module[m], "用户账号登录,模块显示错误")'''

            connect = self.connect_sql.connect_tuqiang_sql()
            cursor = connect.cursor()
            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)
            print(current_user_info)
            # get_up_account_info_sql = "SELECT o.account,o.nickName,o.phone FROM user_info o WHERE o.userId = '" + \
            # current_user_info[0] + "';"
            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)
            usr_service_provider = self.account_center_page_navi_bar.ordinary_usr_service_provider(
            )
            expect_usr_service_provider = up_user_info[0]
            self.assertIn(expect_usr_service_provider, usr_service_provider,
                          "服务商显示错误")
            if up_user_info[1] != '':
                service_provider_connect = self.account_center_page_navi_bar.ordinary_usr_service_provider_connect(
                )
                expect_service_provider_connect = up_user_info[1]
                self.assertIn(expect_service_provider_connect,
                              service_provider_connect, "联系人显示错误")

            service_provider_phone = self.account_center_page_navi_bar.ordinary_usr_service_provider_phone(
            )
            expect_service_provider_phone = up_user_info[2]
            self.assertIn(expect_service_provider_phone,
                          service_provider_phone, "电话显示错误")

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

            # 判断是否成功退出到登录页
            self.assertEqual(self.base_url + "/",
                             self.driver.get_current_url(), "退出系统失败")

            # 验证退出系统后“记住我”是否是未勾选状态
            box_status = self.login_page.check_remember_me()
            self.assertEqual(False, box_status, '记住密码为勾选状态!')

        csv_file.close()
class TestCase01LoginSuccess(unittest.TestCase):
    # 测试用户账号登录成功
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.user_center = UserCenter(self.driver, self.base_url)
        self.log_in_page_read_csv = LogInPageReadCsv()
        self.driver.set_window_max()
        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_user_login_by_csv(self):
        '''通过csv测试用户账户成功登录和成功退出功能'''
        data = ["部门管理", "设备", "贷款客户", "车辆监控中心", "统计报表", "设置"]

        csv_file = self.log_in_page_read_csv.read_csv('login_account.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)

            # 判断登录成功后招呼栏的用户名是否正确
            username = self.user_center.get_username()

            # 从数据库获取登录账号的用户名
            account_info = self.user_center.get_account_info_by_sql(
                user_to_login['account'])
            print(account_info)
            account_name = account_info[1]

            self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误')

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

            # 取消退出系统
            sleep(2)
            self.user_center.logout_dismiss()

            # 关闭退出系统弹框
            sleep(2)
            self.user_center.logout_close()

            # 成功退出系统
            sleep(2)
            self.user_center.logout()

            # 再次登录判断是否成功退出到登录页并登录成功
            self.login_page.user_login(user_to_login["account"],
                                       user_to_login["passwd"])

            # # 成功退出系统
            sleep(2)
            self.user_center.logout()

        csv_file.close()
Example #7
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()
Example #8
0
class TestCase116LoginSuccessWithSalesAndAgent(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"])
            # 点账户中心
            self.account_center_page_navi_bar.click_account_center_button()
            # self.account_center_page_navi_bar.click_account_center_button()
            # 判断登录成功后跳转页面是否正确
            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 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)
            print("当前号", current_user_info)
            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()