class TestCase108LoginTester(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.driver.set_window_max()
        self.driver.wait(1)

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

    def test_log_in_tester(self):
        # 打开页面
        self.base_page.open_page()
        # 点击体验账号
        self.login_page.click_tester_button()

        # 断言登录的账号
        user_account = self.login_page.get_user_account_tester()
        self.assertEqual('taste', user_account)

        # 点击个人中心
        self.login_page.click_user_center()
        # 点击退出系统
        self.login_page.click_log_out_system()
        # 点击确定
        self.login_page.click_ensure()

        self.assertEqual(self.base_url + "/", self.driver.get_current_url(),
                         "退出系统失败")
class TestCase104LoginException(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_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_case_login_exception(self):
        # 异常登录
        self.base_page.open_page()
        sleep(2)
        # 第一种 密码和账号都为空
        self.login_page.account_input('')
        self.login_page.password_input('')
        self.login_page.login_button_click()
        sleep(2)

        self.assertEqual(self.assert_text.log_in_page_account_or_password_not_null(),
                         self.login_page.get_exception_text())

        # 第二种 密码 和 账号一个不为空
        self.login_page.account_input('jimitest')
        self.login_page.password_input('')
        self.login_page.login_button_click()
        sleep(2)
        self.assertEqual(self.assert_text.log_in_page_account_or_password_not_null(),
                         self.login_page.get_exception_text())

        self.login_page.account_input('')
        self.login_page.password_input('jimi123')
        self.login_page.login_button_click()
        sleep(2)
        self.assertEqual(self.assert_text.log_in_page_account_or_password_not_null(),
                         self.login_page.get_exception_text())

        # 第三种 账号不存在
        self.login_page.account_input('fdsafasfd')
        self.login_page.password_input('jimi123')
        self.login_page.login_button_click()
        sleep(5)
        self.assertEqual(self.assert_text.log_in_page_account_not_exist(), self.login_page.get_exception_text())

        # 第四种 密码错误
        self.login_page.account_input('jimitest')
        self.login_page.password_input('jimi123222')
        self.login_page.login_button_click()
        sleep(5)
        self.assertEqual(self.assert_text.log_in_page_password_error(), self.login_page.get_exception_text())
Beispiel #3
0
class TestCase10AccountCenterOverviewStock(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.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.driver.set_window_max()
        self.connect_sql = ConnectSql()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.account_center_change_page = AccountCenterChangePage(self.driver, self.base_page)
        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_account_center_overview_stock(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in()
        account = self.log_in_base.get_log_in_account()
        self.account_center_page_navi_bar.click_account_center_button()

        # 拖拽页面到库存显示的
        self.account_center_change_page.switch_kucun_dev_enable()
        self.account_center_change_page.switch_to_kucun_dev_frame()

        kucun_account = self.account_center_change_page.get_account_in_kuncun_frame()
        self.driver.default_frame()
class TestCase020AccountCenterMsgUnread(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.account_center_page_msg_center = AccountCenterMsgCenterPage(
            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.account_center_change_page = AccountCenterChangePage(
            self.driver, self.base_page)
        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_account_center_msg_unread(self):
        self.base_page.open_page()
        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        # 进入消息中心
        self.account_center_page_msg_center.enter_msg_center()
        self.driver.wait(7)
        # 进入iframe
        # self.account_center_page_msg_center.message_center_iframe()

        # 获取消息中心title
        msg_center_title = self.account_center_page_msg_center.get_msg_center_title(
        )
        # 验证消息中心title是否正确显示
        self.assertIn(
            self.assert_text.account_center_page_message_center_text(),
            msg_center_title, "消息中心title有误!")
        #退出iframe
        # self.driver.default_frame()

        # 获取左侧栏目-消息中心-x条未读
        unread_msg_num = int(
            self.account_center_page_msg_center.get_unread_msg_num())
        print(unread_msg_num)
        if unread_msg_num > 0:
            # 设置搜索条件-消息状态为“未读”,搜索出结果,统计结果列表中的未读消息共几条
            self.account_center_page_msg_center.set_search_status_unread()
            self.driver.wait(4)
            count_unread_msg_num = self.account_center_page_msg_center.get_total_unread_logs_num(
            )
            # 判断消息中心左侧栏目的未读消息与搜索结果的未读消息数量是否一致
            self.assertEqual(unread_msg_num, count_unread_msg_num,
                             "消息中心左侧栏目的未读消息与搜索结果的未读消息数量不一致")
            # self.driver.default_frame()
            # 退出登录
            # self.account_center_page_navi_bar.usr_logout()
        else:
            print("当前未读消息共:" + str(unread_msg_num) + "条!")
Beispiel #5
0
class TestCase271AccountCenterModifyInfoException(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.clear_cookies()

    def test_modify_info_exception(self):
        "修改资料错误提示"

        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        self.driver.wait(1)
        # 点击招呼栏的修改资料
        self.account_center_page_navi_bar.click_modify_usr_info()

        csv_find = self.account_center_page_read_csv.read_csv(
            "modify_info_exception.csv")
        csv_data = csv.reader(csv_find)
        for row in csv_data:
            data = {
                "name": row[0],
                "phone": row[1],
                "email": row[2],
                "name_prompt": row[3],
                "phone_prompt": row[4],
                "email_prompt": row[5]
            }

            all_prompt = self.account_center_page_navi_bar.get_modify_info_exception_prompt(
                data)

            self.assertEqual(data["name_prompt"], all_prompt["name"],
                             "个人资料,客户名称错误提示语显示不一致")

            self.assertEqual(data["phone_prompt"], all_prompt["phone"],
                             "个人资料,电话错误提示语显示不一致")

            self.assertEqual(data["email_prompt"], all_prompt["email"],
                             "个人资料,邮箱错误提示语显示不一致")

        # 验证长度
        len = self.account_center_page_navi_bar.get_modifgy_info_element_len()
        self.assertEqual(20, len["phone_len"], "电话号码长度显示不一致")
        self.assertEqual(50, len["email_len"], "邮箱长度显示不一致")

        csv_find.close()
        # 关闭修改资料框
        self.account_center_page_navi_bar.cancel_modify_user_info()
        # 退出
        # self.account_center_page_navi_bar.usr_logout()

    def tearDown(self):
        self.driver.quit_browser()
class TestCase118LoginWithLogoutDismiss(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_login_and_logout_dismiss(self):
        '''测试成功登录的用户取消退出'''
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 输入用户信息进行登录
        self.log_in_base.log_in()
        # 点账户中心
        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, "登录成功后页面跳转错误")
        # 成功退出系统
        self.account_center_page_navi_bar.usr_logout_dismiss()
        # 判断是否仍停留在当前账户首页,并未退出系统
        self.assertEqual(self.base_url + "/customer/toAccountCenter",
                         self.driver.get_current_url(), "取消退出系统失败")
class TestCase32AccountCenterMsgEdit_Exception(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.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_msg_center = AccountCenterMsgCenterPage(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.connect_sql = ConnectSql()
        self.search_sql = SearchSql()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.base_page.open_page()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def test_account_center_msg_exception_prompt(self):
        """ 消息中心,验证编辑中的错误提示 """

        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        self.driver.wait(1)
        # 点击进入消息中心
        self.account_center_page_msg_center.enter_msg_center()
        # self.account_center_page_msg_center.message_center_iframe()
        # sleep(10)
        sleep(25)

        # 取元素长度
        len = self.account_center_page_msg_center.get_message_edit_element_len(
        )
        # 基本信息
        self.assertEqual(50, len["device_name"], "设备名称长度不相同")
        self.assertEqual(20, len["sim"], "设备SIM卡号长度不相同")
        self.assertEqual(500, len["remark"], "备注长度不相同")
        # 客户信息
        self.assertEqual(20, len["driver_name"], "司机名称长度不相同")
        self.assertEqual(50, len["vehicle_number"], "车牌号长度不相同")
        self.assertEqual(50, len["sn"], "SN长度不相同")
        self.assertEqual(100, len["engine_number"], "电机/发动机号长度不相同")
        self.assertEqual(20, len["phone"], "车架号长度不相同")
        # self.assertEqual(18, len["id_card"], "电话长度不相同")
        self.assertEqual(50, len["car_frame"], "身份证号长度不相同")
        self.assertEqual(10, len["total_mileage"], "总里程长度不相同")
        # 安装信息
        self.assertEqual(100, len["install_company"], "安装公司长度不相同")
        self.assertEqual(50, len["install_personnel"], "安装人员长度不相同")
        self.assertEqual(200, len["install_address"], "安装地址长度不相同")
        self.assertEqual(200, len["install_position"], "安装位置长度不相同")

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

    def tearDown(self):
        self.driver.quit_browser()
Beispiel #8
0
class TestCase18AccountCenterOverviewSetUpLandmark(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.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.driver.set_window_max()
        self.assert_text = AssertText()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_account_center_overview_set_up_landmark(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        sleep(2)
        account_center_handle = self.driver.get_current_window_handle()
        # 点击库存
        self.account_center_page_details.account_center_iframe()
        self.account_center_page_details.account_overview('地标设置')
        self.driver.default_frame()

        all_handles = self.driver.get_all_window_handles()
        for handle in all_handles:
            if handle != account_center_handle:
                self.driver.switch_to_window(handle)
                sleep(2)
                expect_url = self.driver.get_current_url()
                actual_url = self.base_url + '/safearea/geozonemap?flag=1'
                self.assertEqual(expect_url, actual_url, '点击地标设置后,实际的url和期望的不一样!')
                sleep(2)

                actual_text = self.account_center_page_details.get_actual_text_after_click_set_up_landmark()
                self.assertEqual(self.assert_text.account_center_page_mark_point_text(), actual_text,
                                 '点击地标设置后,页面没有跳转到地标设置页面上')

                self.assertEqual('active',
                                 self.driver.get_element('x,//*[@id="safemenu"]/li[2]').get_attribute('class'))

                # 查看控制台告警设置能否打开
                self.account_center_page_navi_bar.click_alarm_button_in_console()
                # 断言
                get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button()
                self.assertEqual(self.assert_text.account_center_page_alarm_manager_text(), get_text)
                self.account_center_page_navi_bar.close_alarm_in_console()

                self.driver.close_current_page()
                # 回到账户中心窗口
                self.driver.switch_to_window(account_center_handle)
                self.driver.wait()
Beispiel #9
0
class TestCase801MessageCenterSearchMassage(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.message_center_page = MessageCenterPage(self.driver,
                                                     self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.help_page = HelpPage(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.clear_cookies()
        self.base_page.open_page()
        self.log_in_base.log_in()

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

    def test_case_801_message_center_search_massage(self):
        user_account = self.log_in_base.get_log_in_account()
        # 点击消息中心
        self.message_center_page.click_message_center_button()

        csv_file = self.account_center_page_read_csv.read_csv(
            'message_center_search.csv')
        csv_data = csv.reader(csv_file)
        i = 1
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'imei': row[0],
                'massage_type': row[1],
                'is_read': row[2]
            }
            print(search_data)
            self.message_center_page.add_data_search_message_data(search_data)
            # 获取当前用户和下级用户的所有用户id
            all_user_id = self.help_page.get_all_user_id(user_account)
            # 获取数据库查询的条数
            sql_total = self.message_center_page.get_sql_total_search_center_massage(
                search_data, all_user_id)
            # 获取页面上的数据条数
            web_total = self.message_center_page.get_web_total_search_center_massage(
            )
            print('第%s次查询的数据库总数:%s' % (i, sql_total))
            print('第%s次查询的页面总数:%s' % (i, web_total))
            i += 1
            self.assertEqual(sql_total, web_total)

        csv_file.close()
Beispiel #10
0
class TestCase14AccountCenterOverviewAlarm(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.account_center_page_details = AccountCenterDetailsPage(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_account_center_overview_alarm(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        sleep(2)
        account_center_handle = self.driver.get_current_window_handle()
        # 点击围栏
        self.account_center_page_details.account_center_iframe()
        self.account_center_page_details.account_overview('围栏')
        self.driver.default_frame()

        all_handles = self.driver.get_all_window_handles()
        for handle in all_handles:
            if handle != account_center_handle:
                self.driver.switch_to_window(handle)
                sleep(2)
                expect_url = self.driver.get_current_url()
                actual_url = self.base_url + '/safearea/geozonemap?flag=0'
                self.assertEqual(expect_url, actual_url, '点击围栏后,实际的url和期望的不一样!')
                actual_text = self.account_center_page_details.get_actual_text_after_click_alarm()
                self.assertEqual(self.assert_text.account_center_page_area_alarm_text(), actual_text,
                                 '点击围栏后,页面没有跳转到围栏设置页面')

                # 验证区域预警有没有被选中
                value = self.account_center_page_details.click_safearea_get_vaule()
                self.assertEqual('active', value)

                # 查看控制台告警设置能否打开
                self.account_center_page_navi_bar.click_alarm_button_in_console()
                # 断言
                get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button()
                self.assertEqual(self.assert_text.account_center_page_alarm_manager_text(), get_text)
                self.account_center_page_navi_bar.close_alarm_in_console()

                self.driver.close_current_page()
                # 回到账户中心窗口
                self.driver.switch_to_window(account_center_handle)
                self.driver.wait()
Beispiel #11
0
class TestCase106LoginChangeLanguage(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.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_change_language(self):
        '''测试登录切换语言'''
        language = ["English", "España", "Portugal", "Polska", "Deutschland"]

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

        # 通过登录按钮的文本内容判断默认是否为中文
        login_button_text = self.login_page.login_button_text()
        self.assertEqual(self.assert_text.log_in_page_log_in_text(),
                         login_button_text)

        # 切换语言
        login_button_text = self.login_page.change_language(language[0])
        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Log in", login_button_text[0])
        self.assertEqual("Input Account", login_button_text[1])
        self.assertEqual("Input password", login_button_text[2])

        login_button_text = self.login_page.change_language(language[1])
        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Ingresar", login_button_text[0])
        self.assertEqual("Ingrese cuenta", login_button_text[1])
        self.assertEqual("Ingrese contraseña", login_button_text[2])

        login_button_text = self.login_page.change_language(language[2])
        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Iniciar", login_button_text[0])
        self.assertEqual("Digitar conta", login_button_text[1])
        self.assertEqual("Digitar password", login_button_text[2])

        login_button_text = self.login_page.change_language(language[3])
        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Zaloguj", login_button_text[0])
        self.assertEqual("Wprowadz konto", login_button_text[1])
        self.assertEqual("Wprowadz haslo", login_button_text[2])

        login_button_text = self.login_page.change_language(language[4])
        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Einloggen", login_button_text[0])
        self.assertEqual("Konto eingeben", login_button_text[1])
        self.assertEqual("Passwort eintragen", login_button_text[2])
class TestCase08AccountCenterVisualAccount(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_visual_account = AccountCenterVisualAccountPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        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_account_center_visual_account(self):
        '''通过csv测试虚拟账户管理功能'''
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        sleep(2)
        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        self.account_center_page_visual_account.enter_visual_account()

        csv_file = self.account_center_page_read_csv.read_csv('add_visual_account.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            acc_to_add = {
                "account": row[0],
                "passwd": row[1]
            }
            # 登录
            # 获取虚拟账户管理title
            visual_account_title = self.account_center_page_visual_account.get_visual_account_title()
            # 验证消息中心title是否正确显示
            self.assertIn(self.assert_text.account_center_page_virtual_account_manager(), visual_account_title,
                          "虚拟账户管理title有误!")

            # 添加虚拟账户
            self.account_center_page_visual_account.add_visual_account(acc_to_add["account"], acc_to_add["passwd"])
            state = self.account_center_page_visual_account.get_visual_account_limits_state()
            self.assertEqual(False, state["edit_data"], "修改数据默认勾选了")
            self.assertEqual(False, state["instruction"], "下发指令默认勾选了")
            # 保存
            self.account_center_page_visual_account.save_add_info()

            # 验证是否保存成功
            save_status = self.account_center_page_visual_account.get_save_status()
            self.assertIn(self.assert_text.account_center_page_operation_done(), save_status, "保存成功")
            self.driver.wait()

        csv_file.close()
Beispiel #13
0
class TestCase68CustManageCustBatchTransferCustSearch(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.quit_browser()

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

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

        self.cust_manage_basic_info_and_add_cust_page.click_first_account()

        # 点击编辑用户
        self.cust_manage_basic_info_and_add_cust_page.click_batch_transfer_customer()

        self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit()

        self.cust_manage_basic_info_and_add_cust_page.click_batch_transfer_customer()
        # 循环点击五次
        for n in range(5):
            self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe()
            self.driver.click_element('x,//*[@id="treeDemo2_%s_span"]' % str(n + 3))
            sleep(2)
            self.driver.default_frame()

        # 搜索
        # 1 搜索无数据的内容
        self.cust_manage_basic_info_and_add_cust_page.search_cust('无数据')
        get_text = self.cust_manage_basic_info_and_add_cust_page.get_search_no_data_text()
        self.assertIn(self.assert_text.account_center_page_no_data_text(), get_text)
Beispiel #14
0
class TestCase70CustManageCustSearch(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.connect_sql = ConnectSql()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def test_cust_manage_add_cust_search(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.cancel_add_account()
        self.cust_manage_basic_info_and_add_cust_page.add_acc()

        # 添加客户名称、账号,点击保存
        self.cust_manage_basic_info_and_add_cust_page.add_account_name("虚拟账号")
        self.cust_manage_basic_info_and_add_cust_page.add_account(
            "xnzh_dzl022")
        self.cust_manage_basic_info_and_add_cust_page.acc_add_save()

        connect = self.connect_sql.connect_tuqiang_sql()
        cursor = connect.cursor()
        get_account_sql = "select account from user_info where account = 'xnzh_dzl022';"
        cursor.execute(get_account_sql)
        user = cursor.fetchall()
        print(user)
        print(len(user))
        self.assertEqual(0, len(user), "添加普通账号时,可成功添加虚拟账户")

    def tearDown(self):
        self.driver.quit_browser()
Beispiel #15
0
class TestCase121LoginChangeLanguage(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.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_change_language(self):
        '''测试登录切换语言'''
        language = ["English", "España", "Portugal", "Polska", "Deutschland"]

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

        # 通过登录按钮的文本内容判断默认是否为中文
        login_button_text = self.login_page.login_button_text()
        self.assertEqual(self.assert_text.log_in_page_log_in_text(),
                         login_button_text, "默认语言不是简体中文")

        # 切换语言

        login_button_text = self.login_page.change_language(language[0])

        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Log in", login_button_text, "语言与所切换语言不一致")

        login_button_text = self.login_page.change_language(language[1])

        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Ingresar", login_button_text, "语言与所切换语言不一致")

        login_button_text = self.login_page.change_language(language[2])

        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Iniciar", login_button_text, "语言与所切换语言不一致")

        login_button_text = self.login_page.change_language(language[3])

        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Zaloguj", login_button_text, "语言与所切换语言不一致")

        login_button_text = self.login_page.change_language(language[4])

        # 通过登录按钮的文本内容判断默认是否与所切换的语言一致
        self.assertEqual("Einloggen", login_button_text, "语言与所切换语言不一致")
Beispiel #16
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)
class TestCase139RiskPointShare(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.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.safe_area_page = SafeAreaPage(self.driver, self.base_url)

        self.base_page.open_page()
        self.base_page.click_chinese_button()
        self.driver.set_window_max()
        self.assert_text = AssertText()
        self.log_in_base.log_in_jimitest()
        self.connect_sql = ConnectSql()
        self.search_sql = SafeAreaSearchSql()
        self.safe_area_page_read_csv = SafeAreaPageReadCsv()

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

    def test_case_139_risk_point_share(self):
        # 点击账号中心
        sleep(5)
        self.safe_area_page.click_account_center()
        # 获取登录账号
        account = self.log_in_base.get_log_in_account()
        # 断言url
        self.safe_area_page.click_control_after_click_safe_area()
        expect_url = self.base_url + "/safearea/geozonemap?flag=0"
        self.assertEqual(expect_url, self.driver.get_current_url())

        self.safe_area_page.click_risk_point_share_button()
        csv_file = self.safe_area_page_read_csv.read_csv(
            'risk_point_share.csv')
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            data = {'risk_name': row[0]}
            self.safe_area_page.add_data_to_search_risk_point_in_safe_area(
                data)
            # 获取查询出来的页面条数
            web_total = self.safe_area_page.get_web_total_after_click_search_risk_share(
            )
            sql_total = self.safe_area_page.get_sql_total_after_click_search_risk_share(
                data)
            self.assertEqual(web_total, sql_total)
        csv_file.close()
Beispiel #18
0
class TestCase132MarkPaging(unittest.TestCase):
    """ web_autotest账号,标注点页面分页功能 """

    # author:邓肖斌

    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.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.safe_area_page = SafeAreaPage(self.driver, self.base_url)

        self.base_page.open_page()
        self.base_page.click_chinese_button()
        self.driver.set_window_max()
        self.log_in_base.log_in()
        self.safe_area_page.click_control_after_click_safe_area()
        self.safe_area_page_read_csv = SafeAreaPageReadCsv()

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

    def test_case_mark_paging(self):
        # 断言url
        expect_url = self.base_url + "/safearea/geozonemap?flag=0"
        self.assertEqual(expect_url, self.driver.get_current_url())

        self.safe_area_page.click_mark_button()
        sleep(2)

        # 获取总页数
        total_number = self.safe_area_page.get_total_page_number_mark()
        if total_number == '0':
            print('无数据!')
        elif total_number == '1':
            print('就一页!')
        else:
            # 下一页
            self.safe_area_page.click_next_page_mark()
            self.assertEqual('2', self.safe_area_page.get_current_page_number_mark())
            # 点击上一页
            self.safe_area_page.click_ago_page_mark()
            self.assertEqual('1', self.safe_area_page.get_current_page_number_mark())

            # 点击尾页
            self.safe_area_page.click_last_page_mark()
            self.assertEqual(self.safe_area_page.get_current_page_number_mark(),
                             self.safe_area_page.get_total_page_number_mark())
            # 点击首页
            self.safe_area_page.clcik_first_page_mark()
            self.assertEqual('1', self.safe_area_page.get_current_page_number_mark())
class TestCase802MessageCenterClickUnreadMessage(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.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.message_center_page = MessageCenterPage(self.driver, self.base_url)
        self.help_page = HelpPage(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.clear_cookies()
        self.base_page.open_page()
        self.log_in_base.log_in()

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

    def test_case_802_message_center_click_unread_message(self):
        # 获取未读消息的总数
        unread_message_total_number = self.message_center_page.get_unread_message_total_number()
        print(unread_message_total_number)
        # 点击消息中心
        self.message_center_page.click_message_center_button()
        data = {
            'imei': '',
            'massage_type': '',
            'is_read': '未读'
        }
        self.message_center_page.add_data_search_message_data(data)
        # 获取搜索出来的未读消息的总数
        search_unread_message_total_number = self.message_center_page.get_web_total_search_center_massage()

        self.assertEqual(unread_message_total_number, str(search_unread_message_total_number))

        if unread_message_total_number == '0':
            pass
        else:
            # 点击其中一条未读消息
            self.message_center_page.click_anyone_unread_message()
            # 点击标为已读按钮
            self.message_center_page.click_set_unread_message_read()

            # 重新获取抬头上的未读消息数量
            unread_message_total_number_01 = self.message_center_page.get_unread_message_total_number()
            self.assertEqual(int(unread_message_total_number) - 1, int(unread_message_total_number_01))
class TestCase803MessageCenterClickUnreadMessageAllRead(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.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.message_center_page = MessageCenterPage(self.driver,
                                                     self.base_url)
        self.help_page = HelpPage(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.clear_cookies()
        self.base_page.open_page()
        self.log_in_base.log_in()

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

    def test_case_803_message_center_click_unread_message_all_read(self):
        # 获取未读消息的总数
        unread_message_total_number = self.message_center_page.get_unread_message_total_number(
        )
        print(unread_message_total_number)
        # 点击消息中心
        self.message_center_page.click_message_center_button()
        sleep(10)

        # 点击全部标记为已读
        self.message_center_page.click_set_unread_message_all_read()
        sleep(10)
        unread_message_total_number_01 = self.message_center_page.get_unread_message_total_number(
        )
        print(unread_message_total_number_01)
        self.assertEqual('0', unread_message_total_number_01)

        # 搜索未读消息数量
        data = {'imei': '', 'massage_type': '', 'is_read': '未读'}
        self.message_center_page.add_data_search_message_data(data)
        # 获取搜索出来的未读消息的总数
        search_unread_message_total_number = self.message_center_page.get_web_total_search_center_massage(
        )
        self.assertEqual(0, search_unread_message_total_number)
class TestCase26AccountCenterDefaultHomePageNoSetting(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_home_page_setting = AccountCenterSettingHomePage(
            self.driver, self.base_url)
        self.assert_text2 = AssertText2()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_no_setting_default_home_page(self):
        '''没有设置默认首页验证'''

        self.log_in_base.log_in_with_csv("zcs001", "jimi123")
        self.account_center_page_navi_bar.click_account_center_button()
        # 点击默认首页设置
        self.account_center_page_home_page_setting.click_home_page_setting()

        # 取列表数据
        all_state = self.account_center_page_home_page_setting.get_home_page_list_all_state(
        )
        for i in all_state:
            self.assertEqual(
                self.assert_text2.account_center_home_page_no_setting_state(),
                i, "并不是全部为默认设置")

        sleep(2)
        # 退出
        self.account_center_page_navi_bar.usr_logout()
        # 登录
        self.log_in_base.log_in_with_csv("zcs001", "jimi123")
        expect_url = self.driver.get_current_url()
        actual_url = self.base_url + "/customer/toAccountCenter"
        self.assertEqual(expect_url, actual_url, "未设置默认首页,登陆后并不是进入账户中心页")
class TestCase64CustManageSearch(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.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_search(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录
        self.log_in_base.log_in()

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

        # 循环点击5次
        for n in range(5):
            self.driver.click_element('x,//*[@id="treeDemo_%s_span"]' % str(n + 2))
            sleep(2)
            text = self.driver.get_text('x,//*[@id="treeDemo_%s_span"]' % str(n + 2))
            account_name = text.split('(')[0]
            value = self.driver.get_text('x,//*[@id="user_account"]')
            self.assertEqual(account_name, value)

        # 搜索无数据
        self.cust_manage_basic_info_and_add_cust_page.search_customer('无数据')
        get_text = self.cust_manage_basic_info_and_add_cust_page.get_search_customer_no_data_text()
        self.assertIn(self.assert_text.account_center_page_no_data_text(), get_text)
Beispiel #23
0
class TestCase33AccountCenterAddVisualEditException(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.visual_account_page = AccountCenterVisualAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.assert_text = AssertText()
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def test_add_visual_account_exception_validation(self):
        '''添加虚拟用户验证'''

        data = ["jimitest", "dzltest", "xnzh_cs01"]

        # 登录
        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        # 进入虚拟账户管理
        self.visual_account_page.enter_visual_account()
        # 添加虚拟账号、保存
        for i in range(len(data)):
            self.visual_account_page.add_visual_account(data[i], "jimi123")
            self.visual_account_page.save_add_info()
            self.visual_account_page.dis_save_add_info()
            self.driver.wait(1)
            self.assertEqual(
                self.assert_text.account_center_page_account_exist(),
                self.visual_account_page.get_save_status(),
                "在添加虚拟账号中可以添加已存在的账号!")
            self.driver.wait(1)
            # 退出登录
            # self.account_center_page_navi_bar.usr_logout()

    def tearDown(self):
        self.driver.quit_browser()
Beispiel #24
0
class TestCase120LoginForgetPasswd(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.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_login_forget_passwd(self):
        '''测试忘记密码功能'''
        # 打开途强在线首页-登录页
        self.base_page.open_page()

        # 点击忘记密码
        self.login_page.forget_password()
        self.driver.wait()

        # 断言找回密码的文本框
        self.assertEqual(self.assert_text.log_in_page_find_password_text(),
                         self.login_page.get_text_after_forget_password())
        # 输入账号
        self.login_page.forget_passwd_account("test_007")
        # 输入电话
        self.login_page.forget_passwd_phone("13530050000")
        # 取消修改密码
        self.login_page.dis_forget_passwd2()
        self.driver.wait()
        # 通过能否获取到登录按钮的文本内容来判断是否成功取消弹框
        login_button_text = self.login_page.login_button_text()
        self.assertEqual(self.assert_text.log_in_page_log_in_text(),
                         login_button_text)
        self.driver.wait()
        # 点体验账号
        '''self.login_page.click_experience_account()
class TestCase211UserCenterLogout(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.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.user_center_page = UserCenterPage(self.driver, self.base_url)
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_user_center_logout(self):
        self.base_page.open_page()
        self.log_in_base.log_in()

        # 点击退出登录
        self.user_center_page.click_user_center_button()
        # 点击退出登录按钮
        self.user_center_page.click_logout_button()
        # 点击取消
        self.user_center_page.click_cancel_button()

        # 点击退出登录
        self.user_center_page.click_user_center_button()
        # 点击退出登录按钮
        self.user_center_page.click_logout_button()
        # 点击取消
        self.user_center_page.click_close_button()

        # 点击退出登录
        self.user_center_page.click_user_center_button()
        # 点击退出登录按钮
        self.user_center_page.click_logout_button()
        # 点击取消
        self.user_center_page.click_ensure_button()
Beispiel #26
0
class TestCase119LoginWithRememberMe(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.driver.set_window_max()
        self.driver.wait(1)

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

    def test_login_with_remember_me(self):
        '''测试登录时勾选记住我'''
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        self.log_in_base.log_in()
        # 点账户中心
        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)
        # 成功退出系统
        self.account_center_page_navi_bar.usr_logout()
        # 判断是否成功退出系统
        self.assertEqual(self.base_url + "/", self.driver.get_current_url(),
                         "退出系统失败")
        # 验证退出系统后“记住我”是否是已勾选状态
        box_status = self.login_page.check_remember_me()
        self.assertEqual(True, box_status, '记住密码失败')
Beispiel #27
0
class TestCase410918AccountCenterRefillCardAddApply(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.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_refill_card = AccountCenterRefillCardPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        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_apply_refill_card(self):
        '''充值卡-申请记录--申请充值卡'''

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        # self.log_in_base.log_in_with_csv("dzltest", "jimi123")
        self.log_in_base.log_in()
        self.driver.wait(1)
        self.account_center_page_navi_bar.click_account_center_button()

        # 进入充值卡页面
        # self.account_center_page_navi_bar.switch_to_chongzhi_card()
        self.account_center_page_refill_card.click_refill_card()

        csv_file = self.account_center_page_read_csv.read_csv(
            'apply_refill_card.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            data = {
                "year": row[0],
                "lifetime": row[1],
                "name": row[2],
                "phone": row[3],
                "payment_account": row[4]
            }
            # 验证页面顶部我的账号
            my_account = self.account_center_page_refill_card.get_title_display_account(
            )
            # 取消
            self.account_center_page_refill_card.apply_refill_card_cancel()

            # 验证账号
            self.account_center_page_refill_card.click_apply_refill_card_button(
            )
            apply_page_account = self.account_center_page_refill_card.get_refill_account(
            )
            self.assertEqual(my_account, apply_page_account, "充值账号显示不一致")

            # 添加充值卡
            self.account_center_page_refill_card.apply_refill_card_add(
                data["year"], data["lifetime"], data["name"], data["phone"],
                data["payment_account"])

            information = self.account_center_page_refill_card.get_applicant_information(
            )

            statu = self.account_center_page_refill_card.get_operate_status()
            self.assertEqual(
                self.assert_text2.account_center_refill_card_apply_succeed(),
                statu, "申请充值卡失败")

            # 验证添加数据与申请人信息
            self.assertEqual(apply_page_account,
                             information["applicant_account"],
                             "申请人信息中,充值账号显示不一致")
            self.assertEqual(data["year"] + "张", information["year"],
                             "申请人信息中,一年充值卡张数显示不一致")
            self.assertEqual(data["lifetime"] + "张", information["lifetime"],
                             "申请人信息中,终身充值卡张数显示不一致")
            self.assertEqual(data["name"], information["name"],
                             "申请人信息中,付款人姓名显示不一致")
            self.assertEqual(data["phone"], information["phone"],
                             "申请人信息中,充值联系方式显示不一致")
            self.assertEqual(data["payment_account"],
                             information["payment_account"],
                             "申请人信息中,付款账号显示不一致")

        csv_file.close()
Beispiel #28
0
class TestCase57CustManageCheckAccount(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(
            self.driver, self.base_url)
        self.cust_manage_cust_list_page = CustManageCustListPage(
            self.driver, self.base_url)
        self.cust_manage_my_dev_page = CustManageMyDevPage(
            self.driver, self.base_url)
        self.cust_manage_lower_account_page = CustManageLowerAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.connect_sql = ConnectSql()
        self.cust_manage_page_read_csv = CustManagePageReadCsv()
        self.assert_text = AssertText()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

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

        # 登录
        self.log_in_base.log_in()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                # 断言账号类型
                cursor_02.close()
                connect_02.close()
            cursor.close()
            connect.close()
        csv_file.close()
class TestCase37AccountCenterSearchLowerClientVerify(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.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(
            self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.account_center_change_page = AccountCenterChangePage(
            self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_search_lower_client(self):
        '''通过csv测试账户详情--下级客户--查找不同账号功能'''

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in()
        self.driver.wait(1)
        self.account_center_page_navi_bar.click_account_center_button()
        self.account_center_change_page.switch_fast_sale_enable()
        self.account_center_change_page.switch_to_fast_sale_frame()

        csv_file = self.account_center_page_read_csv.read_csv(
            'search_different_account.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            search_account = {"account": row[0]}

            # 查找账户
            search_result = self.account_center_page_details.subordinate_account_search(
                search_account["account"])
            if type(search_result) is str:
                self.assertIn(
                    self.assert_text.account_center_page_no_data_text(),
                    search_result, "搜索结果为暂无数据时,提示不一致")

            else:
                for subscript in range(len(search_result)):
                    text = search_result[subscript].split("(")[0]
                    self.assertIn(search_account["account"], text, "搜索结果不一致")

            self.driver.wait()

        # 直接选择用户
        for user in range(8):
            self.account_center_page_details.fast_sales()
            self.account_center_page_details.click_list_subordinate_client(
                user + 1)

        # 验证enter键输入
        self.account_center_page_details.fast_sales()
        self.account_center_page_details.search_subordinate_client_click_enter(
            "1234")

        self.driver.wait()
        self.driver.default_frame()
        csv_file.close()
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()