class TestFriendsCase: @classmethod def setup_class(cls): cls.friends = BaseDriver.andriod_driver().to_mine_friends_page() # cls.logInfo = LogInfo() def setup(self): my_friends_icon = self.friends.get_first_friend_name() if my_friends_icon is None: self.friends = BaseDriver.andriod_driver().to_mine_friends_page() else: pass self.logInfo = LogInfo() @allure.story("亲友-亲友详情页测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.core @pytest.mark.release @pytest.mark.mineP0 def test_care(self): """ 跳转亲友详情页 :return: 是否成功跳转到亲友详情页面 """ first_name = self.friends.get_first_friend_name() first_steps = self.friends.get_first_friend_steps() first_sleep = self.friends.get_first_friend_sleep() first_weight = self.friends.get_first_friend_weight() self.friends.click_first_friend_layout() person_name = self.friends.get_person_name() person_steps = self.friends.get_person_steps() person_sleep = self.friends.get_person_sleep() person_weight = self.friends.get_person_weight() self.friends.save_screenshots("查看跳转亲友详情页截图") self.logInfo.logEnd("查看亲友详情页日志") assert first_name == person_name and first_steps == person_steps and first_sleep == person_sleep and first_weight == person_weight @classmethod def teardown_class(cls): # cls.friends.click_back_by_native(type="friend") cls.friends.driver.quit()
class TestTodaySportCase: @classmethod def setup_class(cls): cls.todaysport = BaseDriver.andriod_driver().to_mine_sport_page() # cls.logInfo = LogInfo() def setup(self): # print ("这是运动类") # self.sport_page.get_device_state_custom() # sport_icon = self.todaySport.get_sport_icon() # if sport_icon is None: # self.todaySport.driver.quit() # time.sleep(3) # self.todaySport = BaseDriver.andriod_driver().to_mine_sport_page() # else: # pass self.logInfo = LogInfo() @allure.story("我的运动今日运动历史列表页跳转测试") @allure.severity("block") # @pytest.mark.smoke #重复 @pytest.mark.sportNormal def test_today_sports(self): """ 测试我的运动看今日运动页面跳转 :return:跳转成功,且跳转前与跳转后运动数值相同即为通过 """ today_sport_title = self.todaysport.get_today_sport_title() self.todaysport.to_today_sport_page() today_all_sports_run_mile = self.todaysport.get_today_all_sport_run_mile( ) print(today_sport_title) print(today_all_sports_run_mile) self.todaysport.save_screenshots("今日运动所有运动公里数截图") self.logInfo.logEnd("今日运动所有运动公里数日志") # assert today_sport_title == today_all_sports_run_mile @classmethod def teardown_class(cls): cls.todaysport.click_back_by_native(type="left_btn") cls.todaysport.driver.quit()
class TestCourseCase: @classmethod def setup_class(cls): cls.course = BaseDriver.andriod_driver().to_mine_course_page() # cls.course = CoursePage(cls.driver) # cls.logInfo = LogInfo() def setup(self): my_course_icon = self.course.get_add_course_icon() if my_course_icon is None: self.course = BaseDriver.andriod_driver().to_mine_course_page() else: pass self.logInfo = LogInfo() @allure.story("我的课程-添加课程测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.core @pytest.mark.release @pytest.mark.mineP0 def test_add_course(self): """ 添加课程 备注:当课程列表第一个为付费课程时,则无法添加课程 :return: 是否成功添加课程 """ time.sleep(2) self.course.to_add_course_list() self.course.click_yoga_tab() # self.course.find_free_course() # time.sleep(10) # self.course.click_free_course_label() first_course_name = self.course.get_first_course_list_name() if first_course_name == "New": first_course_name = self.course.get_first_course_list_name_2() self.course.to_first_course_list() course_name = self.course.get_course_name() if first_course_name == course_name: self.course.add_coursec_btn() self.course.click_back_by_native() self.course.click_back_by_native(type='left') mine_course_first_name = self.course.get_first_course_name() self.course.save_screenshots("查看跳转课程详情页截图") self.logInfo.logEnd("查看课程详情页日志") # self.course.click_back_by_native(type='left') assert mine_course_first_name == first_course_name @allure.story("我的课程-课程详情页测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.core @pytest.mark.release @pytest.mark.mineP0 def test_course_page(self): """ 跳转课程详情页 :return: 是否成功跳转到课程详情页面 """ time.sleep(2) # self.course.click_to_my_course() # self.course.to_add_course_list() first_name = self.course.get_first_course_name() self.course.to_first_course_page() second_name = self.course.get_course_name() self.course.save_screenshots("查看跳转课程详情页截图") self.logInfo.logEnd("查看课程详情页日志") self.course.click_back_by_native() assert first_name == second_name @allure.story("我的课程-观看课程测试") @allure.severity('critical') @pytest.mark.smoke def test_watch_course(self): """ 测试观看课程 :return:播放视频后查找到播放视频整体surface元素即为通过 """ self.course.to_first_course_page() time.sleep(3) self.course.click_to_course_list() self.course.click_to_watch_video() video_play_judge = self.course.get_video_play_element() self.course.click_to_pause_video() self.course.click_to_exit_video() self.course.click_feedback() self.course.save_screenshots("课程详情视频播放页截图") self.logInfo.logEnd("课程详情视频播放页日志") self.course.click_back_by_native() assert video_play_judge is not None @allure.story("我的课程-退出课程测试") @allure.severity('critical') @pytest.mark.smoke def test_exit_course(self): """ 测试退出课程 :return: """ self.course.to_first_course_page() time.sleep(1) self.course.click_more_btn() self.course.click_exit_course_btn() after_exit_course = self.course.get_course_info() self.course.save_screenshots("退出课程课程详情页截图") self.logInfo.logEnd("退出课程日志") self.course.click_back_by_native() assert after_exit_course is not None and after_exit_course == "学习课程" @allure.story("我的课程-添加付费课程测试") @allure.severity('critical') @pytest.mark.smoke def test_add_pay_course(self): """ 添加付费课程 :return: 调起收银台即为通过 """ time.sleep(3) self.course.to_add_course_list() self.course.click_all_tab() self.course.find_quality_goods() self.course.click_quality_goods_label() pay_course_info = self.course.get_buy_course_info() self.course.click_to_pay_page() time.sleep(1) ensure_btn = self.course.get_confirm_pay_btn() self.course.save_screenshots("查看购买付费课程页截图") self.logInfo.logEnd("查看购买付费课程页日志") assert pay_course_info == "购买课程" and ensure_btn == "确认支付" @classmethod def teardown_class(cls): cls.course.click_back_by_native(type='left') cls.course.driver.quit()
class TestTodayStepsCase: @classmethod def setup_class(cls): cls.todaySteps = BaseDriver.andriod_driver().to_today_steps_page() # cls.logInfo = LogInfo() def setup(self): # print ("这是今日步数类") # self.todaySteps.get_device_state_custom() statistics_icon = self.todaySteps.get_statistics_icon() if statistics_icon is None: self.todaySteps = BaseDriver.andriod_driver().to_today_steps_page() else: pass self.logInfo = LogInfo() @allure.story("今日步数-分享页面测试") @allure.severity('Normal') @pytest.mark.sportNormal @pytest.mark.smoke # @allure.issue('http://www.baidu.com',"问题") # @allure.testcase('http://www.sina.com', '测试用例') def test_share(self): """ 测试今日步数页面,点击分享按钮,跳转到分享页面,对两侧数值的一致性进行验证 :return: 两侧数据一致,PASS """ steps_before = self.todaySteps.get_steps_today_page() self.todaySteps.click_share_btn() steps_after = self.todaySteps.get_share_steps() self.todaySteps.save_screenshots("今日步数页面分享截图") self.logInfo.logEnd("今日步数页面分享日志") self.todaySteps.click_back_by_native(type="title") assert steps_before == steps_after @allure.story("今日步数-今日统计页面测试") @pytest.mark.smoke def test_count_today_day_steps(self): """ 测试今日步数统计页面每日点击切换结果 :return: 点击后页面可查找到符合结果特殊字符即为通过 """ self.todaySteps.click_statistics_btn() day_count = self.todaySteps.get_step_statistics() self.todaySteps.save_screenshots("今日步数统计日页面截图") self.logInfo.logEnd("今日步数根据日统计") self.todaySteps.click_back_by_native(type="left_btn") if "-" not in day_count and "日" in day_count: assert "日", "月" in day_count @pytest.mark.smoke @allure.story("今日步数-统计分享页面测试") @allure.severity('Normal') @pytest.mark.sportNormal def test_share_day_count(self): """ 测试今日步数日统计活动时长,活动历程,消耗千卡 :return: 分享前与分享后数值相等即为通过 """ self.todaySteps.click_statistics_btn() self.todaySteps.click_statistics_day() day_active_steps = self.todaySteps.get_day_active_steps() day_active_steps = del_symbol(day_active_steps) day_active_time = self.todaySteps.get_day_active_time() day_active_miles = self.todaySteps.get_day_active_miles() day_active_carolie = self.todaySteps.get_day_use_calorie() time.sleep(2) self.todaySteps.click_share_btn() share_active_steps = self.todaySteps.get_day_share_steps() share_active_times = self.todaySteps.get_day_share_times() share_active_miles = self.todaySteps.get_day_share_miles() share_active_carolie = self.todaySteps.get_day_share_carolie() time.sleep(2) self.todaySteps.save_screenshots("今日步数统计日页面分享截图") self.logInfo.logEnd("今日步数根据日统计分享") self.todaySteps.day_share_back_btn() self.todaySteps.click_back_by_native(type="left_btn") self.todaySteps.click_back_by_native(type="left_btn") assert day_active_steps in share_active_steps and \ share_active_miles == day_active_miles and day_active_carolie == share_active_carolie # and day_active_time == share_active_times @allure.story("今日步数-周统计页面测试") @pytest.mark.smoke def test_count_today_week_steps(self): """ 测试今日步数统计页面每周点击切换结果 :return: 点击后页面可查找到符合结果特殊字符即为通过 """ self.todaySteps.click_statistics_btn() self.todaySteps.click_week_statistics() day_count = self.todaySteps.get_step_statistics() self.todaySteps.save_screenshots("今日步数统计周页面截图") self.logInfo.logEnd("今日步数根据周统计日志") self.todaySteps.click_back_by_native(type="left_btn") if "-" in day_count: assert "日", "月" in day_count @allure.story("今日步数-周统计页面分享测试") @pytest.mark.smoke def test_share_week_count(self): """ 测试今日步数周活动时长,活动历程,消耗千卡 :return: 分享前与分享后数值相等即为通过 """ self.todaySteps.click_statistics_btn() self.todaySteps.click_week_statistics() week_active_miles = self.todaySteps.get_week_active_miles() week_active_carolie = self.todaySteps.get_week_active_carolie() time.sleep(2) self.todaySteps.click_share_btn() share_week_miles = self.todaySteps.get_week_share_miles() share_week_carolie = self.todaySteps.get_week_share_carolie() self.todaySteps.save_screenshots("今日步数统计周页面分享截图") self.logInfo.logEnd("今日步数根据周统计分享日志") self.todaySteps.click_week_back_btn() self.todaySteps.click_back_by_native(type="left_btn") assert share_week_miles == week_active_miles and share_week_carolie == week_active_carolie @allure.story("今日步数-月统计页面测试") @pytest.mark.smoke def test_count_today_month_steps(self): """ 测试今日步数统计页面每月点击切换结果 :return: 点击后页面可查找到符合结果特殊字符即为通过 """ self.todaySteps.click_statistics_btn() self.todaySteps.click_month_statistics() day_count = self.todaySteps.get_step_statistics() self.todaySteps.save_screenshots("今日步数统计月页面截图") self.logInfo.logEnd("今日步数根据月统计") self.todaySteps.click_back_by_native(type="left_btn") if "年" in day_count: assert "年", "月" in day_count @allure.story("今日步数-月统计分享页面测试") @pytest.mark.smoke def test_share_month_count(self): """ 测试今日步数月活动时长,活动历程,消耗千卡 :return: 分享前与分享后数值相等即为通过 """ self.todaySteps.click_statistics_btn() self.todaySteps.click_month_statistics() month_active_miles = self.todaySteps.get_month_active_miles() month_active_carolie = self.todaySteps.get_month_active_carolie() time.sleep(2) self.todaySteps.click_share_btn() share_month_miles = self.todaySteps.get_month_share_miles() share_month_carolie = self.todaySteps.get_month_share_carolie() self.todaySteps.day_share_back_btn() self.todaySteps.click_back_by_native(type="left_btn") assert month_active_carolie == share_month_carolie and month_active_miles == share_month_miles # @allure.story("今日步数-统计-日视图页面测试") # @allure.severity('Blocker') # # @allure.issue('http://www.baidu.com',"问题") # # @allure.testcase('http://www.sina.com', '测试用例') # def test_share(self): # """ # 测试今日步数,统计页面,日试图,界面跳转 # :return:可以正确进入统计日试图,PASS # """ # self.todaySteps.click_statistics_btn() # #暂时无法定位日视图的控件,暂时不写 # self.todaySteps.save_screenshots("今日步数页面分享截图") # self.logInfo.logEnd("今日步数页面分享日志") # assert steps_before == steps_after @classmethod def teardown_class(cls): cls.todaySteps.click_back_by_native(type='left') cls.todaySteps.driver.quit()
class TestSportCase: @classmethod def setup_class(cls): cls.sport_page = BaseDriver.andriod_driver().to_sport_page() # cls.logInfo = LogInfo() def setup(self): # print ("这是运动类") # self.sport_page.get_device_state_custom() sport_icon = self.sport_page.get_sport_icon() if sport_icon is None: self.sport_page.driver.quit() time.sleep(3) self.sport_page = BaseDriver.andriod_driver().to_sport_page() else: pass self.logInfo = LogInfo() @allure.story("首页点击步数进入今日步数页面测试") @allure.severity('Blocker') # @allure.issue('http://www.baidu.com',"问题") # @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.sportP0 @pytest.mark.core @pytest.mark.release @pytest.mark.smoke def test_steps_page(self): """ 测试从首页点击步数,进入今日详情页,对两侧步数是否一致进行验证 :return: 两侧数据一致时,代表PASS """ steps_nums = self.sport_page.get_steps_main_page() steps_num = int(del_symbol(steps_nums)) if steps_num > 0: self.sport_page.click_steps_layout() steps = int(self.sport_page.get_steps_today()) isSuccess = (steps_num == steps) else: #此时没有产生步数,不知道文案,暂时标为失败 isSuccess = False self.sport_page.save_screenshots("进入今日步数详情页截图") self.logInfo.logEnd("进入今日步数详情页日志") self.sport_page.click_back_by_native("left_btn") assert isSuccess is True # @allure.story("首页点击睡眠卡片进入昨晚睡眠页面测试") # @allure.severity('Blocker') # def test_last_sleep_time(self): # """ # 测试从首页点击昨晚睡眠长卡片,进入昨晚睡眠页面,对两侧睡眠时长是否一致进行验证 # :return: 两侧数值一致时,PASS # """ # sleep_time_mian_page = self.sport_page.get_sleep_time_main_page() # sleep_before = sleep_time_mian_page.split(" ")[1] # self.sport_page.click_first_layout() # sleep_time_mine_page = self.sport_page.get_sleep_time_mine() # # sleep_middle = del_symbol(sleep_time_mine_page) # # sleep_after = del_str(sleep_middle, " ") # self.sport_page.save_screenshots("从首页点击睡眠卡片进入昨晚睡眠截图") # self.logInfo.logEnd("从首页点击睡眠卡片进入昨晚睡眠日志") # self.sport_page.click_back_by_native("left_btn") # assert sleep_before == sleep_time_mine_page @allure.story("首页点击体重卡片进入体重详情页面测试") @allure.severity('Blocker') # @allure.issue('http://www.baidu.com',"问题") # @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.sportP0 @pytest.mark.core @pytest.mark.release # @pytest.mark.smoke #首页布局不固定,当前账号暂不修改布局 @pytest.mark.skip #首页布局原因 def test_weight(self): """ 测试从首页点击体重卡片,进入体重详情页,对两侧数值是否一致进行验证 :return:两侧数值一致时,PASS """ weight_main_page = self.sport_page.get_weight_main_page() weight_temp = weight_main_page.split(" ")[1] # self.sport_page.to_mine_status_page() self.sport_page.click_weight_layout() weight_mine_page = self.sport_page.get_weight_mine_page() + "斤" self.sport_page.save_screenshots("进入体重详情页截图") self.logInfo.logEnd("进入体重详情页日志") self.sport_page.click_back_by_native("left_btn") assert weight_temp == weight_mine_page @allure.story("进行健走测试") @allure.severity('Blocker') @pytest.mark.core @pytest.mark.release @pytest.mark.smoke @pytest.mark.sportP0 def test_work_page(self): temp = self.sport_page.to_work_page() self.sport_page.save_screenshots("进行健走截图") self.logInfo.logEnd("进行健走日志") assert temp is True @allure.story("进行室外跑测试") @allure.severity('Blocker') @pytest.mark.core @pytest.mark.release @pytest.mark.smoke @pytest.mark.sportP0 def test_outdoor_run_page(self): temp = self.sport_page.to_run_outdoor_page() self.sport_page.save_screenshots("进行室外跑截图") self.logInfo.logEnd("进行室外跑日志") assert temp is True @allure.story("进行室内跑测试") @allure.severity('Blocker') @pytest.mark.core @pytest.mark.release # @pytest.mark.smoke #元素未找到 @pytest.mark.sportP0 def test_indoor_run_page(self): temp = self.sport_page.to_run_indoor_page() self.sport_page.save_screenshots("进行室内跑截图") self.logInfo.logEnd("进行室内跑日志") assert temp is True @allure.story("进行骑行测试") @allure.severity('Blocker') @pytest.mark.core @pytest.mark.release # @pytest.mark.smoke #元素未找到 @pytest.mark.sportP0 def test_cycling_page(self): temp = self.sport_page.to_cycling_page() self.sport_page.save_screenshots("进行骑行截图") self.logInfo.logEnd("进行骑行日志") assert temp is True @allure.story("查找运动tab页广告位") @allure.severity('Normal') @pytest.mark.dependency() @pytest.mark.sportNormal def test_find_ad(self): self.sport_page.to_status_page() # 获取广告控件 if self.sport_page.get_ad_element() is None: is_have_ad = False else: is_have_ad = True assert is_have_ad is True @allure.story("进入首页广告页测试") @allure.severity('Normal') @pytest.mark.flaky(reruns=2, reruns_delay=3) @pytest.mark.dependency(depends=['TestSportCase::test_find_ad']) @pytest.mark.sportNormal def test_ad_page(self): self.sport_page.to_advertisement_page() time.sleep(2) back_btn = self.sport_page.get_back_btn() ad_back_btn = self.sport_page.get_ad_back_btn() self.sport_page.save_screenshots("进入首页广告截图") self.logInfo.logEnd("进入首页广告日志") if back_btn is not None: self.sport_page.click_back_btn() else: self.sport_page.click_back_by_native(type="back") assert back_btn is not None or ad_back_btn is not None @allure.story("进入首页大家都在练-长卡片测试") @allure.severity('Normal') @pytest.mark.dependency() @pytest.mark.flaky(reruns=2, reruns_delay=5) @pytest.mark.sportNormal def test_practice_long_card(self): time.sleep(5) self.sport_page.swipe_on("up_middle") self.sport_page.to_practice_long_card() back_btn = self.sport_page.get_classic_back_btn() time.sleep(2) self.sport_page.save_screenshots("进入首页大家都在练长卡片截图") self.logInfo.logEnd("进入首页大家都在练长卡片日志") self.sport_page.click_classic_back_btn() assert back_btn is not None @allure.story("进入首页大家都在练-短卡片1测试") @allure.severity('Normal') @pytest.mark.dependency(depends=["TestSportCase::test_practice_long_card"]) @pytest.mark.flaky(reruns=2, reruns_delay=5) @pytest.mark.sportNormal def test_practice_short_card_1(self): time.sleep(5) self.sport_page.swipe_on("up_middle") self.sport_page.to_practice_short_card_1() back_btn = self.sport_page.get_classic_back_btn() time.sleep(2) self.sport_page.save_screenshots("进入首页大家都在练-短卡片1截图") self.logInfo.logEnd("进入首页大家都在练-短卡片1日志") self.sport_page.click_classic_back_btn() assert back_btn is not None @allure.story("进入首页大家都在练-短卡片2测试") @allure.severity('Normal') @pytest.mark.dependency( depends=["TestSportCase::test_practice_short_card_1"]) @pytest.mark.flaky(reruns=2, reruns_delay=5) @pytest.mark.sportNormal def test_practice_short_card_2(self): # time.sleep(5) # self.sport_page.swipe_on("up_middle") self.sport_page.to_practice_short_card_2() back_btn = self.sport_page.get_classic_back_btn() time.sleep(2) self.sport_page.save_screenshots("进入首页大家都在练-短卡片2截图") self.logInfo.logEnd("进入首页大家都在练-短卡片2日志") self.sport_page.click_classic_back_btn() assert back_btn is not None @pytest.mark.skip(reason="暂时没有赛事活动模块") @allure.story("进入首页赛事活动页面测试") @allure.severity('Normal') @pytest.mark.sportNormal def test_premitition_page(self): # time.sleep(5) # self.sport_page.swipe_on("up_middle") # time.sleep(3) # self.sport_page.swipe_on("up_middle") self.sport_page.to_competition_activity_page() back_btn = self.sport_page.get_back_btn() time.sleep(5) self.sport_page.save_screenshots("进入首页赛事活动页面截图") self.logInfo.logEnd("进入首页赛事活动页面日志") self.sport_page.click_back_btn() assert back_btn is not None # @allure.story("进入首页热门话题第一部分详情页测试") # @allure.severity('Normal') # def test_hot_topic_first_page(self): # time.sleep(5) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # # nick_element = self.sport_page.get_nick_element() # # self.sport_page.find_element_to_element(nick_element) # nick_name = self.sport_page.get_hot_topic_nick_name() # self.sport_page.to_hot_topic_first_card() # nick_name_page = self.sport_page.get_topic_page_nick_name() # time.sleep(3) # self.sport_page.save_screenshots("进入首页热门话题第一部分详情页截图") # self.logInfo.logEnd("进入首页热门话题第一部分详情页日志") # assert nick_name == nick_name_page # # @allure.story("进入首页热门话题第二部分详情页测试") # @allure.severity('Normal') # def test_hot_topic_second_page(self): # time.sleep(5) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # # nick_element = self.sport_page.get_nick_element() # # self.sport_page.find_element_to_element(nick_element) # nick_name = self.sport_page.get_second_nick_name() # self.sport_page.to_hot_topic_second_card() # nick_name_page = self.sport_page.get_topic_page_nick_name() # time.sleep(3) # self.sport_page.save_screenshots("进入首页热门话题第二部分详情页截图") # self.logInfo.logEnd("进入首页热门话题第二部分详情页日志") # assert nick_name == nick_name_page # # @allure.story("进入首页热门话题第三部分详情页测试") # @allure.severity('Normal') # def test_hot_topic_third_page(self): # time.sleep(5) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # time.sleep(2) # self.sport_page.swipe_on("up_middle") # # nick_element = self.sport_page.get_nick_element() # # self.sport_page.find_element_to_element(nick_element) # nick_name = self.sport_page.get_third_nick_name() # self.sport_page.to_hot_topic_third_card() # nick_name_page = self.sport_page.get_topic_page_nick_name() # time.sleep(3) # self.sport_page.save_screenshots("进入首页热门话题第三部分详情页截图") # self.logInfo.logEnd("进入首页热门话题第三部分详情页日志") # assert nick_name == nick_name_page @classmethod def teardown_class(cls): cls.sport_page.driver.quit()
class TestMyStatus(): """ 运动模块-我的状态测试 """ @classmethod def setup_class(cls): cls.my_status = BaseDriver.andriod_driver().to_my_status_page() def setup(self): my_status_icon = self.my_status.get_my_status_icon() if my_status_icon is None: self.my_status = BaseDriver.andriod_driver().to_my_status_page() else: pass self.logInfo = LogInfo() @pytest.mark.smoke # @pytest.mark.skip(reason="滑动到指定元素的方法还需要优化,此用例跳过") def test_pai_value(self): """ 测试pai值我的状态页面展示数值与点击进入后数值 :return: 一致则通过 """ self.my_status.swipe_on(direction="up") get_before_all_pai_value = self.my_status.get_before_pai_value() get_before_today_pai_value = self.my_status.get_today_pai_value() self.my_status.click_to_pai_page() judge_if_pai_guide_exist = self.my_status.find_pai_guide_element() if judge_if_pai_guide_exist is not None: self.my_status.swipe_on("up") get_after_all_pai_value = self.my_status.get_after_all_pai_value() get_after_today_pai_value = self.my_status.get_after_today_pai_value() get_after_today_pai_value = get_after_today_pai_value.split("P")[0] self.my_status.save_screenshots("查看运动-我的状态-PAI值截图") self.logInfo.logEnd("查看运动-我的状态-PAI值日志") self.my_status.click_back_by_native(type="left_btn") time.sleep(1) assert get_after_all_pai_value in get_before_all_pai_value and \ get_after_today_pai_value in get_before_today_pai_value @pytest.mark.smoke def test_press_value(self): """ 测试运动-我的状态-压力值和点击进入后压力值 :return: 数值一致即为通过 """ self.my_status.swipe_on(direction="down") get_before_press = self.my_status.get_before_recent_press() self.my_status.click_to_press_page() get_after_press = self.my_status.get_after_recent_press() self.my_status.save_screenshots("查看运动-我的状态-压力值截图") self.logInfo.logEnd("查看运动-我的状态-压力值日志") self.my_status.click_back_by_native(type="left_btn") time.sleep(1) assert get_after_press in get_before_press @pytest.mark.smoke def test_heart_rate(self): """ 测试运动-我的状态-心率数值和点击进入后数值 :return: 进入前后心率数值相同即为通过 """ get_before_heart_rate = self.my_status.get_before_heart_rate() self.my_status.click_to_heart_rate_page() time.sleep(1) get_after_heart_rate = self.my_status.get_after_heart_rate() self.my_status.save_screenshots("查看运动-我的状态-心率截图") self.logInfo.logEnd("查看运动-我的状态-心率日志") self.my_status.click_back_by_native(type="left_btn") assert get_after_heart_rate in get_before_heart_rate # @pytest.mark.smoke #展示用暂时注释,需考虑无数据时场景 @pytest.mark.skip(reason="暂无睡眠数据") def test_last_sleep(self): """ 测试运动-我的状态-睡眠卡片跳转 :return:跳转前与跳转后睡眠时间相同即为通过 """ # get_sleep_element = self.my_status.find_before_last_sleep_element() self.my_status.swipe_to_half() get_before_sleep_time = self.my_status.get_before_sleep_time() get_before_sleep_time = get_before_sleep_time.split("昨晚睡眠 ")[1] self.my_status.click_to_sleep_page() get_after_sleep_time = self.my_status.get_after_sleep_time() self.my_status.save_screenshots("查看运动-我的状态-睡眠截图") self.logInfo.logEnd("查看运动-我的状态-睡眠日志") self.my_status.click_back_by_native(type="left_btn") assert get_before_sleep_time == get_after_sleep_time # @pytest.mark.smoke #演示原因 暂时注释 @pytest.mark.skip(reason="暂无睡眠数据") def test_a_few_sleep(self): """ 测试运动-我的状态-零星小睡跳转 :return: """ self.my_status.find_before_last_sleep_element() self.my_status.click_to_sleep_page() get_before_little_sleep = self.my_status.get_before_little_sleep_time() self.my_status.click_to_little_sleep() get_after_little_sleep = self.my_status.get_after_little_sleep_time() print(get_after_little_sleep, get_before_little_sleep) self.my_status.click_back_by_native(type="back") self.my_status.click_back_by_native(type="back") @pytest.mark.smoke # @pytest.mark.skip(reason="滑动到指定元素的方法还需要优化,此用例跳过") def test_weight_kilogram(self): """ 测试运动-我的状态-体重数值进入前与进入后 :return: 数值相同即为pass """ # self.my_status.swipe_to_bottle() self.my_status.swipe_on(direction="down") # self.my_status.find_before_weight_value() get_before_weight = self.my_status.get_before_weight_value() self.my_status.click_to_weight_page() time.sleep(1) get_after_weight = self.my_status.get_after_weight_value() self.my_status.save_screenshots("查看运动-我的状态-体重截图") self.logInfo.logEnd("查看运动-我的状态-体重日志") self.my_status.click_back_by_native(type="left_btn") assert get_after_weight in get_before_weight ''' 由于体重元素不在屏幕展示范围内,需要先执行滑动,再查找元素 待解决 ''' @pytest.mark.smoke # @pytest.mark.skip(reason="滑动到指定元素的方法还需要优化,此用例跳过") def test_body_fat(self): """ 测试运动-我的状态-身体指数卡片跳转 :return:跳转前与跳转后身体指数相同即为通过 """ # self.my_status.swipe_to_bottle() self.my_status.find_body_fat_element() before_body_fat = self.my_status.get_before_body_fat() before_body_fat = before_body_fat.split(" ")[1] self.my_status.click_to_body_fat_page() after_body_fat = self.my_status.get_after_body_fat() self.my_status.save_screenshots("查看运动-我的状态-身体指数截图") self.logInfo.logEnd("查看运动-我的状态-身体指数日志") self.my_status.click_back_by_native(type="left_btn") assert before_body_fat in after_body_fat @pytest.mark.smoke # @pytest.mark.skip(reason="滑动到指定元素的方法还需要优化,此用例跳过") def test_balance(self): """ 测试运动-我的状态-平衡性卡片跳转 :return: 点击前后页面平衡性一致即为通过 """ # self.my_status.swipe_to_bottle() self.my_status.find_balance_element() before_balance = self.my_status.get_before_balance() before_balance = before_balance.split(" ")[1] self.my_status.click_to_balance_page() time.sleep(1) after_balance = self.my_status.get_after_balance() self.my_status.save_screenshots("查看运动-我的状态-平衡性截图") self.logInfo.logEnd("查看运动-我的状态-平衡性日志") self.my_status.click_back_by_native(type="left_btn") assert after_balance in before_balance @classmethod def teardown_class(cls): cls.my_status.driver.quit()
class TestLastSleep: @classmethod def setup_class(cls): cls.last_sleep = BaseDriver.andriod_driver().to_my_status_sleep_page() # cls.logInfo = LogInfo() def setup(self): share_icon = self.last_sleep.get_sleep() if share_icon is None: self.last_sleep = BaseDriver.andriod_driver().to_my_status_sleep_page() else: pass self.logInfo = LogInfo() @allure.story("昨晚睡眠-视图切换页面测试") @allure.severity('Blocker') @pytest.mark.sleepNormal #@pytest.mark.smoke def test_last_sleep_day_view(self): """ 测试昨晚睡眠日视图切换 :return:查找到睡眠得分即为通过 """ self.last_sleep.click_day_btn() last_sleep_score = self.last_sleep.get_sleep_score() edit_icon = self.last_sleep.get_edit_icon() self.last_sleep.save_screenshots("昨晚睡眠页面日视图截图") self.logInfo.logEnd("昨晚睡眠页面日视图日志") assert last_sleep_score is not None and edit_icon is not None #@pytest.mark.smoke def test_last_week_day_view(self): """ 测试昨晚睡眠周统计视图 :return: 点击后若页面展示周睡眠统计即为pass """ self.last_sleep.click_week_btn() click_week_result = self.last_sleep.get_click_result() self.last_sleep.save_screenshots("昨晚睡眠页面周视图截图") self.logInfo.logEnd("昨晚睡眠页面周视图日志") assert click_week_result == "周睡眠统计" #@pytest.mark.smoke def test_last_month_day_view(self): """ 测试昨晚睡眠月统计视图 :return: 点击后若页面展示月睡眠统计即为pass """ self.last_sleep.click_month_btn() click_month_result = self.last_sleep.get_click_result() self.last_sleep.save_screenshots("昨晚睡眠页面月视图截图") self.logInfo.logEnd("昨晚睡眠页面月视图日志") assert click_month_result == "月睡眠统计" #@pytest.mark.smoke def test_last_year_day_view(self): """ 测试昨晚睡眠年统计视图 :return: 点击后若页面展示年睡眠统计即为pass """ self.last_sleep.click_year_btn() click_tear_result = self.last_sleep.get_click_result() self.last_sleep.save_screenshots("昨晚睡眠页面年视图截图") self.logInfo.logEnd("昨晚睡眠页面年视图日志") assert click_tear_result == "年睡眠统计" @classmethod def teardown_class(cls): cls.last_sleep.click_back_by_native(type='left') cls.last_sleep.driver.quit()
class TestMyDynamic: """ 测试我的tab下我的动态下动态展示和帖子点赞评论删除操作 """ @classmethod def setup_class(cls): cls.dynamic = BaseDriver.andriod_driver().to_my_dynamic_page() # cls.logInfo = LogInfo() def setup(self): edit_profile_icon = self.dynamic.get_edit_profile_icon() if edit_profile_icon is None: self.dynamic = BaseDriver.andriod_driver().to_my_dynamic_page() else: pass self.logInfo = LogInfo() @allure.story("个人主页-动态tab下帖子跳转功能测试") @allure.severity('critical') @pytest.mark.smoke def test_dynamic_page(self): """ 查看个人主页-动态tab下帖子跳转功能 :return: 是否成功跳转到帖子页面 """ time.sleep(1) first_name = self.dynamic.get_first_post_name() self.dynamic.to_post_page() time.sleep(1) self.dynamic.swipe_on(direction='down') nick_name = self.dynamic.get_publisher_name() self.dynamic.save_screenshots("查看个人主页-动态tab下帖子跳转功能截图") self.logInfo.logEnd("查看个人主页-动态tab下帖子跳转功能日志") self.dynamic.click_back_by_native() assert first_name == nick_name @allure.story("个人主页-动态tab下帖子点赞测试") @pytest.mark.smoke def test_dynamic_like_post(self): """ 测试对社区帖子进行点赞 :return:若帖子点赞数为0则点赞后数量为1,若>0,则点赞后结果加一,或取消点赞,结果减一 """ self.dynamic.to_post_page() before_press_like_btn = self.dynamic.get_like_btn_value() if before_press_like_btn == "点赞": self.dynamic.click_like_btn() time.sleep(1) after_press_like_btn = self.dynamic.get_like_btn_value() self.dynamic.save_screenshots("社区tab帖子点赞功能截图") self.logInfo.logEnd("社区tab帖子点赞功能日志") assert after_press_like_btn == '1' else: before_press_like_btn = int(before_press_like_btn) self.dynamic.save_screenshots("社区tab帖子点赞功能截图") self.logInfo.logEnd("社区tab帖子点赞功能日志") self.dynamic.click_like_btn() time.sleep(1) after_press_like_btn = int(self.dynamic.get_like_btn_value()) assert after_press_like_btn == before_press_like_btn + 1 \ or after_press_like_btn == before_press_like_btn - 1 @allure.story("个人主页-动态tab下帖子评论功能测试") @pytest.mark.smoke def test_dynamic_comment_post(self): """ 测试对帖子评论功能 :return:帖子评论数为0时,评论后返回结果为1,或当前评论数>1时,返回结果为评论数+1即为通过 """ self.dynamic.to_post_page() before_comment_value = self.dynamic.get_comment_value() if before_comment_value == "评论": self.dynamic.click_to_comment_page() self.dynamic.edit_comment() self.dynamic.press_comment_btn() after_comment_value = self.dynamic.get_comment_value() self.dynamic.save_screenshots("社区tab帖子评论功能截图") self.logInfo.logEnd("社区tab帖子评论功能日志") assert after_comment_value == '1' else: before_comment_value = int(before_comment_value) self.dynamic.click_to_comment_page() self.dynamic.edit_comment() self.dynamic.press_comment_btn() after_comment_value = int(self.dynamic.get_comment_value()) assert after_comment_value == before_comment_value + 1 @allure.story("个人主页-动态tab下帖子删除功能测试") @pytest.mark.smoke def test_dynamic_delete_post(self): """ 测试社区删帖功能 :return:删帖前当前帖子发布者名称与删帖后贴子发布者名称不同即为pass """ now_my_dynamic_num = int(self.dynamic.get_my_dynamic_num_value()) time.sleep(2) before_dynamic_index = self.dynamic.get_my_dynamic_index() self.dynamic.to_post_page() if now_my_dynamic_num == 1: self.dynamic.click_share_btn() self.dynamic.click_delete_btn() self.dynamic.click_confirm_delete_btn() after_dynamic_index = self.dynamic.get_my_dynamic_index() self.dynamic.save_screenshots("社区tab帖子删除功能截图") self.logInfo.logEnd("社区tab帖子删除功能日志") assert len( before_dynamic_index) == 1 and after_dynamic_index is None else: now_publisher_name = self.dynamic.get_publisher_name() self.dynamic.click_share_btn() self.dynamic.click_delete_btn() self.dynamic.click_confirm_delete_btn() after_publisher_name = self.dynamic.get_publisher_name() self.dynamic.save_screenshots("社区tab帖子删除功能截图") self.logInfo.logEnd("社区tab帖子删除功能日志") assert now_publisher_name != after_publisher_name @classmethod def teardown_class(cls): cls.dynamic.driver.quit()
class TestPersonalHomepageCase: @classmethod def setup_class(cls): cls.homepage = BaseDriver.andriod_driver().to_mine_personal_homepage() # cls.logInfo = LogInfo() def setup(self): # print ("这是个人主页类") # self.homepage.get_device_state_custom() edit_profile_icon = self.homepage.get_edit_profile_icon() if edit_profile_icon is None: self.homepage = BaseDriver.andriod_driver().to_mine_personal_homepage() else: pass self.logInfo = LogInfo() @allure.story("个人主页-我的关注测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke #展示用暂时注释 @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_care(self): """ 查看我的关注页面 :return: 是否成功查看我的关注页面 """ self.homepage.click_care_btn() title = self.homepage.get_title() self.homepage.save_screenshots("查看个人主页-我的关注页面截图") self.logInfo.logEnd("查看个人主页-我的关注页面日志") self.homepage.click_back_by_native(type='left') assert title == "我的关注" @allure.story("个人主页-我的粉丝测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.core @pytest.mark.release @pytest.mark.mineP0 def test_fans(self): """ 查看我的粉丝页面 :return: 是否成功查看我的粉丝页面 """ self.homepage.click_fans_btn() title = self.homepage.get_title() self.homepage.save_screenshots("查看个人主页-我的粉丝页面截图") self.logInfo.logEnd("查看个人主页-我的粉丝页面日志") self.homepage.click_back_by_native(type='left') assert title == "我的粉丝" @allure.story("个人主页-编辑资料按钮跳转功能测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_edit_profile(self): """ 查看个人主页-编辑资料按钮跳转功能 :return: 是否成功跳转到个人信息页面 """ self.homepage.click_person_profile() title = self.homepage.get_title() self.homepage.save_screenshots("查看个人主页-编辑资料按钮跳转功能截图") self.logInfo.logEnd("查看个人主页-编辑资料按钮跳转功能日志") self.homepage.click_back_by_native(type='left') assert title == "个人信息" @allure.story("个人主页-更多勋章按钮跳转功能测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_medal_page(self): """ 查看个人主页-更多勋章按钮跳转功能 :return: 是否成功跳转到我的勋章页面 """ self.homepage.to_medal_page() title = self.homepage.get_title() self.homepage.save_screenshots("查看个人主页-更多勋章按钮跳转功能截图") self.logInfo.logEnd("查看个人主页-更多勋章按钮跳转功能日志") time.sleep(2) self.homepage.click_back_by_native(type='left') assert title == "我的勋章" @allure.story("个人主页-我的日记本跳转功能测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_diary_page(self): """ 查看个人主页-我的日记本跳转功能 :return: 是否成功跳转到我的日记本页面 """ time.sleep(3) self.homepage.to_diary_page() title = self.homepage.get_title() self.homepage.save_screenshots("查看个人主页-我的日记本跳转功能截图") self.logInfo.logEnd("查看个人主页-我的日记本跳转功能日志") self.homepage.click_back_by_native(type='left') assert title == "日记本" @allure.story("个人主页-动态tab下帖子跳转功能测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_dynamic_page(self): """ 查看个人主页-动态tab下帖子跳转功能 :return: 是否成功跳转到帖子页面 """ time.sleep(2) first_name = self.homepage.get_first_post_name() self.homepage.to_post_page() time.sleep(3) self.homepage.swipe_on('down') nick_name = self.homepage.get_publisher_name() self.homepage.save_screenshots("查看个人主页-动态tab下帖子跳转功能截图") self.logInfo.logEnd("查看个人主页-动态tab下帖子跳转功能日志") self.homepage.click_back_by_native() assert first_name == nick_name @allure.story("个人主页-视频tab下帖子跳转功能测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.skip #当前账号无权限 @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_video_page(self): """ 查看个人主页-视频tab下帖子跳转功能 :return: 是否成功跳转到帖子页面 """ self.homepage.click_video_tab() time.sleep(2) first_name = self.homepage.get_first_post_name() self.homepage.to_post_page() time.sleep(3) self.homepage.swipe_on('down') second_name = self.homepage.get_publisher_name() self.homepage.save_screenshots("查看个人主页-视频tab下帖子跳转功能截图") self.logInfo.logEnd("查看个人主页-视频tab下帖子跳转功能日志") self.homepage.click_back_by_native() assert first_name == second_name @classmethod def teardown_class(cls): # cls.homepage.click_back_by_native(type="home_page") cls.homepage.driver.quit()
class TestJoinTrain: """ 训练课程模块测试 """ def setup_class(cls): cls.join_train = BaseDriver.andriod_driver().to_train_page() def setup(self): # sport_icon = self..get_sport_icon() # if sport_icon is None: # self.sport_page.driver.quit() # time.sleep(3) # self.sport_page = BaseDriver.andriod_driver().to_heart_rate_page() # else: # pass self.logInfo = LogInfo() @allure.story("判断是否已参加训练课程") @allure.severity('Normal') @pytest.mark.smoke # @pytest.mark.dependency() @pytest.mark.run(order=1) def test_judge_already_join_train(self): """ 判断是否已有参加课程 若有则退出课程 :return: """ judge_join_train = self.join_train.judge_if_already_join_train() if judge_join_train is not None: self.join_train.click_continue_train() train_flag = True while train_flag == True: if self.join_train.get_more_btn() is not None: self.join_train.click_more_btn() self.join_train.click_exit_train() self.join_train.click_confirm_exit_train_btn() else: train_flag = False after_exit_judge = self.join_train.judge_if_already_join_train() else: after_exit_judge = self.join_train.judge_if_already_join_train() assert after_exit_judge is None @allure.story("参加训练课程观看并退出观看") @allure.severity('Normal') @pytest.mark.smoke # @pytest.mark.dependency(depends=["test_judge_already_join_train"]) @pytest.mark.run(order=2) def test_join_train(self): """ 添加训练课程,观看并退出 :return: 课程进入前后课程名称一致,并且播放成功即为通过 """ self.join_train.click_join_train() self.join_train.click_select_train_target() self.join_train.click_next_step() self.join_train.click_select_train_level() self.join_train.click_next_step() self.join_train.click_select_start_date() self.join_train.click_next_step() time.sleep(3) before_train_name = self.join_train.get_train_name() self.join_train.click_join_train_btn() after_train_name = self.join_train.get_train_name() self.join_train.click_start_train() already_download_judge = self.join_train.judge_already_download_video() if already_download_judge is not None: self.join_train.click_download_today_video() time.sleep(10) video_play_judge = self.join_train.video_play_surface_judge() self.join_train.touch_video() self.join_train.click_close_video_btn() self.join_train.confirm_close_video() elif already_download_judge is None: video_play_judge = self.join_train.video_play_surface_judge() self.join_train.touch_video() self.join_train.click_close_video_btn() self.join_train.confirm_close_video() self.join_train.save_screenshots("课程tab初次参加训练截图") self.logInfo.logEnd("课程tab初次参加训练日志") assert before_train_name == after_train_name and video_play_judge is not None @allure.story("退出训练课程") @allure.severity('Normal') @pytest.mark.smoke def test_exit_train(self): """ 退出训练课程 :return: """ self.join_train.click_continue_train() self.join_train.click_more_btn() self.join_train.click_exit_train() self.join_train.click_confirm_exit_train_btn() self.join_train.save_screenshots("课程tab退出训练截图") self.logInfo.logEnd("课程tab退出训练日志") exit_train_result = self.join_train.get_exit_train_result_element() assert exit_train_result is not None @classmethod def teardown_class(cls): # cls.join_train.click_back_by_native(type='back') cls.join_train.driver.quit()
class TestFindCase: @classmethod def setup_class(cls): cls.find_page = BaseDriver.andriod_driver().to_find_page() # cls.logInfo = LogInfo() time.sleep(3) def setup(self): activities_icon = self.find_page.get_activity_icon() if activities_icon is None: self.find_page = BaseDriver.andriod_driver().to_find_page() else: pass self.logInfo = LogInfo() @allure.story("切换到活动页面测试") @allure.severity('Blocker') @pytest.mark.discoveryP0 @pytest.mark.core def test_click_activity_btn(self): ''' 进入到活动页面 :return: 是否成功进入活动页面 ''' self.find_page.click_activity_btn() title = self.find_page.get_my_participation_title() self.find_page.save_screenshots("活动页面截图") self.logInfo.logEnd("进入活动页面日志") self.find_page.click_back_by_native(type="find") assert title == '我参与的' @allure.story("进入资讯页面测试") @allure.severity('Blocker') @pytest.mark.discoveryP0 @pytest.mark.core def test_news(self): """ 进入资讯页面 :return: 是否成功进入资讯页面 """ self.find_page.click_news() title = self.find_page.get_news_icon_page_title() self.find_page.save_screenshots("资讯页面截图") self.logInfo.logEnd("进入资讯页面日志") self.find_page.click_back_by_native(type="find") assert title == '全部资讯' @allure.story("进入健康服务页面测试") @allure.severity('Blocker') @pytest.mark.discoveryP0 @pytest.mark.core def test_health_service(self): ''' 点击健康服务icon :return: 是否成功进入到健康服务页面 ''' self.find_page.click_health_service() title = self.find_page.get_health_service_title() self.find_page.save_screenshots("健康服务截图") self.logInfo.logEnd("点击健康服务更多按钮日志") self.find_page.click_back_by_native(type="find") assert title == "健康服务" @allure.story("获取发现页面是否有热门活动模块") @allure.severity('Blocker') @pytest.mark.discoveryP0 @pytest.mark.core @pytest.mark.dependency() def test_get_activities(self): ''' 获取发现页面是否有热门活动 :return:有热门活动 返回True ''' title = self.find_page.get_activities_title() self.find_page.save_screenshots("判断发现页面是否有热门活动截图") self.logInfo.logEnd("判断发现页面是否有热门活动日志") assert title is not None @allure.story("热门活动跳转测试") @allure.severity('Blocker') @pytest.mark.discoveryP0 @pytest.mark.core @pytest.mark.dependency(depends=['TestFindCase::test_get_activities']) def test_click_popular_activities(self): ''' 点击热门活动 :return:是否成功跳转到活动页面 ''' self.find_page.click_popular_activities() title = self.find_page.get_activities_title() self.find_page.save_screenshots("热门活动截图") self.logInfo.logEnd("点击热门活动日志") self.find_page.click_back_by_native(type="left") assert title == "中国节·庚子端午" @allure.story("进入发现首页热门资讯文章详情页") @allure.severity('Blocker') @pytest.mark.discoveryP0 @pytest.mark.core def test_news_page(self): ''' 进入热门资讯详情页 :return: 是否成功进入发现页面热门资讯文章详情页 ''' news_title = self.find_page.get_news_title() if news_title is None: news_title = self.find_page.get_news_title_2() self.find_page.click_news_layout_2() else: self.find_page.click_news_layout() news_page_title = self.find_page.get_news_page_title() # self.find_page.click_news_back_to_find() self.find_page.save_screenshots("热门资讯详情页截图") self.logInfo.logEnd("进入热门资讯日志") self.find_page.click_back_by_native(type="left") assert news_title == news_page_title @allure.story("进入内容推荐页面测试") @allure.severity('Blocker') @pytest.mark.discoveryP0 @pytest.mark.core def test_click_content_recommendation_first(self): ''' 进入到发现页面内容推荐列表里第一个帖子详情页面 :return: 是否成功进入对应帖子的页面 ''' time.sleep(3) # self.find_page.swipe_on("up_middle") title = self.find_page.get_content_recommendation_first_title() self.find_page.click_content_recommendation_first_layout() first_title = self.find_page.get_content_recommendation_first_page_title() # self.find_page.click_news_back_to_find() self.find_page.save_screenshots("内容推荐列表第一个帖子详情页截图") self.logInfo.logEnd("进入内容推荐列表第一个帖子详情页面日志") self.find_page.click_back_by_native(type="left") assert title == first_title @classmethod def teardown_class(cls): cls.find_page.driver.quit()
class TestTodayEnergyCase: @classmethod def setup_class(cls): cls.today_energy = BaseDriver.andriod_driver().to_weight_page() # cls.logInfo = LogInfo() def setup(self): # print ("这是运动类") # self.sport_page.get_device_state_custom() # sport_icon = self.todaySport.get_sport_icon() # if sport_icon is None: # self.todaySport.driver.quit() # time.sleep(3) # self.todaySport = BaseDriver.andriod_driver().to_mine_sport_page() # else: # pass self.logInfo = LogInfo() @allure.story("我的运动今日能量跳转测试") @allure.severity("block") @pytest.mark.smoke @pytest.mark.sportNormal def test_today_energy(self): """ 测试我的运动今日能量跳转 :return: 跳转前后数据一致即为通过 """ get_today_energy = self.today_energy.get_energy_main() self.today_energy.to_energy_page() get_active_energy = self.today_energy.get_energy_page_value() self.today_energy.save_screenshots("今日运动今日能量截图") self.logInfo.logEnd("今日运动今日能量日志") assert get_active_energy == get_today_energy @allure.story("我的能量周统计测试") @pytest.mark.smoke def test_week_energy(self): """ 测试每周平均消耗活动能量 :return: 获取特殊字符"-"成功,即为通过 """ self.today_energy.to_energy_page() time.sleep(1) self.today_energy.click_week_energy_btn() get_week_energy = self.today_energy.get_week_and_month_energy_time() self.today_energy.save_screenshots("今日运动每周平均消耗能量截图") self.logInfo.logEnd("今日运动每周平均消耗能量能量日志") assert "-" in get_week_energy @allure.story("我的能量月统计测试") @pytest.mark.smoke def test_month_energy(self): """ 测试每月平均消耗活动能量 :return: """ self.today_energy.to_energy_page() time.sleep(1) self.today_energy.click_month_energy_btn() get_month_energy = self.today_energy.get_week_and_month_energy_time() self.today_energy.save_screenshots("今日运动每月平均消耗能量截图") self.logInfo.logEnd("今日运动每月平均消耗能量能量日志") assert "日" not in get_month_energy @classmethod def teardown_class(cls): cls.today_energy.click_back_by_native(type="left_btn") cls.today_energy.driver.quit()
class TestOtherCountryUser: """ 测试非大陆用户或非简体中文用户登录后tab展示 """ @classmethod def setup_class(cls): cls.foreign = BaseDriver.andriod_driver().to_other_country_workout_tab( ) def setup(self): # foreign_icon = self.foreign.get_foreign_workout_icon() # if foreign_icon is None: # self.foreign = BaseDriver.andriod_driver().to_other_country_workout_tab() # else: # pass self.logInfo = LogInfo() @pytest.mark.skip #需要测试时开启 @allure.story("非大陆账号登录后tab数量和名称测试") @allure.severity('Normal') # @pytest.mark.smoke @pytest.mark.parametrize( "username, password", [("*****@*****.**", "huami001") # ("13522028106", "529614wwy"), # ("13269115357", "Zx13269115357") ]) def test_not_chinese_account(self, username, password): """ 测试非大陆账号登录后展示tab数量和tab名称 :return:无社区tab和发现tab且有friends tab 即为通过 """ judge_not_chinese_account_login = self.foreign.judge_not_chinese_account_if_login( ) if judge_not_chinese_account_login is not None: self.foreign.click_to_not_chinese_mine_page() self.foreign.swipe_to_settings_element() self.foreign.click_settings_btn() self.foreign.click_logout_btn() self.foreign.click_confirm_exit_account() self.foreign.click_confirm_exit() self.foreign.login_by_phone(username, password) judge_xiaomi_account = self.foreign.get_judge_xiaomi_account() if judge_xiaomi_account is not None: self.foreign.click_not_xiaomi_account_login else: pass else: self.foreign.login_by_phone(username, password) judge_xiaomi_account = self.foreign.get_judge_xiaomi_account() if judge_xiaomi_account is not None: self.foreign.click_not_xiaomi_account_login else: pass judge_if_have_band = self.foreign.judge_if_have_not_band() if judge_if_have_band is not None: self.foreign.click_not_have_band_got_it() else: pass isSuccess = self.foreign.get_not_chinese_account_sports_icon() self.foreign.save_screenshots("登录截图") self.logInfo.logEnd("登录日志") not_chinese_account_sports = self.foreign.get_not_chinese_account_sports_icon( ) not_chinese_account_friends = self.foreign.get_not_chinese_account_friends_icon( ) not_chinese_account_mine = self.foreign.get_not_chinese_account_mine_icon( ) self.foreign.click_to_not_chinese_mine_page() self.foreign.swipe_to_settings_element() self.foreign.click_settings_btn() self.foreign.click_logout_btn() self.foreign.click_confirm_exit_account() self.foreign.click_confirm_exit() time.sleep(5) assert not_chinese_account_sports is not None and \ not_chinese_account_friends is not None and not_chinese_account_mine is not None \ and isSuccess is not None @pytest.mark.parametrize( "username, password", [("13146085375", "huami001") # ("13522028106", "529614wwy"), # ("13269115357", "Zx13269115357") ]) @allure.story("大陆账号登录后tab数量和名称测试") @allure.severity('Normal') @pytest.mark.smoke @pytest.mark.skip #需要测试时开启 def test_chinese_account(self, username, password): """ 测试大陆账号登录后展示tab数量和tab名称 :return:有社区tab和发现tab即为通过 """ judge_login = self.foreign.judge_chinese_account_if_login() if judge_login is not None: self.foreign.click_to_mine_tab() self.foreign.swipe_to_settings_element() self.foreign.click_settings_btn() self.foreign.click_logout_btn() self.foreign.click_confirm_exit_account() self.foreign.click_confirm_exit() self.foreign.login_by_phone(username, password) judge_xiaomi_account = self.foreign.get_judge_xiaomi_account() if judge_xiaomi_account is not None: self.foreign.click_not_xiaomi_account_login else: pass else: self.foreign.login_by_phone(username, password) judge_xiaomi_account = self.foreign.get_judge_xiaomi_account() if judge_xiaomi_account is not None: self.foreign.click_not_xiaomi_account_login else: pass time.sleep(5) get_chinese_account_login_sports_tab = self.foreign.get_discover_tab() not_chinese_account_friends = self.foreign.get_not_chinese_account_friends_icon( ) assert get_chinese_account_login_sports_tab is not None and \ not_chinese_account_friends is None def teardown(self): self.foreign.driver.quit()
class TestMySports: """ 运动模块-我的运动测试 """ @classmethod def setup_class(cls): cls.my_sports = BaseDriver.andriod_driver().to_my_sports_page() def setup(self): my_sports_icon = self.my_sports.get_my_sports_icon() if my_sports_icon is None: self.my_sports = BaseDriver.andriod_driver().to_my_sports_page() else: pass self.logInfo = LogInfo() @allure.story("今日运动列表-列表展示页面测试") @pytest.mark.smoke def test_my_sports_show(self): """ 运动模块-我的运动列表展示 :return:列表内展示:今日步数、今日运动、今日能量、连续达标 """ get_today_steps_icon = self.my_sports.get_my_sports_icon() get_today_sports_icon = self.my_sports.get_before_today_steps_miles() get_today_energy_icon = self.my_sports.get_before_today_energy() self.my_sports.swipe_on(direction="up_middle") get_today_goal_icon = self.my_sports.get_before_goal() assert get_today_steps_icon is not None and get_today_sports_icon is not None \ and get_today_energy_icon is not None and get_today_goal_icon is not None self.my_sports.save_screenshots("查看运动-我的运动-页面截图") self.logInfo.logEnd("查看运动-我的运动-页面日志") @allure.story("今日运动列表-运动距离和步数跳转页面测试") @pytest.mark.smoke def test_today_steps_value(self): """ 测试-运动模块-我的运动-今日步数-运动距离 :return: 步数展示-距离展示-今日展示 """ self.my_sports.swipe_on(direction="down") get_before_today_steps = self.my_sports.get_before_today_steps() get_before_today_steps = get_before_today_steps.split(' ')[1] get_before_today_steps_distance = self.my_sports.get_before_today_steps_miles( ) get_before_today_steps_distance = get_before_today_steps_distance.split( "步数运动距离")[1] self.my_sports.click_to_today_steps_page() get_after_today_steps = self.my_sports.get_after_today_steps() get_after_today_distance = self.my_sports.get_after_today_steps_distance( ) get_after_today_distance = get_after_today_distance.split("距离")[1] get_after_today_carol = self.my_sports.get_after_today_steps_carol() print(get_after_today_distance, get_before_today_steps_distance) self.my_sports.save_screenshots("查看运动-我的运动-今日步数页面截图") self.logInfo.logEnd("查看运动-我的运动-今日步数页面日志") self.my_sports.click_back_by_native(type="left_btn") if get_after_today_carol is not None: assert get_before_today_steps in get_after_today_steps @allure.story("今日运动列表-我的运动跳转页面测试") @pytest.mark.smoke def test_today_my_steps(self): """ 测试运动模块-我的运动-今日步数进入前与进入后步数数值 :return: 一致即为通过 """ get_before_today_steps = self.my_sports.get_before_today_steps() get_before_today_steps = get_before_today_steps.split(' ')[1] self.my_sports.click_to_today_steps_page() get_after_today_steps = self.my_sports.get_after_today_steps() print(get_before_today_steps) print(get_after_today_steps) self.my_sports.save_screenshots("查看运动-我的运动-今日步数截图") self.logInfo.logEnd("查看运动-我的运动-今日步数日志") self.my_sports.click_back_by_native(type="left_btn") assert get_before_today_steps in get_after_today_steps @allure.story("今日运动列表-今日运动跳转页面测试") @pytest.mark.smoke def test_today_sports(self): """ 测试运动模块-我的运动-今日运动进入前与进入后运动公里 :return:前后数值一致则为通过 """ get_before_today_sports_miles = self.my_sports.get_before_today_sports_miles( ) get_before_today_sports_miles = get_before_today_sports_miles.split( "分")[1] self.my_sports.click_to_today_sports_miles_page() self.my_sports.click_count_by_week() get_after_today_sports_miles = self.my_sports.get_after_today_sports_miles( ) self.my_sports.save_screenshots("查看运动-我的运动-今日运动截图") self.logInfo.logEnd("查看运动-我的运动-今日运动日志") self.my_sports.click_back_by_native(type="left_btn") assert get_after_today_sports_miles in get_before_today_sports_miles @allure.story("今日运动列表-今日能量跳转页面测试") @pytest.mark.smoke def test_today_energy(self): """ 测试运动模块-我的运动-今日能量进入前与进入后能量数值 :return:前后数值一致则为通过 """ get_before_today_energy = self.my_sports.get_before_today_energy() self.my_sports.click_to_today_energy_page() get_after_today_energy = self.my_sports.get_after_today_energy() self.my_sports.save_screenshots("查看运动-我的运动-今日能量截图") self.logInfo.logEnd("查看运动-我的运动-今日能量日志") self.my_sports.click_back_by_native(type="left_btn") assert get_after_today_energy in get_before_today_energy @allure.story("今日运动列-今日跳转页面测试") @pytest.mark.smoke def test_today_goal(self): """ 测试运动模块-我的运动-今日达标进入前与进入后能量数值 :return:前后数值一致则为通过 """ self.my_sports.swipe_on(direction="up") get_before_goal_value = self.my_sports.get_before_goal() get_before_goal_value = get_before_goal_value.split(" ")[1] self.my_sports.click_to_goal_page() get_after_goal_value = self.my_sports.get_after_goal() self.my_sports.save_screenshots("查看运动-我的运动-今日达标截图") self.logInfo.logEnd("查看运动-我的运动-今日达标日志") self.my_sports.click_goal_back_to_my_sports assert get_before_goal_value in get_after_goal_value @classmethod def teardown_class(cls): cls.my_sports.driver.quit()
class TestUserInfoCase: @classmethod def setup_class(cls): cls.user_info = BaseDriver.andriod_driver().to_mine_user_page() # cls.logInfo = LogInfo() def setup(self): # print ("这是用户信息类") # self.user_info.get_device_state_custom() nick_name_icon = self.user_info.get_nick_name_value() if nick_name_icon is None: self.user_info = BaseDriver.andriod_driver().to_mine_user_page() else: pass self.logInfo = LogInfo() @pytest.mark.todisplay @allure.story("修改昵称功能测试") @allure.severity('Blocker') @allure.issue('http://www.baidu.com', "问题") @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.mineNormal @pytest.mark.smoke @pytest.mark.parametrize("username", [ "username1", "username2", "username3" ]) def test_edit_nick_name(self, username): ''' 修改用户昵称 :return:是否成功修改昵称 ''' nick_name_before = self.user_info.get_nick_name_value() self.user_info.to_edit_nick_name() # self.user_info.nick_name_send_keys(nick_name_before + "1") self.user_info.nick_name_send_keys(username) self.user_info.click_save_btn() nick_name_middle = self.user_info.get_nick_name_value() self.user_info.save_screenshots("修改昵称截图") self.logInfo.logEnd("修改昵称日志") assert nick_name_before != nick_name_middle @pytest.mark.todisplay @allure.story("修改性别功能测试") @allure.severity('Blocker') @allure.issue('http://www.baidu.com', "问题") @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.mineNormal @pytest.mark.smoke def test_edit_sex(self): ''' 修改用户性别 :return:是否成功修改性别 ''' sex_value = self.user_info.get_sex_value() self.user_info.to_edit_sex() if sex_value == '男': self.user_info.chose_female_btn() else: self.user_info.chose_male_btn() sex_value_after = self.user_info.get_sex_value() self.user_info.save_screenshots("修改性别截图") self.logInfo.logEnd("修改性别日志") assert sex_value != sex_value_after @pytest.mark.todisplay @allure.story("修改身高功能测试") @allure.severity('Blocker') @allure.issue('http://www.baidu.com', "问题") @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.mineNormal def test_edit_height(self): ''' 修改用户身高 :return:是否成功修改身高 ''' height_value = self.user_info.get_height_value() self.user_info.to_edit_height() self.user_info.swipe_on('up') time.sleep(2) self.user_info.save_height() height_value_after = self.user_info.get_height_value() self.user_info.save_screenshots("修改身高截图") self.logInfo.logEnd("修改身高日志") assert height_value != height_value_after @allure.story("编辑个人简介功能测试") @allure.severity('Blocker') @allure.issue('http://www.baidu.com', "问题") @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.mineNormal @pytest.mark.smoke def test_edit_brief(self): ''' 修改个人简介 :return:是否成功修改个人简介 ''' brief_content = self.user_info.get_brief() self.user_info.to_edit_brief_page() self.user_info.edit_brief(brief_content + "1") self.user_info.save_brief() brief_content_after = self.user_info.get_brief() self.user_info.save_screenshots("修改个人简介截图") self.logInfo.logEnd("修改个人简介日志") assert brief_content != brief_content_after # @pytest.mark.smoke # def test_edit_photo(self): # ''' # 修改个人头像 # :return:是否成功修改后成功返回个人信息页面 # ''' # before_photo_element = self.user_info.get_image_element() # self.user_info.to_image_page() # self.user_info.click_local_photo() # self.user_info.click_select_photo() # self.user_info.confirm_photo() # after_photo_element = self.user_info.get_image_element() # self.user_info.save_screenshots("修改个人照片截图") # self.logInfo.logEnd("修改个人照片日志") # assert before_photo_element is not None and\ # after_photo_element is not None ''' 选择相片是系统控件 无法操作 ''' @classmethod def teardown_class(cls): # cls.user_info.click_back_by_native(type='left') cls.user_info.driver.quit()
class TestCommunityPost: @classmethod def setup_class(cls): cls.community_post = BaseDriver.andriod_driver().to_community_tab() # cls.logInfo = LogInfo() def setup(self): # print ("这是用户类") # self.user_page.get_device_state_custom() # community_icon = self.community_post.get_community_icon() # if community_icon is None: # self.community_post = BaseDriver.andriod_driver().to_community_tab() # else: # pass self.logInfo = LogInfo() @pytest.mark.todisplay @pytest.mark.smoke def test_publish_post(self): """ 测试社区发帖功能 :return: 获取的成功发布toast即为通过 """ self.community_post.to_publish_post() judge_have_diary_auth = self.community_post.judge_have_diary_authority( ) if judge_have_diary_auth is not None: self.community_post.to_select_post_btn() self.community_post.to_select_photo_btn() self.community_post.click_next_btn() self.community_post.click_next_step() self.community_post.click_and_input_post_content() self.community_post.click_publish_btn() get_toast = self.community_post.find_publish_success_toast() self.community_post.save_screenshots("社区tab发布帖子功能截图") self.logInfo.logEnd("社区tab发布帖子功能日志") assert get_toast == '发布成功' else: self.community_post.to_select_photo_btn() self.community_post.click_next_btn() self.community_post.click_next_step() self.community_post.click_and_input_post_content() self.community_post.click_publish_btn() get_toast = self.community_post.find_publish_success_toast() self.community_post.save_screenshots("社区tab发布帖子功能截图") self.logInfo.logEnd("社区tab发布帖子功能日志") assert get_toast == '发布成功' @pytest.mark.smoke def test_like_post(self): """ 测试对社区帖子进行点赞 :return:若帖子点赞数为0则点赞后数量为1,若>0,则点赞后结果加一,或取消点赞,结果减一 """ self.community_post.to_search_user_by_id() self.community_post.click_search_box() self.community_post.click_search_box() self.community_post.click_search_history() self.community_post.click_user_tab() self.community_post.click_to_user_page() self.community_post.click_to_post_content() before_press_like_btn = self.community_post.get_like_btn_value() if before_press_like_btn == "点赞": self.community_post.click_like_btn() after_press_like_btn = self.community_post.get_like_btn_value() self.community_post.save_screenshots("社区tab帖子点赞功能截图") self.logInfo.logEnd("社区tab帖子点赞功能日志") assert after_press_like_btn == '1' else: before_press_like_btn = int(before_press_like_btn) self.community_post.save_screenshots("社区tab帖子点赞功能截图") self.logInfo.logEnd("社区tab帖子点赞功能日志") self.community_post.click_like_btn() after_press_like_btn = int( self.community_post.get_like_btn_value()) assert after_press_like_btn == before_press_like_btn + 1 \ or after_press_like_btn == before_press_like_btn - 1 @pytest.mark.smoke def test_comment_post(self): """ 测试对帖子评论功能 :return:帖子评论数为0时,评论后返回结果为1,或当前评论数>1时,返回结果为评论数+1即为通过 """ self.community_post.to_search_user_by_id() self.community_post.click_search_box() self.community_post.click_search_box() self.community_post.click_search_history() self.community_post.click_user_tab() self.community_post.click_to_user_page() self.community_post.click_to_post_content() before_comment_value = self.community_post.get_comment_value() if before_comment_value == "评论": self.community_post.click_to_comment_page() self.community_post.edit_comment() self.community_post.press_comment_btn() after_comment_value = self.community_post.get_comment_value() self.community_post.save_screenshots("社区tab帖子评论功能截图") self.logInfo.logEnd("社区tab帖子评论功能日志") assert after_comment_value == '1' else: before_comment_value = int(before_comment_value) self.community_post.click_to_comment_page() self.community_post.edit_comment() self.community_post.press_comment_btn() after_comment_value = int(self.community_post.get_comment_value()) assert after_comment_value == before_comment_value + 1 @pytest.mark.smoke def test_delete_post(self): """ 测试社区删帖功能 :return:删帖前当前帖子发布者名称与删帖后贴子发布者名称不同即为pass """ self.community_post.to_search_user_by_id() self.community_post.click_search_box() self.community_post.click_search_box() self.community_post.click_search_history() self.community_post.click_user_tab() self.community_post.click_to_user_page() self.community_post.click_to_post_content() now_publisher_name = self.community_post.get_publisher_name() self.community_post.click_share_btn() self.community_post.click_delete_btn() self.community_post.click_confirm_delete_btn() after_publisher_name = self.community_post.get_publisher_name() self.community_post.save_screenshots("社区tab帖子删除功能截图") self.logInfo.logEnd("社区tab帖子删除功能日志") assert now_publisher_name != after_publisher_name @classmethod def teardown_class(cls): cls.community_post.driver.quit()
class TestUserCase: @classmethod def setup_class(cls): cls.user_page = BaseDriver.andriod_driver().to_mine_page_user() # cls.logInfo = LogInfo() def setup(self): # print ("这是用户类") # self.user_page.get_device_state_custom() add_device_icon = self.user_page.get_add_device_icon() if add_device_icon is None: self.user_page = BaseDriver.andriod_driver().to_mine_page_user() else: pass self.logInfo = LogInfo() @allure.story("健康周报功能测试") @allure.severity('Trivial') @allure.issue('http://www.baidu.com', '问题6') @allure.testcase('http://www.sina.com', '测试用例6') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_mine_report(self): """ 查看健康周报 :return: 是否成功查看健康周报页面 """ self.user_page.to_mine_report() title = self.user_page.get_title() self.user_page.save_screenshots("查看健康周报截图") self.logInfo.logEnd("查看健康周报日志") self.user_page.click_back_by_native(type='left') assert title == "健康周报" @allure.story("设置步数功能测试") @allure.severity('blocker') @allure.issue("http://www.baidu.com", '问题7') @allure.testcase("http://www.sina.com", '测试用例7') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_set_steps_goal(self): """ 设置步数 :return: 是否成功设置步数 """ self.user_page.swipe_on('up') steps_before = self.user_page.get_steps_goal() self.user_page.set_goal() self.user_page.set_steps_goal() time.sleep(2) # blue_tooth_tip = self.user_page.get_blue_tooth_tip() steps_tip = self.user_page.get_steps_tip() while steps_tip is None: time.sleep(3) # blue_tooth_tip = self.user_page.get_blue_tooth_tip() steps_tip = self.user_page.get_steps_tip() time.sleep(5) self.user_page.swipe_on('up_middle') self.user_page.set_steps_goal_confirm() steps_after = self.user_page.get_steps_goal() self.user_page.save_screenshots("修改步数截图") self.logInfo.logEnd("修改步数日志") assert steps_before != steps_after @allure.story("查看订单功能测试") @allure.severity('blocker') @allure.issue("http://www.baidu.com", '问题9') @allure.testcase("http://www.sina.com", '测试用例9') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_order_page(self): """ 查看订单功能 :return: 查看订单功能是否正常 """ self.user_page.swipe_on('up') self.user_page.to_order_page() title = self.user_page.get_title() self.user_page.save_screenshots("查看订单截图") self.logInfo.logEnd("查看订单日志") self.user_page.click_back_by_native(type='left') assert title == "我的订单" @allure.story("查看行为标注功能测试") @allure.severity('blocker') @allure.issue("http://www.baidu.com", '问题10') @allure.testcase("http://www.sina.com", '测试用例10') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_behavior_page(self): """ 查看行为标注功能 :return: 查看行为标注是否正常 """ self.user_page.swipe_on('up') self.user_page.to_behavior_page() title = self.user_page.get_title() self.user_page.save_screenshots("查看行为标注截图") self.logInfo.logEnd("查看行为标注日志") self.user_page.click_back_by_native(type='left') assert title == "行为标注" @allure.story("查看第三方接入功能测试") @allure.severity('blocker') @allure.issue("http://www.baidu.com", '问题11') @allure.testcase("http://www.sina.com", '测试用例11') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_third_page(self): """ 查看第三方接入功能 :return: 查看第三方接入功能是否正常 """ self.user_page.swipe_on('up') self.user_page.to_third() title = self.user_page.get_title() self.user_page.save_screenshots("查看第三方接入截图") self.logInfo.logEnd("查看第三方接入日志") self.user_page.click_back_by_native(type='left') assert title == "第三方接入" @allure.story("提交意见反馈功能测试") @allure.severity('blocker') @allure.issue("http://www.baidu.com", '问题12') @allure.testcase("http://www.sina.com", '测试用例12') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_feed_back(self): """ 提交意见反馈功能 :return: 提交意见反馈功能是否正常 """ self.user_page.swipe_on('up') self.user_page.to_feed_back_page() self.user_page.feed_back_send_keys("测试") self.user_page.save_screenshots("提交意见反馈截图") self.user_page.to_submit() toast = self.user_page.get_toast("提交成功") # print("文案为:" + toast) self.logInfo.logEnd("提交意见反馈日志") assert toast is not None #现版本里没有此选项,4.0.19版本里恢复此功能 @allure.story("查看账号与安全功能测试") @allure.severity('blocker') @allure.issue("http://www.baidu.com", '问题13') @allure.testcase("http://www.sina.com", '测试用例13') @pytest.mark.smoke @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_setting_account(self): """ 查看账号与安全 :return: 查看账号与安全是否正常 """ self.user_page.swipe_on('up') self.user_page.to_setting_page() self.user_page.to_account_page() time.sleep(1) title = self.user_page.get_title() self.user_page.save_screenshots("查看账号与安全截图") self.logInfo.logEnd("查看账号与安全日志") self.user_page.click_back_by_native(type='left') self.user_page.click_back_by_native(type='left') assert title == "账号与安全" @allure.story("查看单位功能测试") @allure.severity('blocker') @allure.issue("http://www.baidu.com", '问题14') @allure.testcase("http://www.sina.com", '测试用例14') #@pytest.mark.smoke #查找不到unit元素 @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_unit(self): """ 查看单位 :return:查看单位是否正常 """ # self.user_page.swipe_on('up') self.user_page.to_setting_page() self.user_page.to_unit_page() time.sleep(2) title = self.user_page.get_title() self.user_page.save_screenshots("查看单位截图") self.logInfo.logEnd("查看单位日志") self.user_page.click_back_by_native(type='left') self.user_page.click_back_by_native(type='left') assert title == "单位" @allure.story("改变在通知栏显示连接状态功能测试") @allure.severity('blocker') @allure.issue("http://www.baidu.com", '问题15') @allure.testcase("http://www.sina.com", '测试用例15') # @pytest.mark.smoke #无法执行 @pytest.mark.release @pytest.mark.core @pytest.mark.mineP0 def test_notification_connect_switch(self): """ 改变在通知栏显示连接状态 :return: 改变在通知栏显示连接状态是否成功 """ # self.user_page.swipe_on('up') self.user_page.to_setting_page() time.sleep(3) status = self.user_page.get_switch_status() time.sleep(1) self.user_page.change_switch() time.sleep(1) self.user_page.save_screenshots("改变在通知栏显示连接状态截图") self.logInfo.logEnd("改变在通知栏显示连接状态日志") if status == 'true': assert self.user_page.get_switch_status() == 'false' else: assert self.user_page.get_switch_status() == 'true' @classmethod def teardown_class(cls): cls.user_page.driver.quit()
class TestCollectCase: @classmethod def setup_class(cls): cls.collect = BaseDriver.andriod_driver().to_mine_collect_page() # cls.logInfo = LogInfo() def setup(self): my_collect_icon = self.collect.get_course_tab() if my_collect_icon is None: self.collect = BaseDriver.andriod_driver().to_mine_collect_page() else: pass self.logInfo = LogInfo() @allure.story("我的收藏-帖子tab下帖子详情页测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.core @pytest.mark.release @pytest.mark.mineP0 def test_collect_post_page(self): """ 跳转帖子tab下帖子详情页 :return: 是否成功跳转到帖子详情页面 """ time.sleep(3) first_name = self.collect.get_first_post_name() self.collect.to_first_post_page() second_name = self.collect.get_publisher_name() self.collect.save_screenshots("查看跳转帖子tab下帖子详情页截图") self.logInfo.logEnd("查看帖子tab下帖子详情页日志") self.collect.click_back_by_native() assert first_name == second_name @allure.story("我的收藏-课程tab下课程详情页测试") @allure.severity('critical') @allure.issue('http://www.baidu.com', '问题') @allure.testcase('http://www.sina.com', '测试用例') @pytest.mark.smoke @pytest.mark.core @pytest.mark.release @pytest.mark.mineP0 def test_collect_course_page(self): """ 跳转课程tab下课程详情页 :return: 是否成功跳转到课程详情页面 """ time.sleep(5) self.collect.to_course_tab() first_name = self.collect.get_first_course_name() self.collect.to_first_course_page() second_name = self.collect.get_course_name() self.collect.save_screenshots("查看跳转课程tab下课程详情页截图") self.logInfo.logEnd("查看课程tab下课程详情页日志") self.collect.click_back_by_native() assert first_name == second_name @classmethod def teardown_class(cls): cls.collect.click_back_by_native(type='left') cls.collect.driver.quit()