def test_discover_skip_operation(self): """ test_cases/test_topic_operations.py:TopicTestCase.test_discover_skip_operation Summary: 跳转操作-热门话题箭头跳转/切换图片分类/点击图片跳转/广告跳转/故事集跳转 """ base_app = base_frame_view.BaseFrameView(self.get_driver()) action = mobile_keyevent_action.KeyEventAction(self.get_driver()) try: curr_discover_activity = discover_tab_activity.DiscoverTabActivity( base_app) log.logger.info("点击热门话题箭头跳转") status = curr_discover_activity.tap_hot_topic_icon() self.assertTrue(status, "进入话题广场页面失败", "进入话题广场") action.back(activities.ActivityNames.IN_MAIN) log.logger.info("向上滑动使图片栏固定在顶部") curr_discover_activity.swipe_up_entire_scroll_view() #curr_discover_activity.swipe_up_any_view(ratio=0.1) log.logger.info("切换图片分类") log.logger.info("点击最新tab") curr_discover_activity.newest_header_tab.tap() status = curr_discover_activity.is_square_item_exisit() self.assertTrue(status, "切换图片分类失败", "切换图片分类-最新") log.logger.info("点击最热tab") curr_discover_activity.hotest_header_tab.tap() status = curr_discover_activity.is_square_item_exisit() self.assertTrue(status, "切换图片分类失败", "切换图片分类-最热") status = curr_discover_activity.first_photo_item.tap() self.assertTrue(status, "进入图片详情页面失败", "发现页点击九宫格图片") action.back(activities.ActivityNames.IN_MAIN) if curr_discover_activity.first_live_item: # 存在直播,则进入直播页 status = curr_discover_activity.first_live_item.tap() self.assertTrue(status, "进入直播页面失败") action.back(activities.ActivityNames.IN_MAIN) if curr_discover_activity.first_story_item: # 存在故事集,则进入故事集页 status = curr_discover_activity.first_story_item.tap() self.assertTrue(status, "进入故事集详情页面失败", "发现页点击九宫格故事集") action.back(activities.ActivityNames.IN_MAIN) if curr_discover_activity.ad_item: status = curr_discover_activity.tap_ad() self.assertTrue(status, "进入广告页面失败", "发现页点击九宫格广告") action.back(activities.ActivityNames.IN_MAIN) except Exception as exp: log.logger.error("发现异常, case:test_send_topic_topic_operation执行失败") self.raise_exp_and_save_screen_shot(base_app, 'send_topic', exp)
def test_take_and_pick_photo_operation(self): """ test_cases/test_photo_operations.py:PhotoTestCase.test_take_and_pick_photo_operation Summary: 拍照同时选中已有的图片-进入编辑加工页 """ base_app = base_frame_view.BaseFrameView(self.get_driver()) action = mobile_keyevent_action.KeyEventAction(self.get_driver()) try: action.back(activities.ActivityNames.CAMERA2) curr_camera2_activity = camera2_activity.Camera2Activity(base_app) log.logger.info("点击拍照") curr_camera2_activity.tap_camera() log.logger.info("点击拍照完成按钮") curr_camera2_activity.tap_finish_camera() curr_publish_core_activity = publish_core_activity.PublishCoreActivity(base_app) self.assertTrue(curr_publish_core_activity.photo_available_list[0].is_selected, "拍照的照片在加工页未选中", "拍照-刚拍的照片选中检测") status = curr_publish_core_activity.tap_add_photo_button() self.assertTrue(status, "添加图片,进入图片选择页失败") curr_gallery_activity = story_gallery_activity.StoryGalleryActivity(base_app) photo_count = curr_gallery_activity.image_photo_enable_picked_count curr_photo_list = curr_gallery_activity.image_photo_list log.logger.info("随机选1张图片") # 选随机选择几张图片,为了排除底部遮罩tab的干扰,图片最多选择11张 max_pick_count = photo_count if photo_count < 11 else 11 index = random.randint(2, max_pick_count) # 该页面第一个格子为拍照按钮 log.logger.info("选择相册中的第{}张照片".format(index)) curr_photo_list[index-1].select() log.logger.info("验证该图片有没有被选中") self.assertEqual('2', curr_photo_list[index-1].check_value, "该图片没有被选中", "拍照-选中已有照片检测") log.logger.info("该图片已被选中") log.logger.info("验证已选中的图片的数目") self.assertEqual('2', curr_gallery_activity.selected_photo_count, "选择的图片数量不一致", "拍照-验证已选择照片数目") status = curr_gallery_activity.tap_photo_next_step_button() self.assertTrue(status, "进入照片加工页失败") except Exception as exp: log.logger.error("发现异常, case:test_take_and_pick_photo_operation执行失败") self.raise_exp_and_save_screen_shot(base_app, 'take_and_pick_photo', exp)
def test_search_operation(self): """ test_cases/test_topic_operations.py:TopicTestCase.test_search_operation Summary: 搜索操作-搜索用户/话题-点击进入用户/话题页面 """ base_app = base_frame_view.BaseFrameView(self.get_driver()) action = mobile_keyevent_action.KeyEventAction(self.get_driver()) try: curr_discover_activity = discover_tab_activity.DiscoverTabActivity( base_app) log.logger.info("点击搜索框") curr_discover_activity.tap_search_box() log.logger.info("进入搜索页面") curr_search_page = discover_tab_activity.SearchPage(base_app) search_value = 'infashiontest' action.send_string(search_value) log.logger.info("验证搜索结果列表出现") self.assertTrue(curr_search_page.is_search_result_exist(), "没有搜索结果", "发现页搜索用户") status = curr_search_page.user_list[0].tap() self.assertTrue(status, "进入用户in记页失败") action.back(activities.ActivityNames.IN_MAIN) log.logger.info("清空搜索框遗留内容") curr_search_page.top_search_bar.search_box.clear_text_field() action.send_proud_key() self.assertTrue(curr_search_page.is_search_result_exist(), "没有搜索结果", "发现页搜索话题") status = curr_search_page.tag_list[0].tap() self.assertTrue(status, "进入话题页失败") action.back(activities.ActivityNames.IN_MAIN) # curr_search_page.top_search_bar.input_search_value(search_value) except Exception as exp: log.logger.error("发现异常, case:test_send_topic_topic_operation执行失败") self.raise_exp_and_save_screen_shot(base_app, 'send_topic', exp)
def test_take_photo_operation(self): """ test_cases/test_photo_operations.py:PhotoTestCase.test_take_photo_operation Summary: 拍照-选中拍照的图片-进入加工-返回-临时保存 """ base_app = base_frame_view.BaseFrameView(self.get_driver()) action = mobile_keyevent_action.KeyEventAction(self.get_driver()) try: action.back(activities.ActivityNames.CAMERA2) curr_camera2_activity = camera2_activity.Camera2Activity(base_app) log.logger.info("点击拍照") status = curr_camera2_activity.tap_camera() self.assertTrue(status, "拍照失败", "点击拍照") log.logger.info("点击拍照完成按钮") status = curr_camera2_activity.tap_finish_camera() self.assertTrue(status, "拍照完成失败", "加工拍照图片") # 2.9.9之前版本的步骤 # curr_gallery_activity = story_gallery_activity.StoryGalleryActivity(base_app) # # log.logger.info("切换一次底部tab,避免\"发布故事集\"的引导遮罩对选取图片的干扰") # curr_gallery_activity.tap_story_tab() # curr_gallery_activity.tap_photo_tab() # # status = curr_gallery_activity.open_camera() # self.assertTrue(status, "进入故事照片编辑页失败", "进入拍照页") # # log.logger.info('点击拍照') # curr_story_camera_activity = story_camera_activity.StoryCameraActivity(base_app) # curr_story_camera_activity.tap_camera() # log.logger.info('选中刚拍照的图片') # curr_story_camera_activity.photo_list[0].select() # self.assertTrue(curr_story_camera_activity.photo_list[0].is_selected, '刚拍的照片没选中', "拍照并选中刚拍的照片") # # curr_story_camera_activity.tap_next_step_button() curr_publish_core_activity = publish_core_activity.PublishCoreActivity(base_app) log.logger.info("验证返回按钮,返回拍照编辑页") curr_publish_core_activity.tap_back_button(save=False, cancel=False) except Exception as exp: log.logger.error("发现异常, case:test_take_photo_operation执行失败") self.raise_exp_and_save_screen_shot(base_app, 'take_photo', exp)
def test_topic_square_operation(self): """ test_cases/test_topic_operations.py:TopicTestCase.test_topic_square_operation Summary: 话题广场操作 我的话题-点击话题 分类话题-切换分类-点击话题 推荐话题-分页加载-点击话题 """ base_app = base_frame_view.BaseFrameView(self.get_driver()) action = mobile_keyevent_action.KeyEventAction(self.get_driver()) try: curr_discover_activity = discover_tab_activity.DiscoverTabActivity(base_app) curr_discover_activity.tap_hot_topic_icon() curr_topic_square_activity = topic_sqaure_activity.TopicSquareActivity(base_app) log.logger.info("点击我的tab") curr_topic_square_activity.tap_my_tab() my_topic_count = len(curr_topic_square_activity.my_topic_list) log.logger.info("我的话题数为{}个".format(my_topic_count)) index = random.randint(0, my_topic_count-1) log.logger.info("点击第{}个话题".format(index+1)) status = curr_topic_square_activity.my_topic_list[index].tap() self.assertTrue(status, "进入话题详情页失败", "热门话题-我的话题-进入话题详情页") action.back(activities.ActivityNames.TOPIC_SQUARE) log.logger.info("点击分类tab") curr_topic_square_activity.tap_category_tab() cate_count = len(curr_topic_square_activity.category_list) log.logger.info("话题类别数为{}个".format(cate_count)) self.assertTrue(status, "切换话题tab", "热门话题-点击分类tab") index = random.randint(0, cate_count-1) log.logger.info("点击第{}个话题类别".format(index + 1)) curr_topic_square_activity.category_list[index].tap(5) curr_topic = curr_topic_square_activity.topic_list[0] old_topic_name = curr_topic.topic_name log.logger.info("当前类别下第一个话题为\"{}\"".format(old_topic_name)) log.logger.info("切换话题分类, 获取新的类别") index = self._get_different_value(0, cate_count-1, index) log.logger.info("切换话题类别,点击第{}个话题类别".format(index + 1)) curr_topic_square_activity.category_list[index].tap(5) curr_topic = curr_topic_square_activity.topic_list[0] new_topic_name = curr_topic.topic_name log.logger.info("当前类别下第一个话题为\"{}\"".format(new_topic_name)) self.assertNotEqual(old_topic_name, new_topic_name, "话题类别未切换", "热门话题-分类话题-切换话题分类") topic_count = len(curr_topic_square_activity.topic_list) log.logger.info("\"{}\"话题数为{}个".format(new_topic_name, topic_count)) index = random.randint(0, topic_count - 1) log.logger.info("点击第{}个话题".format(index+1)) status = curr_topic_square_activity.topic_list[index].tap() self.assertTrue(status, "进入话题页失败", "热门话题-分类话题-点击话题") action.back(activities.ActivityNames.TOPIC_SQUARE) log.logger.info("点击推荐tab") curr_topic_square_activity.tap_recommend_tab() curr_topic_square_activity.swipe_up_entire_scroll_view() self.assertTrue(True, "点击推荐tab", "热门话题-推荐话题-分页加载") except Exception as exp: log.logger.error("发现异常, case:test_topic_square_operation执行失败") self.raise_exp_and_save_screen_shot(base_app, 'topic_square', exp)
def test_focus_user_card_operation(self): """ test_cases/test_friends_operations.py:FocusTestCase.test_focus_user_card_operation Summary: 关注页用户卡片操作:点击头像-点击图片-点赞-取消点赞-评论 """ base_app = base_frame_view.BaseFrameView(self.get_driver()) action = mobile_keyevent_action.KeyEventAction(self.get_driver()) try: curr_focus_activity = focus_tab_activity.FocusTabActivity(base_app) if curr_focus_activity.is_contact_friends_exisit(): log.logger.info("关闭通讯录好友提示") curr_focus_activity.tap_close_contact_button() curr_card_list = curr_focus_activity.card_list log.logger.info("对屏幕中第一个用户动态卡片进行处理") curr_card = curr_card_list[0] log.logger.info("点击头像") status = curr_card.tap_avatar() self.assertTrue(status, "进入用户in记页失败") action.back(activities.ActivityNames.IN_MAIN, 3) status = curr_card.tap_photo() self.assertTrue(status, "进入查看图片详情页失败", "关注页用户卡片点击照片") action.back(activities.ActivityNames.IN_MAIN, 3) curr_focus_activity.swipe_up_any_view(ratio=0.5) # 屏幕滑动,重新获取一次当前卡片 curr_card = curr_card_list[0] log.logger.info("点赞") status = curr_card.tap_zan() self.assertTrue(status, '点赞失败', "关注页用户卡片点赞") log.logger.info("取消点赞") status = curr_card.remove_zan() self.assertTrue(status, '点赞按钮没取消', "关注页用户卡片取消点赞") log.logger.info("评论照片") log.logger.info('点击评论按钮') curr_card.tap_comment() expected_words = u'评论' + unicode( str(random.random() * 10000)[:4], 'utf8') curr_focus_activity.send_words_box.input_words(expected_words) curr_focus_activity.send_words_box.tap_send_button() # 获取刚发送的文本,为评论列表的最后一行 log.logger.info("检查评论内容") actual_words = curr_card.comment_list[-1].text self.assertEqual(expected_words.encode('utf-8'), actual_words, "评论内容有误", "关注页用户卡片评论-评论内容") log.logger.info("评论内容检查完毕") log.logger.info("检查评论人") expected_user = self.config_model.get( 'account', 'user_name' + self.get_current_thread_number()) actual_user = curr_card.comment_user_list[-1].text self.assertEqual(expected_user, actual_user, "评论人有误", "关注页用户卡片评论-评论人") log.logger.info("评论人检查完毕") except Exception as exp: log.logger.error("发现异常, case:test_focus_user_card_operation执行失败") self.raise_exp_and_save_screen_shot(base_app, 'focus_user_card', exp)
def test_focus_friend_photo_operation(self): """ test_cases/test_friends_operations.py:FocusTestCase.test_focus_friend_photo_operation Summary: 发现-进入好友图片详情页-图片详情页操作-点击图片/头像/点赞/评论 """ base_app = base_frame_view.BaseFrameView(self.get_driver()) action = mobile_keyevent_action.KeyEventAction(self.get_driver()) try: curr_focus_activity = focus_tab_activity.FocusTabActivity(base_app) if curr_focus_activity.is_contact_friends_exisit(): log.logger.info("关闭通讯录好友提示") curr_focus_activity.tap_close_contact_button() curr_card_list = curr_focus_activity.card_list log.logger.info("点击首张卡片头部栏跳转") status = curr_card_list[0].tap_header_bar() self.assertTrue(status, "进入好友图片页失败", "关注页人物卡片点击头部栏") curr_photo_activity = friend_photo_album_detail_activity.FriendPhotoDetailActivity( base_app) log.logger.info("点击图片") status = curr_photo_activity.tap_photo(0) self.assertTrue(status, "进入图片详情页失败", "关注-图片详情页点击图片") action.back(activities.ActivityNames.FRIEND_PHOTO_DETAIL) status = curr_photo_activity.tap_tag(0) self.assertTrue(status, "进入标签话题页失败", "关注-图片详情页点击标签") action.back(activities.ActivityNames.FRIEND_PHOTO_DETAIL) curr_photo_activity.swipe_up_any_view(0.4) status = curr_photo_activity.tap_zan() self.assertTrue(status, "点赞失败", "关注-图片详情页点赞") status = curr_photo_activity.remove_zan() self.assertTrue(status, "取消点赞失败", "关注-图片详情页取消点赞") status = curr_photo_activity.tap_avatar() self.assertTrue(status, "进入个人详情页失败", "关注-图片详情页点击头像") action.back(activities.ActivityNames.FRIEND_PHOTO_DETAIL) log.logger.info('发表评论') expected_words = u'评论' + unicode( str(random.random() * 10000)[:4], 'utf8') curr_photo_activity.input_comment(expected_words) curr_photo_activity.tap_send_button() log.logger.info("检查评论内容") curr_photo_activity.swipe_up_entire_scroll_view() actual_words = curr_photo_activity.latest_comment_value self.assertEqual(expected_words.encode('utf-8'), actual_words, "评论内容有误", "关注-图片详情页评论内容") log.logger.info("评论内容检查完毕") log.logger.info("检查评论人") expected_user = self.config_model.get( 'account', 'user_name' + self.get_current_thread_number()) actual_user = curr_photo_activity.latest_comment_user self.assertEqual(expected_user, actual_user, "评论人有误", "关注-图片详情页评论人") log.logger.info("评论人检查完毕") except Exception as exp: log.logger.error( "发现异常, case:test_focus_friend_photo_operation执行失败") self.raise_exp_and_save_screen_shot(base_app, 'friend_photo', exp)
def test_friend_in_diary_operation(self): """ test_cases/test_topic_operations.py:TopicTestCase.test_friend_in_diary_operation Summary: 发现首页-》点击九宫格箭头-》分类-》达人分类操作->进入达人in记主页操作 """ base_app = base_frame_view.BaseFrameView(self.get_driver()) action = mobile_keyevent_action.KeyEventAction(self.get_driver()) try: curr_discover_activity = discover_tab_activity.DiscoverTabActivity( base_app) curr_discover_activity.swipe_up_entire_scroll_view() log.logger.info("点击九宫格箭头跳转") status = curr_discover_activity.tap_head_bar_more() self.assertTrue(status, "进入全部分类页面失败") curr_cate_activity = all_category_activity.AllCategoryActivity( base_app) status = curr_cate_activity.tap_talent() self.assertTrue(status, "进入达人推荐页面失败") curr_talent_activity = talent_recommend_activity.TalentRecommendActivity( base_app) log.logger.info("点击推荐达人的头像") status = curr_talent_activity.talent_list[0].tap_avatar() self.assertTrue(status, "进入达人主页失败", "点击推荐达人头像") curr_personal_activity = personal_main_activity.PersonalMainActivity( base_app) log.logger.info("点击关注") status = curr_personal_activity.tap_follow_button() self.assertTrue(status, "关注对话框吊起失败", "在他人in记页点击关注达人") curr_follow_dialogue = curr_personal_activity.follow_dialogue curr_follow_dialogue.select_group('interest') # 选择订阅分类 curr_follow_dialogue.tap_ok_button() if curr_personal_activity.is_friends_recommend_exist(): # 如果出现好友推荐,则点击收起按钮 curr_personal_activity.tap_friends_pull_button() log.logger.info("进入更多页面") status = curr_personal_activity.tap_more_button() self.assertTrue(status, "进入更改页面失败", "进入他人in记资料更改页") curr_remark_activity = personal_remark_activity.PersonalRemarkActivity( base_app) log.logger.info("更换分组") status = curr_remark_activity.select_group('friends') self.assertTrue(status, "更换分组失败", "更换好友分组") log.logger.info("更换昵称") nick_name = 'nickname' curr_remark_activity.input_remark_name(nick_name) log.logger.info("点击头像") status = curr_remark_activity.tap_avatar() self.assertTrue(status, "点击头像失败", "资料更改页点击好友头像") action.back(activities.ActivityNames.REMARK) log.logger.info("点击完成") curr_remark_activity.tap_ok_button() log.logger.info("验证新更改的昵称") curr_username = curr_personal_activity.user_nickname self.assertEqual( curr_username, nick_name, "昵称更改失败,原昵称\"{}\",新昵称\"{}\"".format(curr_username, nick_name), "更改备注名") log.logger.info("验证完毕") log.logger.info("点击照片") status = curr_personal_activity.matrix_photo_album_list[0].tap() self.assertTrue(status, "进入图片详情页失败", "他人in记页点击照片") action.back(activities.ActivityNames.DIARY_INFO) log.logger.info("取消关注") curr_personal_activity.tap_unfollow_button() curr_personal_activity.tap_confirm_unfollow_button() self.assertEqual('+ 关注', curr_personal_activity.follow_button.text, "取消关注未成功", "他人in记页取消关注") except Exception as exp: log.logger.error("发现异常, case:test_friend_in_diary_operation执行失败") self.raise_exp_and_save_screen_shot(base_app, 'friend_in_diary', exp)
def test_talent_operation(self): """ test_cases/test_topic_operations.py:TopicTestCase.test_talent_operation Summary: 发现首页-》点击九宫格箭头-》分类-》达人分类操作/点击头像/图片/关注 """ base_app = base_frame_view.BaseFrameView(self.get_driver()) action = mobile_keyevent_action.KeyEventAction(self.get_driver()) try: curr_discover_activity = discover_tab_activity.DiscoverTabActivity( base_app) curr_discover_activity.swipe_up_entire_scroll_view() log.logger.info("点击九宫格箭头跳转") status = curr_discover_activity.tap_head_bar_more() self.assertTrue(status, "进入全部分类页面失败", "进入分类页") curr_cate_activity = all_category_activity.AllCategoryActivity( base_app) status = curr_cate_activity.tap_talent() self.assertTrue(status, "进入达人推荐页面失败", "进入推荐达人页") curr_talent_activity = talent_recommend_activity.TalentRecommendActivity( base_app) log.logger.info("点击切换达人分类") curr_talent_activity.category_list[1].tap() status = curr_talent_activity.wait_for_talent(6) self.assertTrue(status, "达人加载失败", "切换达人分类-第二类目") curr_talent_activity.category_list[3].tap() status = curr_talent_activity.wait_for_talent(6) self.assertTrue(status, "达人加载失败", "切换达人分类-第四类目") log.logger.info("点击达人图片") status = curr_talent_activity.talent_list[0].tap_image(0) self.assertTrue(status, "进入图片详情页失败", "点击达人图片") action.back(activities.ActivityNames.TALENT_RECOMMEND) log.logger.info("开始关注达人") status = curr_talent_activity.talent_list[1].tap_follow_button() self.assertTrue(status, "关注按钮没选中", "关注达人") log.logger.info("进入达人主页取消关注") log.logger.info("点击推荐达人的头像") status = curr_talent_activity.talent_list[1].tap_avatar() self.assertTrue(status, "进入达人主页失败", "点击达人头像") curr_personal_activity = personal_main_activity.PersonalMainActivity( base_app) curr_personal_activity.tap_unfollow_button() curr_personal_activity.tap_confirm_unfollow_button() self.assertEqual('+ 关注', curr_personal_activity.follow_button.text, "取消关注未成功", "取消关注达人") except Exception as exp: log.logger.error("发现异常, case:test_talent_operation执行失败") self.raise_exp_and_save_screen_shot(base_app, 'test_talent', exp)