예제 #1
0
class TestCase108GlobSearchUserDetail(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_global_search_user_detail(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_account_search()
        # self.global_dev_search_page.click_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.click_user_info_in_user_detail()
        # 获取用户信息中用户名称,用户类型、用户账号、上级用户
        user_name_in_detail = self.global_dev_search_page.get_user_name_in_detail(
        )
        self.assertIn(user_name, user_name_in_detail)

        # user_type_in_detail = self.global_dev_search_page.get_user_type_in_detail()
        # self.assertEqual(user_type, user_type_in_detail)

        uesr_account_in_detail = self.global_dev_search_page.get_user_account_in_detail(
        )
        self.assertEqual(user_account, uesr_account_in_detail)
        user_account_input_value = self.global_dev_search_page.get_user_account_input_value_in_detail(
        )
        self.assertEqual('true', user_account_input_value)

        get_up_user_name = self.global_dev_search_page.get_up_user_name_in_detail(
        )
        get_up_user_input_value = self.global_dev_search_page.get_up_user_input_value_in_detail(
        )
        self.assertEqual('true', get_up_user_input_value)

        # 查询选中用户的上级
        connect = self.connect_sql.connect_tuqiang_sql()
        cursor = connect.cursor()
        get_up_account_sql = "select parentId from user_info where account = '%s';" % user_account
        cursor.execute(get_up_account_sql)
        get_up_account = cursor.fetchall()
        up_account_id = get_up_account[0][0]
        get_up_name_sql = "select nickName from user_info where userId = '%s';" % up_account_id
        cursor.execute(get_up_name_sql)
        get_up_name = cursor.fetchall()
        up_account = get_up_name[0][0]
        cursor.close()
        connect.close()
        self.assertEqual(get_up_user_name, up_account)

        # 验证右侧的客户数是否可以搜索
        # 搜索没有的数据
        text = self.global_dev_search_page.search_user_in_user_info('无数据')
        self.assertIn(self.assert_text.account_center_page_no_data_text(),
                      text)

        # 循环点击五次
        for n in range(5):
            self.global_dev_search_page.swith_to_search_frame()
            self.driver.click_element(
                'x,//*[@id="complex_userInfo_tree_complexUpdate_%s_a"]' %
                str(n + 15))
            get_up_user_name = self.global_dev_search_page.get_up_user_name_in_details(
            )
            select_up_name = self.driver.get_text(
                'x,//*[@id="complex_userInfo_tree_complexUpdate_%s_span"]' %
                str(n + 15))
            # self.assertEqual(get_up_user_name, select_up_name)
            sleep(2)
            self.driver.default_frame()

        # 点击销售设备
        self.global_dev_search_page.click_sale_dev_in_user_info()
        # 获取销售的对象
        sale_user_name = self.global_dev_search_page.get_sale_user_name()
        self.assertEqual(user_name, sale_user_name)

        # 点击新增客户
        self.global_dev_search_page.click_add_user_in_user_info()
        # 获取新增客户默认的上级
        up_user_in_add_user = self.global_dev_search_page.get_up_user_in_add_user(
        )
        self.assertIn(user_name, up_user_in_add_user)

        # 验证账号
        # 为空
        self.global_dev_search_page.check_add_user_account_input_in_user_info(
            '')
        self.global_dev_search_page.click_save_add_user()
        text = self.global_dev_search_page.get_text_account_input_expertion()
        self.assertEqual(self.assert_text.cust_page_user_account_not_null(),
                         text)

        # 小于3位
        self.global_dev_search_page.check_add_user_account_input_in_user_info(
            '12')
        self.global_dev_search_page.click_save_add_user()
        text = self.global_dev_search_page.get_text_account_input_expertion()
        self.assertEqual(self.assert_text.cust_page_user_account_len(), text)

        # 验证最大长度
        get_user_account_input_max_len = self.global_dev_search_page.get_user_account_input_max_len(
        )
        self.assertEqual('30', get_user_account_input_max_len)

        # 验证客户名称
        # 为空
        self.global_dev_search_page.check_add_user_name_input_in_user_info('')
        self.global_dev_search_page.click_save_add_user()
        text = self.global_dev_search_page.get_text_name_input_expertion()
        self.assertEqual(self.assert_text.cust_page_user_name_not_null(), text)

        # 小于3位
        self.global_dev_search_page.check_add_user_name_input_in_user_info(
            '12')
        self.global_dev_search_page.click_save_add_user()
        text = self.global_dev_search_page.get_text_name_input_expertion()
        self.assertEqual(self.assert_text.cust_page_user_name_more_than_3s(),
                         text)

        # 密码
        # 为空
        self.global_dev_search_page.click_add_user_password_first_input_in_user_info(
            '')
        self.global_dev_search_page.click_save_add_user()
        get_first_password_text = self.global_dev_search_page.get_first_password_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_password_not_nulls(),
                         get_first_password_text)

        # 小于6位
        self.global_dev_search_page.click_add_user_password_first_input_in_user_info(
            '12qw')
        self.global_dev_search_page.click_add_user_password_second_input_in_user_info(
            '12qw')
        self.global_dev_search_page.click_save_add_user()
        get_first_password_text = self.global_dev_search_page.get_first_password_text(
        )
        self.assertEqual(self.assert_text.cust_page_user_password_len(),
                         get_first_password_text)

        # 全数字
        self.global_dev_search_page.click_add_user_password_first_input_in_user_info(
            '121212')
        self.global_dev_search_page.click_add_user_password_second_input_in_user_info(
            '121212')
        self.global_dev_search_page.click_save_add_user()
        get_first_password_text = self.global_dev_search_page.get_first_password_text(
        )
        self.assertEqual(
            self.assert_text.account_center_page_password_formart_text(),
            get_first_password_text)

        # 全字母
        self.global_dev_search_page.click_add_user_password_first_input_in_user_info(
            'qwerqw')
        self.global_dev_search_page.click_add_user_password_second_input_in_user_info(
            'qwerqw')
        self.global_dev_search_page.click_save_add_user()
        get_first_password_text = self.global_dev_search_page.get_first_password_text(
        )
        self.assertEqual(
            self.assert_text.account_center_page_password_formart_text(),
            get_first_password_text)
        # 两次密码不一致
        self.global_dev_search_page.click_add_user_password_first_input_in_user_info(
            'qwerqw123')
        self.global_dev_search_page.click_add_user_password_second_input_in_user_info(
            'qwerqw2324')
        self.global_dev_search_page.click_save_add_user()
        get_second_password_text = self.global_dev_search_page.get_second_password_text(
        )
        self.assertEqual(self.assert_text.cust_page_password_unlike(),
                         get_second_password_text)
class TestCase1101CustManageCustExpection(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_add_cust_exception(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()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        comp_max_len = self.cust_manage_basic_info_and_add_cust_page.get_comp_max_len(
        )
        self.assertEqual('50', comp_max_len)