def test_search_with_shanghu_after_change_geren_to_shanghu(self, testdata): home_page = HomePage() home_page.actions.sleep(1).spread().sleep(1).haoyouzhuli().sleep(2) hypage = HaoYouZhuLiPage() rowinfo = dict(activity_code='467dbea71ec9d3ef328fddbe5514d895', activity_status='进行中', activity_cycle='2020-08-20 00:00 至 2020-09-30 11:03', real_end_time='', help_sponsors='3', new_add_users='4') hypage.actions.sleep(3).detail(rowinfo).sleep(7) dpage = HaoYouZhuLiActivityDetailPage() info = { 'user_number': '16', 'alias': '大伟', 'phone': '17368839772', 'friends_total': '1', 'coupon_code_number': '23', 'discount': '88', 'first_share_time': '2020-08-25 10:42:39', } dpage.actions.user_number('16').phone_number('17368839772').search().check_friends_table(info).sleep(3) cat = { 'activity_code': '467dbea71ec9d3ef328fddbe5514d895', 'activity_status': '2', 'start_time': '2020-08-20 00:00', 'end_time': '2020-09-30 11:03', } dpage.actions.check_activity_table(cat) ort = { 'create_time': '2020-08-20 11:03:36', 'activity_code': '467dbea71ec9d3ef328fddbe5514d895', 'action': '添加活动', 'operator': 'admin', } dpage.actions.click_operation_record_table_row(ort).sleep(10) return flag = testdata.get("用户类型标签(查询)") fixed = "预期_" suffix_regex = r"\({}\d+\)$".format(fixed) home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() editrows = helper.group_by_suffix_regex(testdata, r"\(修改行\)$", True) editrow = { "user_id": editrows[0].get("用户ID"), } ul_page.actions.edit(editrow) editor = UserEditPage() editor.actions.sleep(2).select_usertype('个人').sleep(1).submit() ul_page.actions.sleep(3).edit(editrow) editor.actions.sleep(2).select_usertype('商户').sleep(1).submit() ul_page.actions.sleep(1).usertype(flag).sleep(1).search().sleep(3) e_userinfo_list = helper.group_by_suffix_regex(testdata, suffix_regex, True, helper.digital_suffix_cmp_wrapper(lambda suffix: suffix.lstrip("(").rstrip(")")[len(fixed):])) rowinfo_list = [] for e_userinfo in e_userinfo_list: rowinfo = {"user_id": e_userinfo.get("用户ID"), "phone": e_userinfo.get("手机号"), 'user_alias': e_userinfo.get("用户昵称")} rowinfo_list.append(rowinfo) ul_page.actions.check_userlist_table(rowinfo_list)
def test_search_ad_after_release_ns_video_ad_3(self, testdata): ad_name = testdata.get("广告片名称") ad_duration = testdata.get("视频时长") filepath = testdata.get("视频文件路径") auto_create_name = testdata.get("是否自动生成广告片名称(Y|N)", "N") fn_name = helper.get_caller_name() if auto_create_name.upper() == 'Y'.upper(): ad_name = settings.AD_NAME_PREFIX + SerialNumbersGenerator().serial_numbers ipage = IndexPage(settings.URLS['首页']) ipage.actions.click_tabbar().sleep(1).click_home_tab().sleep(1) ipage.actions.click_make_ad_btn().sleep(1).click_notice_dialog_close_btn().sleep(1).screenshot('{}_选项页面_'.format(fn_name)) ipage.actions.click_select_upload_video_btn().sleep(2).input_upload_video_path(filepath).sleep(3) # 需要等待回到剪切界面 clip_page = ClipPage() clip_page.actions.preview().sleep(2).screenshot('{}_预览界面_'.format(fn_name)).sleep(3) ppage = PreviewPage() ppage.actions.input_title(ad_name).release().sleep(3).screenshot('{}_发布界面_'.format(fn_name)).sleep(3).confirm().sleep(10) home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).adlist().sleep(2) al_page = ADListPage() rowinfo = { "ad_name": ad_name, "ad_duration": ad_duration, } al_page.actions.ad_name(ad_name).sleep(1).search().sleep(3).check_adlist_table(rowinfo)
def test_search_cinema_with_all_right_items(self, testdata): code = testdata.get("影院编码(查询)") name = testdata.get("影院名称(查询)") p = testdata.get("省份(查询)") c = testdata.get("城市(查询)") suffix_regex = r"\(\d+\)$" home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).cinema_manage().sleep(2) cm_page = CinemaManagePage() expected_rows = helper.group_by_suffix_regex( testdata, suffix_regex, True, helper.digital_suffix_cmp_wrapper( lambda suffix: suffix.lstrip("(").rstrip(")"))) all_rowinfo = [] for expected_row in expected_rows: all_rowinfo.append({ "code_number": expected_row.get("影院编码"), "cinema_name": expected_row.get("影院名称"), "status": expected_row.get("影院状态"), "belong": expected_row.get("所属地区"), }) cm_page.actions.sleep(3).cinema_name(name).cinema_code(code).province( p).sleep(3).city(c).sleep(1).search().sleep(3).check_cinema_table( *all_rowinfo, check_total=True).sleep(1)
def test_search_with_wrong_userid(self, testdata): userid = testdata.get("用户ID") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).adlist().sleep(2) al_page = ADListPage() al_page.actions.user_id(userid).sleep(1).search().sleep(3).is_empty_table()
def test_search_with_phone_number_which_has_special_characters(self, testdata): phone = testdata.get("手机号") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() ul_page.actions.phone_number(phone).sleep(1).search().sleep(3).is_empty_table()
def test_search_with_parttext_ad_number(self, testdata): ad_number = testdata.get("广告编号(查询)") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).adlist().sleep(2) al_page = ADListPage() al_page.actions.ad_number(ad_number).sleep(1).search().sleep(3).is_empty_table()
def test_search_ad_with_special_chart(self, testdata): ad_number = testdata.get("广告编号查询输入框") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).adlist().sleep(2) al_page = ADListPage() al_page.actions.ad_number(ad_number).sleep(1).search().sleep(3).is_empty_table()
def test_search_with_wrong_ad_name(self, testdata): s_name = testdata.get("广告名称(查询)") home_page = HomePage() home_page.actions.sleep(2).page.switch_current_window() home_page.actions.sleep(1).data().sleep(1).adlist().sleep(2) al_page = ADListPage() al_page.actions.ad_name(s_name).sleep(1).search().sleep(3).is_empty_table()
def test_search_cinema_with_city_which_no_cinemas(self, testdata): p = testdata.get("省份(查询)") c = testdata.get("城市(查询)") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).cinema_manage().sleep(2) cm_page = CinemaManagePage() cm_page.actions.sleep(3).province(p).sleep(3).city(c).sleep( 1).search().sleep(3).is_empty_cinema_table()
def test_search_with_special_characters(self, testdata): alias = testdata.get("用户昵称") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() ul_page.actions.user_alias(alias).sleep(1).search().sleep(3).is_empty_table()
def test_search_with_wrong_userid_and_alias(self, testdata): userid = testdata.get("用户ID") alias = testdata.get("用户昵称") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() ul_page.actions.user_id(userid).sleep(1).user_alias(alias).search().sleep(3).is_empty_table()
def test_search_cinema_with_wrong_cienma_number(self, testdata): scode_number = testdata.get("影院编码(查询)") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).cinema_manage().sleep(2) cm_page = CinemaManagePage() cm_page.actions.sleep(3).cinema_code(scode_number).sleep( 1).search().sleep(3).is_empty_cinema_table().sleep(1)
def test_search_cinema_with_wrong_cienma_name(self, testdata): cinema_name = testdata.get("影院名称(查询)") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).cinema_manage().sleep(2) cm_page = CinemaManagePage() cm_page.actions.sleep(3).cinema_name(cinema_name).sleep( 1).search().sleep(3).is_empty_cinema_table().sleep(1)
def test_search_with_wrong_or_notexists_userid(self, testdata): userid = testdata.get("用户ID") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() ul_page.actions.user_id(userid).sleep(1).search().sleep(3) if not ul_page.actions.is_empty_table(): tips = '使用错误的不存在的用户ID({userid})能查询出数据' self.fail(tips.format(userid=userid))
def test_search_with_right_phone_number(self, testdata): userid = testdata.get("用户ID") phone = testdata.get("手机号") alias = testdata.get("用户昵称") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() rowinfo = {"user_id": userid, "phone": phone, 'user_alias': alias} ul_page.actions.phone_number(phone).sleep(1).search().sleep(3).check_userlist_table(rowinfo)
def test_search_with_wrong_or_notexists_alias(self, testdata): alias = testdata.get("用户昵称") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() ul_page.actions.user_alias(alias).sleep(1).search().sleep(3) if not ul_page.actions.is_empty_table(): tips = '使用错误的不存在的用户昵称({alias})能查询出数据' self.fail(tips.format(alias=alias))
def test_input_is_clear_when_click_reset_after_input_content(self, testdata): userid = testdata.get("用户ID") alias = testdata.get("用户昵称") empty = '' home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() ul_page.actions.user_id(userid).sleep(1).user_alias(alias).sleep(1).reset().sleep(3) if ul_page.elements.user_id.text != empty or ul_page.elements.user_alias.text != empty: tips = '重置失败' self.fail(tips)
def test_search_cinema_with_matched_area_and_other_is_wrong( self, testdata): code = testdata.get("影院编码(查询)") name = testdata.get("影院名称(查询)") p = testdata.get("省份(查询)") c = testdata.get("城市(查询)") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).cinema_manage().sleep(2) cm_page = CinemaManagePage() cm_page.actions.sleep(3).cinema_name(name).cinema_code(code).province( p).sleep(3).city(c).sleep(1).search().sleep( 3).is_empty_cinema_table()
def test_search_with_right_userid(self, testdata): userid = testdata.get("用户ID") phone = testdata.get("手机号") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() rowinfo = { "user_id": userid, "phone": phone, } ul_page.actions.user_id(userid).sleep(1).search().sleep(3).check_userlist_table(rowinfo, check_total=True)
def test_search_cinema_with_right_cienma_number(self, testdata): code_number = testdata.get("影院编码(查询)") cinema_name = testdata.get("影院名称") status = testdata.get("影院状态") home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).cinema_manage().sleep(2) cm_page = CinemaManagePage() rowinfo = { "code_number": code_number, "cinema_name": cinema_name, "status": status, } cm_page.actions.sleep(3).cinema_code(code_number).sleep( 1).search().sleep(3).check_cinema_table(rowinfo, check_total=True).sleep(1)
def test_search_with_parttext_phone_number(self, testdata): phone = testdata.get("手机号(查询)") fixed = "预期_" suffix_regex = r"\({}\d+\)$".format(fixed) home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() ul_page.actions.phone_number(phone).sleep(1).search().sleep(3) e_userinfo_list = helper.group_by_suffix_regex(testdata, suffix_regex, True, helper.digital_suffix_cmp_wrapper(lambda suffix: suffix.lstrip("(").rstrip(")")[len(fixed):])) rowinfo_list = [] for e_userinfo in e_userinfo_list: rowinfo = {"user_id": e_userinfo.get("用户ID"), "phone": e_userinfo.get("手机号"), 'user_alias': e_userinfo.get("用户昵称")} rowinfo_list.append(rowinfo) ul_page.actions.check_userlist_table(rowinfo_list, check_total=True)
def test_search_with_right_ad_number(self, testdata): ad_number = testdata.get("广告编号") ad_name = testdata.get("广告名称") userid = testdata.get("用户ID") save_status = testdata.get("存储状态") home_page = HomePage() home_page.actions.sleep(20).page.switch_current_window() home_page.actions.sleep(1).data().sleep(1).adlist().sleep(2) al_page = ADListPage() rowinfo = { "ad_number": ad_number, "ad_name": ad_name, "user_id": userid, "save_status": save_status, } al_page.actions.ad_number(ad_number).sleep(1).search().sleep(3).check_adlist_table(rowinfo)
def test_search_with_right_ad_name(self, testdata): s_name = testdata.get("广告名称(查询)") suffix_regex = r"\(\d+\)$" home_page = HomePage() home_page.actions.sleep(2).page.switch_current_window() home_page.actions.sleep(1).data().sleep(1).adlist().sleep(2) expected_ads = helper.group_by_suffix_regex(testdata, suffix_regex, True, helper.digital_suffix_cmp_wrapper(lambda suffix: suffix.lstrip("(").rstrip(")"))) al_page = ADListPage() all_rowinfo = [] for expected_ad in expected_ads: all_rowinfo.append({ "ad_number": expected_ad.get("广告编号"), "ad_name": expected_ad.get("广告名称"), "user_id": expected_ad.get("用户ID"), "save_status": expected_ad.get("存储状态"), }) al_page.actions.ad_name(s_name).sleep(1).search().sleep(3).check_adlist_table(*all_rowinfo, check_total=True)
def test_search_with_geren_after_change_shanghu_to_geren(self, testdata): flag = testdata.get("用户类型标签(查询)") fixed = "预期_" suffix_regex = r"\({}\d+\)$".format(fixed) home_page = HomePage() home_page.actions.sleep(1).data().sleep(1).userlist().sleep(2) ul_page = UserListPage() editrows = helper.group_by_suffix_regex(testdata, r"\(修改行\)$", True) editrow = { "user_id": editrows[0].get("用户ID"), } ul_page.actions.edit(editrow) editor = UserEditPage() editor.actions.sleep(2).personal().submit() ul_page.actions.sleep(1).usertype(flag).sleep(1).search().sleep(3) e_userinfo_list = helper.group_by_suffix_regex(testdata, suffix_regex, True, helper.digital_suffix_cmp_wrapper(lambda suffix: suffix.lstrip("(").rstrip(")")[len(fixed):])) rowinfo_list = [] for e_userinfo in e_userinfo_list: rowinfo = {"user_id": e_userinfo.get("用户ID"), "phone": e_userinfo.get("手机号"), 'user_alias': e_userinfo.get("用户昵称")} rowinfo_list.append(rowinfo) ul_page.actions.check_userlist_table(rowinfo_list)