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

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

    def test_case_user_search_transfer_user(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        self.log_in_base.log_in()
        # 点击账号中心
        self.log_in_base.click_account_center_button()
        self.global_dev_search_page.click_easy_search()
        # 关闭
        self.global_dev_search_page.close_search()
        sleep(2)

        self.global_dev_search_page.click_easy_search()

        # 选择用户搜索
        self.global_dev_search_page.click_user_search_buttons()

        # 获取列表中第二个用户的账号
        self.global_dev_search_page.swith_to_search_frame()
        get_second_user_account = self.global_account_search_page.get_second_user_account_after_search_user(
        )
        # 点击详情
        self.global_account_search_page.click_user_detail_button()
        # 点击销售设备
        self.global_account_search_page.click_transfer_user_button_in_user_detail_button(
        )
        # 选择的用户是该用户(用户详情所属的用户)或其下级用户,提示“选择的用户不能作为上级用户”
        self.global_account_search_page.search_user_to_transfer_user_in_user_detail(
            get_second_user_account)
        get_text = self.global_account_search_page.get_text_after_click_transfer_user(
        )
        self.assertEqual(
            self.assert_text.the_selected_user_cannot_be_the_superior(),
            get_text)
class TestCase100GlobAccountSearch(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

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

        # 度数据
        csv_file = self.global_search_page_read_csv.read_csv('global_search_account_data.csv')
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'account_info': row[0]
            }
            self.global_dev_search_page.swith_to_search_frame()
            self.global_dev_search_page.account_easy_search(search_data)

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

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

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

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

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

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

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

        self.global_dev_search_page.click_easy_search()
        # self.global_dev_search_page.click_dev_search()
        self.global_dev_search_page.swith_to_search_frame()
        self.global_account_search_page.click_search_user_button()

        # 获取页面总共有多少页
        total_number = self.global_account_search_page.get_total_number_after_click_search_user_button(
        )

        if total_number == 0:
            self.assertIn(
                self.assert_text.account_center_page_no_data_text(),
                self.global_account_search_page.
                get_no_data_text_in_user_search())
        elif total_number == 1:
            up_page_state = self.global_account_search_page.get_up_page_state_in_search_user(
            )
            self.assertEqual('active', up_page_state)
            next_page_state = self.global_account_search_page.get_next_page_state_in_search_user(
            )
            self.assertEqual('active', next_page_state)
        else:
            for n in range(total_number):
                self.global_account_search_page.click_per_page(n)

        if total_number != 0:
            self.global_account_search_page.click_per_number()
class TestCase118UserSearchModifyBatchIssuedWorkTypeAuthority(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver(choose='firefox')
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.assert_text = AssertText()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

        self.global_dev_search_page.click_easy_search()

        # 选择用户搜索
        self.global_dev_search_page.click_dev_search()
        self.global_dev_search_page.click_search_buttons()

        # 获取列表中第二个用户的账号
        self.global_dev_search_page.swith_to_search_frame()
        get_second_user_account = self.global_account_search_page.get_second_user_account_after_search_user()
        # 点击详情
        self.global_account_search_page.click_user_detail_button()
        # 点击用户信息
        self.global_account_search_page.click_user_info_in_user_detail()

        # 获取用户信息页面登录账号名字
        current_account = self.global_account_search_page.get_current_account_in_user_detail()
        self.assertEqual(get_second_user_account, current_account)

        # 获取各个权限input的select属性
        web_login_authority = self.global_account_search_page.get_web_login_authority_input_select_in_user_detail()
        app_login_authority = self.global_account_search_page.get_app_login_authorith_input_select_in_user_detail()

        batch_issued_command_authority = self.global_account_search_page.batch_issued_command_authority_in_user_detail()
        batch_issued_work_type_authority = self.global_account_search_page.batch_issued_work_type_authority_in_user_detail()

        web_modify_authority = self.global_account_search_page.get_web_modify_authority_in_user_detail()
        app_modify_authority = self.global_account_search_page.get_app_modify_authority_in_user_detail()

        if batch_issued_work_type_authority == True:
            ## 点击批量下发工作模式
            self.global_account_search_page.click_modify_batch_issued_work_type_authority_in_user_detail()
            # 点击保存
            self.global_account_search_page.click_ensuer_button_in_user_detail()
            # 点击关闭
            self.driver.default_frame()
            self.global_account_search_page.click_close_button()

            # # 退出登录
            self.global_account_search_page.logout()

            # 登录刚刚修改过的账号
            self.global_account_search_page.log_in_user(get_second_user_account, 'jimi123')
            # 进入设备管理页面
            self.global_account_search_page.click_dev_manage_page()

            total_number = self.global_account_search_page.get_total_button_in_dev_manage()
            operation_all = []
            for n in range(total_number):
                get_per_operation = self.global_account_search_page.get_per_operation_in_dev_manage(n)
                operation_all.append(get_per_operation)

            select_issued_work_type = self.assert_text.select_issued_work_type_text()
            self.assertNotIn(select_issued_work_type, operation_all)
            all_issued_work_type = self.assert_text.all_issued_work_type_text()
            self.assertNotIn(all_issued_work_type, operation_all)

            # 退出登录的账号
            self.global_account_search_page.click_account_manage_page()
            self.global_account_search_page.logout()

            # 登录web_autotest
            self.log_in_base.log_in()
            self.log_in_base.click_account_center_button()
            self.global_dev_search_page.click_easy_search()
            # 关闭
            self.global_dev_search_page.close_search()
            sleep(2)
            self.global_dev_search_page.click_easy_search()
            # 选择用户搜索
            self.global_dev_search_page.click_dev_search()
            self.global_dev_search_page.click_search_buttons()
            # 点击详情
            self.global_dev_search_page.swith_to_search_frame()
            self.global_account_search_page.click_user_detail_button()
            # 点击用户信息
            self.global_account_search_page.click_user_info_in_user_detail()

            ## 点击批量下发工作模式
            self.global_account_search_page.click_modify_batch_issued_work_type_authority_in_user_detail()
            # 点击保存
            self.global_account_search_page.click_ensuer_button_in_user_detail()
            # 点击关闭
            self.driver.default_frame()
            self.global_account_search_page.click_close_button()

            # # 退出登录
            self.global_account_search_page.logout()

            # 登录刚刚修改过的账号
            self.global_account_search_page.log_in_user(get_second_user_account, 'jimi123')
            # 进入设备管理页面
            self.global_account_search_page.click_dev_manage_page()

            total_number = self.global_account_search_page.get_total_button_in_dev_manage()
            operation_all = []
            for n in range(total_number):
                get_per_operation = self.global_account_search_page.get_per_operation_in_dev_manage(n)
                operation_all.append(get_per_operation)

            select_issued_work_type = self.assert_text.select_issued_work_type_text()
            self.assertIn(select_issued_work_type, operation_all)
            all_issued_work_type = self.assert_text.all_issued_work_type_text()
            self.assertIn(all_issued_work_type, operation_all)

        if batch_issued_work_type_authority == False:
            ## 点击批量下发工作模式
            self.global_account_search_page.click_modify_batch_issued_work_type_authority_in_user_detail()
            # 点击保存
            self.global_account_search_page.click_ensuer_button_in_user_detail()
            # 点击关闭
            self.driver.default_frame()
            self.global_account_search_page.click_close_button()

            # # 退出登录
            self.global_account_search_page.logout()

            # 登录刚刚修改过的账号
            self.global_account_search_page.log_in_user(get_second_user_account, 'jimi123')
            # 进入设备管理页面
            self.global_account_search_page.click_dev_manage_page()

            total_number = self.global_account_search_page.get_total_button_in_dev_manage()
            operation_all = []
            for n in range(total_number):
                get_per_operation = self.global_account_search_page.get_per_operation_in_dev_manage(n)
                operation_all.append(get_per_operation)

            select_issued_work_type = self.assert_text.select_issued_work_type_text()
            self.assertIn(select_issued_work_type, operation_all)
            all_issued_work_type = self.assert_text.all_issued_work_type_text()
            self.assertIn(all_issued_work_type, operation_all)

            # 退出登录的账号
            self.global_account_search_page.click_account_manage_page()
            self.global_account_search_page.logout()

            # 登录web_autotest
            self.log_in_base.log_in()
            self.log_in_base.click_account_center_button()
            self.global_dev_search_page.click_easy_search()
            # 关闭
            self.global_dev_search_page.close_search()
            sleep(2)
            self.global_dev_search_page.click_easy_search()
            # 选择用户搜索
            self.global_dev_search_page.click_dev_search()
            self.global_dev_search_page.click_search_buttons()
            # 点击详情
            self.global_dev_search_page.swith_to_search_frame()
            self.global_account_search_page.click_user_detail_button()
            # 点击用户信息
            self.global_account_search_page.click_user_info_in_user_detail()

            ## 点击批量下发工作模式
            self.global_account_search_page.click_modify_batch_issued_work_type_authority_in_user_detail()
            # 点击保存
            self.global_account_search_page.click_ensuer_button_in_user_detail()
            # 点击关闭
            self.driver.default_frame()
            self.global_account_search_page.click_close_button()

            # # 退出登录
            self.global_account_search_page.logout()

            # 登录刚刚修改过的账号
            self.global_account_search_page.log_in_user(get_second_user_account, 'jimi123')
            # 进入设备管理页面
            self.global_account_search_page.click_dev_manage_page()

            total_number = self.global_account_search_page.get_total_button_in_dev_manage()
            operation_all = []
            for n in range(total_number):
                get_per_operation = self.global_account_search_page.get_per_operation_in_dev_manage(n)
                operation_all.append(get_per_operation)

            select_issued_work_type = self.assert_text.select_issued_work_type_text()
            self.assertNotIn(select_issued_work_type, operation_all)
            all_issued_work_type = self.assert_text.all_issued_work_type_text()
            self.assertNotIn(all_issued_work_type, operation_all)
Beispiel #6
0
class TestCase128DevAdvancedSearchWithDeleteUser(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.assert_text = AssertText()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

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

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

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

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

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

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

    def test_case_user_search_sale_dev(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        self.log_in_base.log_in()
        # 点击设备管理 获取imei号
        self.global_account_search_page.click_dev_manage_page()
        first_imei = self.global_account_search_page.get_frist_imei_in_dev_manage_page(
        )
        second_imei = self.global_account_search_page.get_second_imei_in_dev_manage_page(
        )
        third_imei = self.global_account_search_page.get_third_imei_in_dev_manage_page(
        )
        fourth_imei = self.global_account_search_page.get_fourth_imei_in_dev_manage_page(
        )
        fifth_imei = self.global_account_search_page.get_fifth_imei_in_dev_manage_page(
        )

        # 点击账号中心
        self.log_in_base.click_account_center_button()
        self.global_dev_search_page.click_easy_search()
        # 关闭
        self.global_dev_search_page.close_search()
        sleep(2)

        self.global_dev_search_page.click_easy_search()

        # 选择用户搜索
        # self.global_dev_search_page.click_dev_search()
        self.global_dev_search_page.click_user_search_buttons()

        # 获取列表中第二个用户的账号
        self.global_dev_search_page.swith_to_search_frame()
        get_second_user_account = self.global_account_search_page.get_second_user_account_after_search_user(
        )
        # 点击详情
        self.global_account_search_page.click_user_detail_button()
        # 点击销售设备
        self.global_account_search_page.clcik_sale_dev_button_in_user_detail_button(
        )
        # 输入不存在的imei进行添加
        self.global_account_search_page.add_imei_to_sale_dev_in_user_detail(
            first_imei + '123456')
        # 获取失败的状态
        failure_statues = self.global_account_search_page.get_failure_statue_text_in_user_detail(
        )
        self.assertEqual(self.assert_text.dev_page_fail_text(),
                         failure_statues)
        failure_reason = self.global_account_search_page.get_failure_reason_text_in_user_detail(
        )
        self.assertEqual(self.assert_text.dev_page_inexistence_text(),
                         failure_reason)

        # 关闭失败的弹窗
        self.global_account_search_page.close_failure_windows()

        # 输入与 IMEI 列表中相同、存在的IMEI,点击添加
        self.global_account_search_page.add_imei_to_sale_dev_in_user_detail(
            first_imei)
        self.global_account_search_page.add_imei_to_sale_dev_in_user_detail(
            first_imei)

        # 获取失败的状态
        failure_statues = self.global_account_search_page.get_failure_statue_text_in_user_detail(
        )
        self.assertEqual(self.assert_text.dev_page_fail_text(),
                         failure_statues)
        failure_reason = self.global_account_search_page.get_failure_reason_text_in_user_detail(
        )
        self.assertEqual(self.assert_text.dev_page_repetition_text(),
                         failure_reason)

        # 关闭失败的弹窗
        self.global_account_search_page.close_failure_windows()

        # 输入与 IMEI 列表中不相同、存在的IMEI,点击添加
        self.global_account_search_page.add_imei_to_sale_dev_in_user_detail(
            second_imei)
        get_imei_after_add = self.global_account_search_page.get_imei_after_add_in_user_detail(
        )
        self.assertEqual(second_imei, get_imei_after_add)

        # 输入多个设备的IMEI,其中部分不存在,其中部分与列表中IMEI重复
        self.global_account_search_page.add_imei_to_sale_dev_in_user_detail(
            second_imei + ',' + first_imei + '123456' + ',' + third_imei)
        # 获取失败的状态
        failure_statues = self.global_account_search_page.get_failure_statue_text_in_user_detail(
        )
        self.assertEqual(self.assert_text.dev_page_fail_text(),
                         failure_statues)
        failure_reason = self.global_account_search_page.get_failure_reason_text_in_user_detail(
        )
        self.assertEqual(self.assert_text.dev_page_repetition_text(),
                         failure_reason)

        second_failure_statues = self.global_account_search_page.get_second_failure_statue_text_in_user_detail(
        )
        self.assertEqual(self.assert_text.dev_page_fail_text(),
                         second_failure_statues)
        second_failure_reason = self.global_account_search_page.get_second_failure_reason_text_in_user_detail(
        )
        self.assertEqual(self.assert_text.dev_page_inexistence_text(),
                         second_failure_reason)

        # 关闭失败的弹窗
        self.global_account_search_page.close_failure_windows()

        # 输入多个设备的IMEI,与列表中IMEI不重复,点击添加
        self.global_account_search_page.add_imei_to_sale_dev_in_user_detail(
            fourth_imei + ',' + fifth_imei)
        total_dev_number = self.global_account_search_page.get_total_dev_number_after_add_in_sale_dev(
        )
        self.assertEqual(5, total_dev_number)
Beispiel #8
0
class TestCase121UserSearchSaleDev(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.assert_text = AssertText()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

    def test_case_user_search_sale_dev(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        self.log_in_base.log_in()
        # 点击设备管理 获取imei号
        self.global_account_search_page.click_dev_manage_page()
        first_imei = self.global_account_search_page.get_frist_imei_in_dev_manage_page(
        )
        second_imei = self.global_account_search_page.get_second_imei_in_dev_manage_page(
        )
        third_imei = self.global_account_search_page.get_third_imei_in_dev_manage_page(
        )
        fourth_imei = self.global_account_search_page.get_fourth_imei_in_dev_manage_page(
        )
        fifth_imei = self.global_account_search_page.get_fifth_imei_in_dev_manage_page(
        )

        # 点击账号中心
        self.log_in_base.click_account_center_button()
        self.global_dev_search_page.click_easy_search()
        # 关闭
        self.global_dev_search_page.close_search()
        sleep(2)

        self.global_dev_search_page.click_easy_search()

        # 选择用户搜索
        self.global_dev_search_page.click_user_search_buttons()

        # 获取列表中第二个用户的账号
        self.global_dev_search_page.swith_to_search_frame()
        get_second_user_account = self.global_account_search_page.get_second_user_account_after_search_user(
        )
        # 点击详情
        self.global_account_search_page.click_user_detail_button()
        # 点击销售设备
        self.global_account_search_page.clcik_sale_dev_button_in_user_detail_button(
        )

        # 设备列表为空,点击销售
        self.global_account_search_page.click_sale_button_in_user_search()
        text = self.global_account_search_page.get_text_after_click_sale_button_with_no_dev(
        )
        self.assertEqual(self.assert_text.glob_search_please_add_dev_text(),
                         text)

        # 设备列表不为空,点击重置
        self.global_account_search_page.add_imei_to_sale_dev_in_user_detail(
            fifth_imei)
        self.global_account_search_page.select_user_expire_time_in_user_detail(
        )

        # 点击重置
        self.global_account_search_page.click_reset_button_in_user_detail()
        total_dev_number = self.global_account_search_page.get_total_dev_number_after_add_in_sale_dev(
        )
        self.assertEqual(0, total_dev_number)

        count_dev_number = self.global_account_search_page.count_dev_number_in_sale_dev_page(
        )
        self.assertEqual('0', count_dev_number)

        user_expire_text = self.global_account_search_page.get_user_expire_text_in_sale_dev(
        )
        self.assertEqual(self.assert_text.please_select_text(),
                         user_expire_text)
Beispiel #9
0
class TestCase114UserSearchUserRelation(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.assert_text = AssertText()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

        self.global_dev_search_page.click_easy_search()

        # 选择用户搜索
        # self.global_dev_search_page.click_dev_search()
        self.global_dev_search_page.click_user_search_buttons()

        user_name = self.global_dev_search_page.get_user_name_in_user_search()
        user_type = self.global_dev_search_page.get_user_type_in_user_search()
        user_account = self.global_dev_search_page.get_user_account_in_user_search(
        )

        self.global_dev_search_page.click_detail_in_user_search()
        # 验证用户信息
        self.global_dev_search_page.swith_to_search_frame()
        user_name_in_user_detail = self.global_account_search_page.get_user_name_in_user_detail(
        )
        self.assertEqual(user_name, user_name_in_user_detail)

        user_type_in_user_detail = self.global_account_search_page.get_user_type_in_user_detail(
        )
        self.assertEqual(user_type, " " + user_type_in_user_detail)

        user_account_in_user_detail = self.global_account_search_page.get_user_account_in_user_detail(
        )
        self.assertEqual(user_account, user_account_in_user_detail)

        dev_number_in_user_detail = self.global_account_search_page.get_dev_number_in_user_detail(
        )

        # 分别点击控制台、重置密码、查看
        # 点击查看
        current_handle = self.driver.get_current_window_handle()
        self.global_account_search_page.click_look_button_in_user_detail()
        all_handles = self.driver.get_all_window_handles()
        for handle in all_handles:
            if handle != current_handle:
                self.driver.switch_to_window(handle)

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

                get_total_dev_number = self.global_account_search_page.get_dev_total_number_in_dev_manage_page(
                )
                self.assertEqual(dev_number_in_user_detail,
                                 str(get_total_dev_number))
                self.driver.close_current_page()

                self.driver.switch_to_window(current_handle)

        # 点控制台
        current_handle = self.driver.get_current_window_handle()
        self.global_dev_search_page.swith_to_search_frame()
        self.global_account_search_page.click_console_button_in_user_detail()
        all_handles = self.driver.get_all_window_handles()
        for handle in all_handles:
            if handle != current_handle:
                self.driver.switch_to_window(handle)

                expect_url = self.driver.base_url + '/console'
                self.assertEqual(self.driver.get_current_url(), expect_url)
                self.driver.close_current_page()
                self.driver.switch_to_window(current_handle)

        # 点击重置密码
        self.global_dev_search_page.swith_to_search_frame()
        self.global_account_search_page.click_reset_password_button_in_user_detail(
        )
        # 点击关闭
        self.global_account_search_page.click_close_button()

        # 点击重置密码
        self.global_account_search_page.click_reset_password_button_in_user_detail(
        )
        # 点击取消
        self.global_account_search_page.click_cancel_button()

        # 点击重置密码
        self.global_account_search_page.click_reset_password_button_in_user_detail(
        )
        # 点击确定
        self.global_account_search_page.click_ensuer_button()
        sleep(4)
        self.driver.default_frame()
        self.global_account_search_page.click_close_button()
class TestCase112UserSearchByDeleteUser(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriver()
        self.base_url = self.driver.base_url
        self.base_page = BasePage(self.driver, self.base_url)
        self.global_dev_search_page = GlobalDevSearchPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPages(
            self.driver, self.base_url)
        self.driver.set_window_max()
        self.global_account_search_page = GlobalAccountSearchPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBase(self.driver, self.base_url)
        self.global_search_page_read_csv = GlobleSearchPageReadCsv()
        self.search_sql = SearchSql()
        self.assert_text = AssertText()
        self.driver.wait(1)
        self.connect_sql = ConnectSql()
        self.driver.clear_cookies()
        self.driver.wait(1)

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

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

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

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

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

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

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

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

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

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

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

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

        self.global_dev_search_page.click_easy_search()

        # 选择用户搜索
        self.global_dev_search_page.click_dev_search()
        self.global_dev_search_page.click_search_buttons()

        # 获取列表中第二个用户的账号
        self.global_dev_search_page.swith_to_search_frame()
        get_second_user_account = self.global_account_search_page.get_second_user_account_after_search_user(
        )
        # 点击详情
        self.global_account_search_page.click_user_detail_button()
        # 点击用户信息
        self.global_account_search_page.click_user_info_in_user_detail()

        # 获取用户信息页面登录账号名字
        current_account = self.global_account_search_page.get_current_account_in_user_detail(
        )
        self.assertEqual(get_second_user_account, current_account)

        # 获取各个权限input的select属性
        web_login_authority = self.global_account_search_page.get_web_login_authority_input_select_in_user_detail(
        )
        app_login_authority = self.global_account_search_page.get_app_login_authorith_input_select_in_user_detail(
        )

        batch_issued_command_authority = self.global_account_search_page.batch_issued_command_authority_in_user_detail(
        )
        batch_issued_work_type_authority = self.global_account_search_page.batch_issued_work_type_authority_in_user_detail(
        )

        web_modify_authority = self.global_account_search_page.get_web_modify_authority_in_user_detail(
        )
        app_modify_authority = self.global_account_search_page.get_app_modify_authority_in_user_detail(
        )

        if web_modify_authority == True:
            # 点击web修改设备的权限
            self.global_account_search_page.click_web_modify_dev_authority_in_user_detail(
            )
            # 点击保存
            self.global_account_search_page.click_ensuer_button_in_user_detail(
            )
            # 点击关闭
            self.driver.default_frame()
            self.global_account_search_page.click_close_button()

            # 退出登录
            self.global_account_search_page.logout()

            # 登录刚刚修改过的账号
            self.global_account_search_page.log_in_user(
                get_second_user_account, 'jimi123')
            # 进入设备管理页面
            self.global_account_search_page.click_dev_manage_page()
            sleep(2)
            # 点击编辑设备
            self.global_account_search_page.click_edit_dev_in_dev_manage_page()
            # 点击保存
            self.global_account_search_page.click_ensuer_button()
            # 获取提示语
            text = self.global_account_search_page.get_no_authority_text()
            # self.assertIn(self.assert_text.no_authority_text(), text)

            # 关闭设备编辑页面
            self.global_account_search_page.close_dev_edit()
            # 退出登录的账号
            self.global_account_search_page.click_account_manage_page()
            self.global_account_search_page.logout()
            # 登录web_autotest
            self.log_in_base.log_in()
            self.log_in_base.click_account_center_button()
            self.global_dev_search_page.click_easy_search()
            # 关闭
            self.global_dev_search_page.close_search()
            sleep(2)
            self.global_dev_search_page.click_easy_search()
            # 选择用户搜索
            self.global_dev_search_page.click_dev_search()
            self.global_dev_search_page.click_search_buttons()
            # 点击详情
            self.global_dev_search_page.swith_to_search_frame()
            self.global_account_search_page.click_user_detail_button()
            # 点击用户信息
            self.global_account_search_page.click_user_info_in_user_detail()

            self.global_account_search_page.click_web_modify_dev_authority_in_user_detail(
            )
            # 点击保存
            self.global_account_search_page.click_ensuer_button_in_user_detail(
            )
            # 点击关闭
            self.driver.default_frame()
            self.global_account_search_page.click_close_button()

            # 退出登录
            self.global_account_search_page.logout()

            # 登录刚刚修改过的账号
            self.global_account_search_page.log_in_user(
                get_second_user_account, 'jimi123')
            # 进入设备管理页面
            self.global_account_search_page.click_dev_manage_page()
            # 点击编辑设备
            self.global_account_search_page.click_edit_dev_in_dev_manage_page()
            # 点击保存
            self.global_account_search_page.click_ensuer_button()
            # 获取提示语
            text = self.global_account_search_page.get_authority_text()
            self.assertIn(
                self.assert_text.account_center_page_operation_done(), text)

        elif web_modify_authority == False:
            # 点击web修改设备的权限
            self.global_account_search_page.click_web_modify_dev_authority_in_user_detail(
            )
            # 点击保存
            self.global_account_search_page.click_ensuer_button_in_user_detail(
            )
            # 点击关闭
            self.driver.default_frame()
            self.global_account_search_page.click_close_button()

            # 退出登录
            self.global_account_search_page.logout()

            # 登录刚刚修改过的账号
            self.global_account_search_page.log_in_user(
                get_second_user_account, 'jimi123')
            # 进入设备管理页面
            self.global_account_search_page.click_dev_manage_page()
            # 点击编辑设备
            self.global_account_search_page.click_edit_dev_in_dev_manage_page()
            # 点击保存
            self.global_account_search_page.click_ensuer_button()
            # 获取提示语
            text = self.global_account_search_page.get_authority_text()
            self.assertIn(
                self.assert_text.account_center_page_operation_done(), text)

            # 关闭设备编辑页面
            self.global_account_search_page.close_dev_edit()
            # 退出登录的账号
            self.global_account_search_page.click_account_manage_page()
            sleep(2)
            self.global_account_search_page.logout()
            # 登录web_autotest
            self.log_in_base.log_in()
            self.log_in_base.click_account_center_button()
            self.global_dev_search_page.click_easy_search()
            # 关闭
            self.global_dev_search_page.close_search()
            sleep(2)
            self.global_dev_search_page.click_easy_search()
            # 选择用户搜索
            self.global_dev_search_page.click_dev_search()
            self.global_dev_search_page.click_search_buttons()
            # 点击详情
            self.global_dev_search_page.swith_to_search_frame()
            self.global_account_search_page.click_user_detail_button()
            # 点击用户信息
            self.global_account_search_page.click_user_info_in_user_detail()

            self.global_account_search_page.click_web_modify_dev_authority_in_user_detail(
            )
            # 点击保存
            self.global_account_search_page.click_ensuer_button_in_user_detail(
            )
            # 点击关闭
            self.driver.default_frame()
            self.global_account_search_page.click_close_button()

            # 退出登录
            self.global_account_search_page.logout()

            # 登录刚刚修改过的账号
            self.global_account_search_page.log_in_user(
                get_second_user_account, 'jimi123')
            # 进入设备管理页面
            self.global_account_search_page.click_dev_manage_page()
            # 点击编辑设备
            self.global_account_search_page.click_edit_dev_in_dev_manage_page()
            # 点击保存
            self.global_account_search_page.click_ensuer_button()
            # 获取提示语
            text = self.global_account_search_page.get_no_authority_text()