class TestEditCreate(object): """edit创建视频的测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_create_craft(self): """创建一个草稿视频.""" sc.logger.info('创建一个草稿视频') fun_name = 'test_create_craft' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“剪辑”按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon1').click() el_video_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/img_click_mask') for i in range(3): el_video_list[i].click() sc.logger.info('点击“添加”按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_import').click() try: WebDriverWait(sc.driver, 60).until( lambda V_improt: V_improt. find_element_by_android_uiautomator('text("下一步")')) sc.logger.info('点击“下一步”按钮') except TimeoutError as t: sc.logger.error('导入视频超时', t) return False except Exception as e: sc.logger.error('导入视频出错', e) return False sc.logger.info('点击“视频”按钮') sc.driver.find_element_by_android_uiautomator('text("视频")').click() sc.logger.info('点击“图片”按钮') sc.driver.find_element_by_android_uiautomator('text("图片")').click() sc.find_by_ids('com.quvideo.xiaoying:id/img_icon', fun_name, self.img_path) sc.logger.info('点击“下一步”按钮') sc.driver.find_element_by_android_uiautomator('text("下一步")').click() sc.logger.info('点击“存草稿”按钮') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.logger.info('返回创作中心主界面') sc.driver.press_keycode(4) sc.logger.info('创建一个草稿视频完成')
class TestEditFilter(object): """编辑滤镜的基本操作测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_edit_filter(self): """剪辑-滤镜.""" sc.logger.info('剪辑-滤镜') fun_name = 'test_edit_filter' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() el_edit_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '滤镜': sc.logger.info('开始点击“滤镜”按钮') el_item.click() break sc.logger.info('点击“下载更多”按钮') el_filter_use = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/ImageView_Content_Thumbnail') el_filter_use.click() time.sleep(1) sc.logger.info('点击左上角返回按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_back').click() sc.logger.info('点击右上角确认按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-滤镜测试完成')
class TestCameraSelf(object): """camera美颜趣拍的测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_camera_self(self): """拍摄-自拍视频(1:1).""" sc.logger.info('拍摄-美颜趣拍(1:1)') fun_name = 'test_camera_self' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“美颜趣拍”') sc.driver.find_element_by_android_uiautomator('text("美颜趣拍")').click() sc.logger.info('点击摄像头反转按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_switch').click() sc.capture_screen(fun_name, self.img_path) el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍5s sc.logger.info('点击录制按钮') el_capture.click() time.sleep(5) sc.logger.info('拍摄5s后点击录制按钮停止拍摄') el_capture.click() sc.logger.info('点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.logger.info('美颜趣拍测试完成,点击返回按钮返回主页面') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('拍摄-美颜趣拍拍摄完成')
class TestCircleSearch(object): """小影圈搜索页的测试类,分步截图.""" width, heigh = sc.get_size() def test_search_page(self): """小影圈搜索页面输入状态测试.""" start_x = self.width // 2 start_bottom = self.heigh - self.heigh // 8 sc.logger.info('小影圈搜索页面输入状态测试开始') time.sleep(2) sc.logger.info('开始查找小影圈按钮') el_cicle = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_find') el_cicle.click() time.sleep(.500) sc.logger.info('开始查找小影圈搜索按钮') el_search_btn = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_search') el_search_btn.click() time.sleep(1) sc.logger.info('开始向小影圈搜索框输入字符a') el_search_edit = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/edittext_search') el_search_edit.click() sc.driver.press_keycode(29) time.sleep(.500) sc.logger.info('开始查找输入框补全内容') el_search_sup = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/textview_keyword') sc.logger.info('小影圈搜索框输入文字"a"截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) sc.logger.info('点击第一条自动联想内容') el_search_sup.click() time.sleep(2) sc.logger.info('开始查找搜索结果中的用户') res_user_id = 'com.quvideo.xiaoying:id/img_simple_user_avatar_click' el_res_user = sc.driver.find_element_by_id(res_user_id) sc.logger.info('开始查找搜索结果中的视频') res_video_id = 'com.quvideo.xiaoying:id/xiaoying_com_img_video_thumb' el_res_video = sc.driver.find_element_by_id(res_video_id) sc.logger.info('小影圈搜索结果截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.7, 300) sc.logger.info('小影圈搜索结果下滑截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert el_res_user and el_res_video is not None def test_search_result(self): """小影圈搜索结果测试,为了简化流程,请与上一条连起来用.""" sc.logger.info('小影圈搜索结果测试开始') start_x = self.width - self.width // 4 start_bottom = self.heigh - self.heigh // 8 # 左滑一次 sc.logger.info('开始左滑至“视频”页面') time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.7, 300) time.sleep(.500) sc.logger.info('开始查找搜索结果视频页面中的视频') res_video_id = 'com.quvideo.xiaoying:id/xiaoying_com_img_video_thumb' el_res_videos = sc.driver.find_element_by_id(res_video_id) sc.logger.info('小影圈搜索结果视频页面截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.3, 300) time.sleep(.500) sc.logger.info('小影圈搜索结果视频页面下滑截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # 再左滑一次 sc.logger.info('开始滑动至“用户”页面') sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.7, 300) time.sleep(.500) sc.logger.info('开始查找搜索结果用户页面中的第一个用户') res_user_id = 'com.quvideo.xiaoying:id/fans_name' el_res_users = sc.driver.find_element_by_id(res_user_id) sc.logger.info('小影圈搜索结果用户页面截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.3, 300) sc.logger.info('小影圈搜索结果用户界面下滑截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert el_res_videos and el_res_users is not None def test_search_follow(self): """小影圈搜索结果中的关注测试,为了简化流程,请与上一条连起来用.""" sc.logger.info('小影圈搜索结果,关注测试开始') start_x = self.width // 4 start_bottom = self.heigh // 2 # 查找用户关注按钮 time.sleep(.500) sc.logger.info('开始查找搜索结果用户页面中的第一个用户关注按钮') sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.3, 300) el_fol_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/btn_follow_state') # sc.driver.find_element_by_android_uiautomator('new UiSelector().text("关注")') for el_res_fol in el_fol_list: if el_res_fol.text == '关注': sc.logger.info('开始点击关注') el_res_fol.click() break el_res_fol = sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("已关注")') sc.logger.info('小影圈搜索结果,用户页面关注情况截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # 取消关注 time.sleep(.500) sc.logger.info('开始取消关注') el_res_fol.click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/buttonDefaultPositive').click() el_res_fol = sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("关注")') sc.logger.info('小影圈搜索结果,用户页面取消关注后情况截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # 切换到视频页面 sc.logger.info('开始滑动至“视频”页面') sc.swipe_by_ratio(start_x, start_bottom, 'right', 0.7, 300) # 查找关注按钮 time.sleep(.500) sc.logger.info('开始查找搜索结果视频页面中的第一个关注按钮') el_follow = 'com.quvideo.xiaoying:id/btn_follow_state' while sc.driver.find_elements_by_id(el_follow) is None: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.3, 300) sc.driver.find_elements_by_id(el_follow) el_vf_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/btn_follow_state') fl_flag = True for el_res_vf in el_vf_list: if el_res_vf.text == '关注': sc.logger.info('开始点击关注') el_res_vf.click() fl_flag = True if el_res_vf.text == '已关注' else False break # el_res_vf = sc.driver.find_element_by_android_uiautomator('new UiSelector().text("已关注")') sc.logger.info('小影圈搜索结果,视频页面关注情况截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert el_res_fol and fl_flag is not None @staticmethod def test_search_history(): """小影圈搜索页面历史记录搜索测试,为了简化流程,请与上一条连起来用.""" sc.logger.info('小影圈搜索页面历史记录搜索测试开始') time.sleep(1) sc.logger.info('开始查找搜索框') el_search_edit = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/edittext_search') el_search_edit.click() sc.logger.info('开始查找清除输入按钮') el_search_edit = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_clear_edit') el_search_edit.click() time.sleep(.500) sc.logger.info('小影圈搜索框历史记录截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) sc.logger.info('开始查找第一条历史记录') res_his_id = 'com.quvideo.xiaoying:id/text_history_list_item' el_search_his = sc.driver.find_element_by_id(res_his_id) sc.logger.info('点击第一条历史记录') el_search_his.click() time.sleep(2) sc.logger.info('开始查找历史记录搜索结果中的视频') try: res_video_id = 'com.quvideo.xiaoying:id/xiaoying_com_img_video_thumb' el_res_video = sc.driver.find_element_by_id(res_video_id) except NoSuchElementException: res_video_desc = 'com.quvideo.xiaoying:id/xiaoying_com_text_video_desc' el_res_video = sc.driver.find_elements_by_id(res_video_desc) sc.logger.info('小影圈历史记录搜索结果截图') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) sc.logger.info('测试完成返回主页') sc.driver.press_keycode(4) assert el_res_video is not None
class TestPreviewTheme(object): """预览页面的theme测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_theme_ui(self): """预览页-切换到主题页面.""" sc.logger.info('预览页-切换到主题页面') fun_name = 'test_theme_ui' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon1').click() el_video = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_click_mask') el_video.click() sc.logger.info('点击“添加”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_import').click() try: WebDriverWait(sc.driver, 60).until( lambda V_improt: V_improt.find_element_by_android_uiautomator('text("下一步")')) except TimeoutError as t: sc.logger.error('导入视频超时', t) return False except Exception as e: sc.logger.error('导入视频出错', e) return False sc.logger.info('点击“下一步”') sc.driver.find_element_by_android_uiautomator('text("下一步")').click() sc.logger.info('点击“主题”按钮') sc.driver.find_element_by_android_uiautomator('text("主题")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('预览页-切换到主题页面') def test_theme_download(self): """预览页-主题下载.""" sc.logger.info('预览页-主题下载') start_x = self.width // 4 start_bottom = self.height - self.height // 10 sc.swipe_by_ratio(start_x, start_bottom, 'right', 0.5, 500) sc.logger.info('点击“下载更多”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgview_get_more_thumbnail_bg').click() time.sleep(1) try: el_theme_use = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/template_caption_grid_btn_update') sc.logger.info('点击“使用”按钮') el_theme_use.click() except NoSuchElementException: el_download_template = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_download') sc.logger.info('点击下载按钮') el_download_template.click() try: WebDriverWait(sc.driver, 30).until( lambda download_theme: download_theme.find_element_by_android_uiautomator('text("使用")')) sc.driver.find_element_by_android_uiautomator('text("使用")').click() except TimeoutError as t: sc.logger.error('素材下载超时', t) sc.logger.info('返回创作中心主界面') for i in range(4): sc.driver.press_keycode(4) return False except Exception as e: sc.logger.info('返回创作中心主界面') for i in range(4): sc.driver.press_keycode(4) sc.logger.error('素材下载失败', e) return False sc.logger.info('返回创作中心主界面') for i in range(3): sc.driver.press_keycode(4) sc.logger.info('预览页-主题测试完成')
class TestHome(object): """小影主页面的测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_home_minor(self): """首页-次要功能位检查.""" sc.logger.info('首页-次要功能位检查') fun_name = 'test_home_minor' time.sleep(5) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.view_by_ids('com.quvideo.xiaoying:id/sub_btn_icon', fun_name, self.img_path) time.sleep(2) start_x = self.width - self.width // 10 start_bottom = self.height // 2 sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.8, 500) sc.view_by_ids('com.quvideo.xiaoying:id/sub_btn_icon', fun_name, self.img_path) sc.logger.info('首页-次要功能位检查完毕') def test_home_other(self): """首页-小影百宝箱及其他.""" sc.logger.info('首页-推荐位-小影百宝箱及其他') fun_name = 'test_home_other' time.sleep(3) start_x = self.width // 2 start_bottom = self.height - self.height // 5 sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.7, 500) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/btn_vip').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_back').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_shuffle').click() sc.driver.press_keycode(4) el_ads_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/creation_item_img') # 跳转小影记广告位 for el_ad in el_ads_list: el_ad.click() time.sleep(3) sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) sc.logger.info('首页-推荐位-小影百宝箱及其他检查完毕') def test_home_studio(self): """首页-我的工作室.""" sc.logger.info('首页-我的工作室') fun_name = 'test_home_studio' time.sleep(3) start_x = self.width // 2 start_bottom = self.height // 5 sc.swipe_by_ratio(start_x, start_bottom, 'down', 0.6, 500) sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() time.sleep(1) try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() except NoSuchElementException: sc.logger.info('此草稿视频为拍摄视频,返回的是拍摄页面') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_cancel').click() el_publish = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_publish_btn') el_publish.click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_back').click() el_del_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_delete') el_del_draft.click() sc.driver.find_element_by_android_uiautomator('text("确认")').click() sc.driver.press_keycode(4) sc.logger.info('首页-我的工作室完成')
class TestPlanetExploreUI(object): """小影圈关注页UI的测试类,分步截图.""" width, heigh = sc.get_size() @staticmethod def test_planet_page(): """小影圈关注页面初始状态测试.""" sc.logger.info('小影圈关注页面初始状态检查开始') time.sleep(2) sc.logger.info('开始查找小影圈按钮') el_planet = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_find') el_planet.click() time.sleep(.500) sc.logger.info('开始查找小影圈关注tab') el_tab_list = sc.driver.find_elements_by_id('android:id/text1') for el_tab in el_tab_list: if el_tab.text == '关注': sc.logger.info('点击“关注”tab') el_tab.click() break sc.logger.info('小影圈关注页面初始状态截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert el_tab is not None def test_refresh(self): """测试下拉刷新.""" sc.logger.info('关注页面下拉刷新测试开始') start_x = self.width // 2 start_y = self.heigh // 8 result = sc.swipe_by_ratio(start_x, start_y, 'down', 0.6, 600) time.sleep(.300) sc.logger.info('小影圈关注页面下拉刷新截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert result is True def test_swipe_vertical(self): """测试上下方向的滑动.""" sc.logger.info('关注页面滑动测试开始') start_x = self.width // 2 start_y = self.heigh // 8 start_bottom = self.heigh - start_y # 先上滑 sc.logger.info('上滑截图开始') result_up = sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.7, 300) time.sleep(.300) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # 再下滑,同理 sc.logger.info('下滑截图开始') result_down = sc.swipe_by_ratio(start_x, start_y, 'down', 0.3, 300) time.sleep(.300) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert result_up and result_down is True def test_origin_home(self): """关注页tab的功能.""" sc.logger.info('关注页面tab功能检查测试开始') start_x = self.width // 2 start_bottom = self.heigh - self.heigh // 8 # 先上滑一点 result_up = sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.6, 500) time.sleep(.300) sc.logger.info('小影圈关注页面轻微上滑截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # 再按关注tab sc.logger.info('开始查找小影圈关注tab') el_tab_list = sc.driver.find_elements_by_id('android:id/text1') for el_tab in el_tab_list: if el_tab.text == '关注': sc.logger.info('点击“关注”tab') el_tab.click() break time.sleep(.300) sc.logger.info('小影圈关注页面点击“关注”tab截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert result_up and el_tab is not None
class TestEditSound(object): """配音的基本操作测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_edit_sound_add(self): """剪辑-配音-添加.""" sc.logger.info('剪辑-配音-添加') fun_name = 'test_edit_sound_add' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '配音': sc.logger.info('开始点击配音') el_item.click() break el_record = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/dub_panel_audio_record_btn') # 长按录制 sc.logger.info('长按拍摄5s') actions = TouchAction(sc.driver) actions.long_press(el_record, None, None, 5000).release().perform() sc.capture_screen(fun_name, self.img_path) """ x = record.location.get('x') y = record.location.get('y') sc.driver.swipe(x, y, x, y, 5000) """ sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_ve_imgbtn_add_audio_dub').click( ) time.sleep(2) el_audio_name = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/musiclist_title') el_audio_name.click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_add_music').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-配音-添加测试完成') def test_edit_sound_del(self): """剪辑-配音-删除.""" sc.logger.info('剪辑-配音-删除') fun_name = 'test_edit_sound_del' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '配音': sc.logger.info('开始点击配音') el_item.click() break sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_speed_close').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_del_dub').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-配音-删除测试完成') def test_edit_sound_cancel(self): """剪辑-配音-放弃.""" sc.logger.info('剪辑-配音-放弃') fun_name = 'test_edit_sound_cancel' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '配音': sc.logger.info('开始点击配音') el_item.click() break sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_ve_imgbtn_add_audio_dub').click( ) time.sleep(2) el_audio_name = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/musiclist_title') el_audio_name.click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_add_music').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.driver.find_element_by_android_uiautomator('text("确认")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-配音-放弃测试完成')
class TestCreationShare(object): """创作页面内分享相关的测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_share_create(self): """分享-创建视频.""" sc.logger.info('分享-创建视频') fun_name = 'test_share_create' time.sleep(1) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍 el_capture.click() time.sleep(5) el_capture.click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() sc.driver.find_element_by_android_uiautomator('text("保存/上传")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('分享-创建视频完成') def test_share_edit(self): """分享-编辑视频标题/话题相关.""" sc.logger.info('分享-编辑视频标题/话题相关') fun_name = 'test_share_edit' start_x = self.width // 2 start_bottom = self.height - self.height // 4 sc.logger.info('添加标题') el_title = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/share_video_title_text') el_title.clear() el_title.send_keys('video title test') sc.logger.info('添加话题') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/share_btn_add_topic').click() sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 500) el_tag = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/txtview_tag_name') el_tag.click() sc.capture_screen(fun_name, self.img_path) # 显示位置有点问题,后续再优化 """ sc.logger.info("显示位置") sc.driver.find_element_by_id("com.quvideo.xiaoying:id/txt_locating_tips").click() try: element = WebDriverWait(dr, 60).until( lambda local: local.find_element_by_id("com.quvideo.xiaoying:id/img_back")) sc.capture_screen(fun_name, self.img_path) loc_list = sc.driver.find_elements_by_id("com.quvideo.xiaoying:id/map_list_item_txt_title") for loc in loc_list: if loc.text == u'不显示位置': loc.click() except TimeoutError as t: sc.loggererror("加载位置超时", t) return False sc.capture_screen(fun_name, self.img_path) """ sc.logger.info('隐私设置') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/share_btn_privacy').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/private_setting_visible_btn').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/private_setting_candnload_btn').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/buttonDefaultPositive').click() sc.logger.info('导出-导出页编辑测试完成') def test_share_upload(self): """导出-分享上传.""" sc.logger.info('导出-分享上传') fun_name = 'test_share_upload' sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/share_btn_share').click() # sc.driver.find_element_by_id('com.quvideo.xiaoying:id/purchase_duration_limit_title').click() try: WebDriverWait( sc.driver, 300).until(lambda V_exprot: V_exprot.find_element_by_id( 'com.quvideo.xiaoying:id/textview_id_sns_qqspace')) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/textview_id_sns_qqspace').click() time.sleep(5) sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) except TimeoutError as t: sc.logger.error('导出视频超时', t) sc.driver.press_keycode(4) return False sc.logger.info('导出-分享上传完成')
class TestCreationTemplate(object): """创作页面素材中心测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] @classmethod def template_download(cls, type, download_id): """素材下载.""" sc.logger.info('%s下载测试', type) """ sc.logger.info('向下滑动') start_x = cls.width // 2 start_bottom = cls.height - cls.height // 5 while True: try: sc.driver.find_element_by_android_uiautomator('text("没有更多了…")').click() break except NoSuchElementException: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.6, 300) sc.logger.info('已经滑动到%s最底部了', type) """ sc.logger.info('开始下载') el_template_down = sc.driver.find_element_by_id(download_id) try: el_template_down.click() except NoSuchElementException: sc.logger.info('当前页面所有素材已下载完成') el_template_use = sc.driver.find_elements_by_android_uiautomator( 'text("使用")') el_template_use.click() return True sc.logger.info('检查素材下载是否成功') try: WebDriverWait( sc.driver, 30).until(lambda theme_use: theme_use. find_element_by_android_uiautomator('text("使用")')) except TimeoutError as t: sc.logger.info('素材下载超时', t) return False except Exception as e: sc.logger.info('素材下载失败', e) return False sc.logger.info('%s下载测试完成', type) @classmethod def template_use(cls, type): """使用素材并进入预览页测试.""" sc.logger.info('%s使用素材并进入预览页测试', type) time.sleep(1) fun_name = 'template_use' try: sc.logger.info('点击“使用”按钮') el_template_use = sc.driver.find_element_by_android_uiautomator( 'text("使用")') el_template_use.click() except NoSuchElementException: sc.logger.info('未找到已下载的素材') return False sc.capture_screen(fun_name, cls.img_path) el_videos = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/img_click_mask') for i in range(2): time.sleep(1) el_videos[i].click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_import').click() try: WebDriverWait(sc.driver, 60).until( lambda V_improt: V_improt. find_element_by_android_uiautomator('text("下一步")')) except TimeoutError as t: sc.logger.error('导入视频超时', t) return False except Exception as e: sc.logger.error('导入视频出错', e) return False sc.driver.find_element_by_android_uiautomator('text("下一步")').click() sc.logger.info('%s使用并进入预览页测试完成', type) @classmethod def theme_manager(cls, type, delete_id): """主题管理.""" sc.logger.info('%s删除测试', type) fun_name = 'theme_manager' sc.capture_screen(fun_name, cls.img_path) try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/text_right').click() except NoSuchElementException: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/right_mgr').click() sc.capture_screen(fun_name, cls.img_path) el_del_template = sc.driver.find_element_by_id(delete_id) el_del_template.click() try: sc.driver.find_element_by_android_uiautomator('text("确认")').click() except NoSuchElementException: sc.logger.info('%s删除不需要确认', type) sc.capture_screen(fun_name, cls.img_path) sc.logger.info('返回创作中心页面') for i in range(3): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('%s删除测试完成', type) def test_template_theme(self): """素材中心-主题.""" sc.logger.info('进入素材中心-主题') fun_name = 'test_template_theme' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“素材中心”') sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() sc.logger.info('点击“主题”') sc.driver.find_element_by_android_uiautomator('text("主题")').click() try: btn_download = 'com.quvideo.xiaoying:id/imgbtn_download' sc.driver.find_element_by_id(btn_download) self.template_download('主题', btn_download) except NoSuchElementException: sc.logger.info('此页素材已经下载完毕了') time.sleep(1) self.template_use('主题') time.sleep(5) sc.logger.info('点击“存草稿”') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.logger.info('点击左上角返回创作中心主界面') time.sleep(2) sc.driver.press_keycode(4) time.sleep(2) sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() sc.driver.find_element_by_android_uiautomator('text("主题")').click() sc.logger.info('删除刚刚下载的主题') sc.capture_screen(fun_name, self.img_path) self.theme_manager( '主题', 'com.quvideo.xiaoying:id/template_caption_grid_btn_update') def test_template_subtitle(self): """素材中心-字幕.""" sc.logger.info('素材中心-字幕') fun_name = 'test_template_subtitle' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“素材中心”') sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() sc.logger.info('点击“字幕”') sc.driver.find_element_by_android_uiautomator('text("字幕")').click() sc.logger.info('下载并使用字幕') try: btn_down = 'com.quvideo.xiaoying:id/template_pack_download_progress' sc.driver.find_element_by_id(btn_down) self.template_download('字幕', btn_down) sc.capture_screen(fun_name, self.img_path) except NoSuchElementException: sc.logger('字幕已经下载完毕了') self.template_use('字幕') time.sleep(5) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() time.sleep(1) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() time.sleep(2) sc.logger.info('点击“存草稿”') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() time.sleep(2) sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() sc.driver.find_element_by_android_uiautomator('text("字幕")').click() sc.logger.info('删除刚刚下载的字幕') sc.capture_screen(fun_name, self.img_path) self.theme_manager('字幕', 'com.quvideo.xiaoying:id/img_delete') def test_template_effect(self): """素材中心-特效.""" sc.logger.info('素材中心-特效') fun_name = 'test_template_effect' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“素材中心”') sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() sc.logger.info('点击“特效”') sc.driver.find_element_by_android_uiautomator('text("特效")').click() self.template_download( '特效', 'com.quvideo.xiaoying:id/template_pack_download_progress') self.template_use('特效') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() time.sleep(2) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() time.sleep(2) sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() time.sleep(2) sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() sc.driver.find_element_by_android_uiautomator('text("特效")').click() sc.logger.info('删除刚刚下载的特效') sc.capture_screen(fun_name, self.img_path) self.theme_manager( '特效', 'com.quvideo.xiaoying:id/template_caption_grid_btn_update') def test_template_filter(self): """素材中心-滤镜.""" sc.logger.info('素材中心-滤镜') fun_name = 'test_template_filter' start_x = self.width // 2 start_bottom = self.height - self.height // 5 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“素材中心”') sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() try: sc.logger.info('点击“滤镜”') sc.driver.find_element_by_android_uiautomator('text("滤镜")').click() except NoSuchElementException: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.6, 300) sc.driver.find_element_by_android_uiautomator('text("滤镜")').click() sc.logger.info('开始下载滤镜') try: el_template_down = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/template_filter_download') el_template_down.click() except NoSuchElementException: sc.logger.info('当前页面所有滤镜已下载完成') sc.logger.info('检查滤镜下载是否成功') try: WebDriverWait( sc.driver, 30).until(lambda use: use.find_element_by_android_uiautomator( 'text("使用")')) except TimeoutError as t: sc.logger.info('滤镜下载超时', t) return False except Exception as e: sc.logger.info('滤镜下载失败', e) return False sc.logger.info('滤镜下载测试完成') self.template_use('滤镜') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() time.sleep(1) sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() time.sleep(10) sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) time.sleep(2) sc.logger.info('删除刚刚下载的滤镜') sc.capture_screen(fun_name, self.img_path) self.theme_manager('滤镜', 'com.quvideo.xiaoying:id/img_delete') def test_template_sticker(self): """素材中心-动画贴纸.""" sc.logger.info('素材中心-动画贴纸') fun_name = 'test_template_sticker' start_x = self.width // 2 start_bottom = self.height - self.height // 4 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“素材中心”') sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) sc.logger.info('点击“动画贴纸”') sc.driver.find_element_by_android_uiautomator('text("动画贴纸")').click() self.template_download( '动画贴纸', 'com.quvideo.xiaoying:id/template_pack_download_progress') self.template_use('动画贴纸') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() time.sleep(1) sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) sc.driver.find_element_by_android_uiautomator('text("动画贴纸")').click() sc.logger.info('删除刚刚下载的动画贴纸') sc.capture_screen(fun_name, self.img_path) self.theme_manager('动画贴纸', 'com.quvideo.xiaoying:id/img_delete') # 目前code需要先下载至少一个转场,download控件无法获取到,需要再调试 def test_template_transition(self): """素材中心-转场.""" sc.logger.info('素材中心-转场') fun_name = 'test_template_transition' start_x = self.width // 2 start_bottom = self.height - self.height // 4 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“素材中心”') sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) time.sleep(1) sc.logger.info('点击“转场”') sc.driver.find_element_by_android_uiautomator('text("转场")').click() time.sleep(1) try: btn_download = 'com.quvideo.xiaoying:id/imgbtn_download' sc.driver.find_element_by_id(btn_download) self.template_download('转场', btn_download) except NoSuchElementException: sc.logger.info('当前页面素材已经全部下载完毕了') time.sleep(1) self.template_use('转场') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() time.sleep(1) sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) time.sleep(1) sc.driver.find_element_by_android_uiautomator('text("转场")').click() sc.logger.info('删除刚刚下载的转场') sc.capture_screen(fun_name, self.img_path) self.theme_manager( '转场', 'com.quvideo.xiaoying:id/template_caption_grid_btn_update') def test_template_font(self): """素材中心-字体.""" sc.logger.info('素材中心-字体') fun_name = 'test_template_font' start_x = self.width // 2 start_bottom = self.height - self.height // 4 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“素材中心”') sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) sc.logger.info('点击“字体”') sc.driver.find_element_by_android_uiautomator('text("字体")').click() sc.logger.info('开始下载字体') el_font_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/btn_download') try: el_font_list[0].click() except Exception: sc.logger.info('当前页面所有字体已下载完成') el_font_use = sc.driver.find_element_by_android_uiautomator( 'text("使用")') el_font_use.click() return True sc.logger.info('检查字体下载是否成功') try: WebDriverWait( sc.driver, 30).until(lambda use: use.find_element_by_android_uiautomator( 'text("使用")')) except TimeoutError as t: sc.logger.info('字体下载超时', t) return False except Exception as e: sc.logger.info('字体下载失败', e) return False sc.logger.info('字体下载测试完成') time.sleep(1) self.template_use('字体') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() time.sleep(1) sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) sc.driver.find_element_by_android_uiautomator('text("字体")').click() sc.logger.info('删除刚刚下载的字体') sc.capture_screen(fun_name, self.img_path) self.theme_manager('字体', 'com.quvideo.xiaoying:id/img_delete') def test_template_giphy(self): """GIPHY-下载.""" sc.logger.info('素材中心-GIPHY') fun_name = 'test_template_giphy' start_x = self.width // 2 start_bottom = self.height - self.height // 4 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“素材中心”') sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) sc.logger.info('点击“动画贴纸”') sc.driver.find_element_by_android_uiautomator('text("动画贴纸")').click() sc.logger.info('点击“GIPHY”') sc.driver.find_element_by_android_uiautomator('text("GIPHY")').click() time.sleep(5) sc.logger.info('开始下载GIPHY') try: el_template_down = sc.driver.find_elements_by_android_uiautomator( 'text("下载")') el_template_down.click() except Exception: sc.logger.info('当前页面所有GIPHY已下载完成') sc.logger.info('检查GIPHY下载是否成功') try: WebDriverWait( sc.driver, 30).until(lambda giphy_use: giphy_use. find_element_by_android_uiautomator('text("使用")')) el_template_use = sc.driver.find_elements_by_android_uiautomator( 'text("使用")') el_template_use.click() except TimeoutError as t: sc.logger.info('GIPHY下载超时', t) return False except Exception as e: sc.logger.info('GIPHY下载失败', e) return False sc.logger.info('GIPHY下载测试完成') self.template_use('GIPHY') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.logger.info('点击“存草稿”') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() time.sleep(1) sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_android_uiautomator('text("素材中心")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) sc.driver.find_element_by_android_uiautomator('text("动画贴纸")').click() sc.driver.find_element_by_android_uiautomator('text("GIPHY")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/right_button').click() time.sleep(1) sc.logger.info('删除刚刚下载的giphy') sc.capture_screen(fun_name, self.img_path) self.theme_manager('GIPHY', 'com.quvideo.xiaoying:id/text_delete')
class TestEditTransition(object): """转场的基本操作测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_edit_transition(self): """剪辑-转场-添加.""" sc.logger.info('剪辑-转场-添加') fun_name = 'test_edit_transition' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) time.sleep(1) el_edit_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '转场': sc.logger.info('开始点击转场') el_item.click() break el_cover_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/ImageView_Content_Thumbnail') el_cover_list[2].click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-转场-添加测试完成') def test_transition_cancel(self): """剪辑-转场-放弃.""" sc.logger.info('剪辑-转场-放弃') fun_name = 'test_transition_cancel' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) time.sleep(1) el_edit_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '转场': sc.logger.info('开始点击转场') el_item.click() break el_cover_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/ImageView_Content_Thumbnail') el_cover_list[3].click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.driver.find_element_by_android_uiautomator('text("确认")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-转场-放弃测试完成')
class TestEditFX(object): """特效的基本操作测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_edit_fx(self): """剪辑-特效-添加.""" sc.logger.info('剪辑-特效-添加') fun_name = 'test_edit_fx' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '特效': sc.logger.info('开始点击“特效”按钮') el_item.click() break time.sleep(1) while True: try: sc.logger.info('开始点击“FX”按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_add_subtitle').click() break except NoSuchElementException: sc.logger.info('该视频已经有特效,先删除特效') sc.logger.info('开始点击特效编辑按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_speed_close').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击删除特效按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_del_subtitle').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-特效-添加测试完成') def test_edit_fx_del(self): """剪辑-特效-删除.""" sc.logger.info('剪辑-特效-删除') fun_name = 'test_edit_fx_del' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for item in edit_list: if item.text == '特效': sc.logger.info('开始点击“特效”按钮') item.click() break sc.logger.info('开始点击特效编辑按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_speed_close').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击删除特效按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_del_subtitle').click() sc.logger.info('点击右上角确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-特效-删除测试完成') def test_edit_fx_cancel(self): """剪辑-特效-放弃.""" sc.logger.info('剪辑-特效-放弃') fun_name = 'test_edit_fx_cancel' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '特效': sc.logger.info('开始点击“特效”按钮') el_item.click() break sc.logger.info('开始点击“FX”按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_add_subtitle').click() el_fx_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/icon') try: el_fx_list[1].click() sc.logger.info('点击第二个特效') except Exception: fx_down_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/img_lock_flag') fx_down_list[0].click() time.sleep(5) el_fx_list[1].click() sc.logger.info('点击右上角确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.logger.info('点击左上角放弃按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('确认放弃操作') sc.driver.find_element_by_android_uiautomator('text("确认")').click() for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-特效-放弃测试完成')
class TestCreationExport(object): """ 创作页面内导出视频相关的测试类. 1.执行导出用例时,请确认当前app未进行过导出操作 2.使用已购买会员账号登录 """ width, height = sc.get_size() img_path = sc.path_lists[0] def test_export_create(self): """导出-创建视频.""" sc.logger.info('导出-创建视频') fun_name = 'test_export_create' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“拍摄”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() sc.logger.info('点击录制按钮') el_capture = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/btn_rec') # 点拍 el_capture.click() time.sleep(5) el_capture.click() sc.logger.info('点击确认按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/cam_btn_next').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_android_uiautomator('text("保存/上传")').click() sc.logger.info('导出-创建视频完成') def test_export_first(self): """导出-保存到相册-480P-首次导出.""" sc.logger.info('导出-保存到相册-480P-首次导出') fun_name = 'test_export_first' sc.logger.info('点击“保存到相册”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/btn_export').click() sc.logger.info('点击“标清(480P)”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/purchase_duration_limit_title').click() try: WebDriverWait(sc.driver, 60).until( lambda V_exprot: V_exprot.find_element_by_android_uiautomator('text("工作室")')) sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) # 等待不要删除视频提示消息消失 time.sleep(10) sc.driver.press_keycode(4) except NoSuchElementException: sc.driver.find_element_by_android_uiautomator('text("感觉如何")') sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) except TimeoutError as t: sc.logger.error('导出视频超时', t) sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) return False sc.logger.info('导出-保存到相册-480P-首次导出测试完成') def test_export_second(self): """导出-保存到相册-720P-二次导出.""" sc.logger.info('导出-保存到相册-720P-二次导出') fun_name = 'test_export_second' sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击第一个草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“保存/上传”') sc.driver.find_element_by_android_uiautomator('text("保存/上传")').click() sc.logger.info('点击“保存到相册”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/btn_export').click() try: sc.driver.find_element_by_id('com.quvideo.xiaoying:id/purchase_hd_title').click() except NoSuchElementException: sc.logger.info('当前设备不支持720P导出') sc.logger.info('返回创作中心主界面') for i in range(5): time.sleep(1) sc.driver.press_keycode(4) return True try: WebDriverWait(sc.driver, 60).until( lambda V_exprot: V_exprot.find_element_by_android_uiautomator('text("工作室")')) sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) time.sleep(1) sc.driver.press_keycode(4) except NoSuchElementException: sc.driver.find_element_by_android_uiautomator('text("分享小影")') sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) except TimeoutError as t: sc.logger.error('导出视频超时', t) return False sc.logger.info('导出-保存到相册-720P-二次导出测试完成') def test_export_third(self): """导出-保存到相册-1080P-三次导出.""" sc.logger.info('导出-保存到相册-1080P') fun_name = 'test_export_third' sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.driver.find_element_by_android_uiautomator('text("保存/上传")').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/btn_export').click() try: sc.driver.find_element_by_id('com.quvideo.xiaoying:id/purchase_hd_1080_title').click() except NoSuchElementException: sc.logger.info('当前设备不支持1080P导出') sc.logger.info('返回创作中心主界面') for i in range(5): time.sleep(1) sc.driver.press_keycode(4) return True try: WebDriverWait(sc.driver, 60).until( lambda V_exprot: V_exprot.find_element_by_android_uiautomator('text("工作室")')) sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() except TimeoutError as t: sc.logger.error('导出视频超时', t) return False sc.logger.info('导出-保存到相册-1080P测试完成') def test_export_gif(self): """导出-保存到相册-GIF.""" sc.logger.info('导出-保存到相册-GIF') fun_name = 'test_export_gif' time.sleep(1) sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击第一个草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“保存/上传”') sc.driver.find_element_by_android_uiautomator('text("保存/上传")').click() sc.logger.info('点击“保存到相册”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/btn_export').click() try: sc.driver.find_element_by_id('com.quvideo.xiaoying:id/gif_title').click() sc.logger.info('点击“GIF”') except NoSuchElementException: sc.logger.info('当前版本不支持GIF导出') return True time.sleep(1) sc.logger.info('点击“确认”按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/share_btn_share').click() try: WebDriverWait(sc.driver, 120).until( lambda V_exprot: V_exprot.find_element_by_android_uiautomator('text("工作室")')) sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() except TimeoutError as t: sc.logger.error('导出视频超时', t) sc.driver.press_keycode(4) sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/buttonDefaultPositive').click() sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) return False sc.logger.info('导出-保存到相册-GIF测试完成')
class TestEditClip(object): """镜头编辑相关操作的测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_clip_edit_function(self): """剪辑-镜头编辑-功能遍历.""" sc.logger.info('剪辑-镜头编辑-功能遍历') fun_name = 'test_clip_edit_function' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击第一个草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() sc.logger.info('点击“镜头编辑”') sc.driver.find_element_by_android_uiautomator('text("镜头编辑")').click() sc.logger.info('剪辑-镜头编辑-时长') try: sc.logger.info('点击“时长”') sc.driver.find_element_by_android_uiautomator('text("时长")').click() sc.logger.info('点击“确认”') sc.driver.find_element_by_android_uiautomator('text("确认")').click() except NoSuchElementException: sc.logger.info('当前镜头是视频,不支持时长') sc.logger.info('剪辑-镜头编辑-修剪') try: sc.logger.info('点击“修剪”') sc.driver.find_element_by_android_uiautomator('text("修剪")').click() sc.logger.info('点击“确认”') sc.driver.find_element_by_android_uiautomator('text("确认")').click() except NoSuchElementException: sc.logger.info('当前镜头是图片,不支持修剪') sc.logger.info('剪辑-镜头编辑-分割') try: sc.logger.info('点击“分割”') sc.driver.find_element_by_android_uiautomator('text("分割")').click() sc.logger.info('点击“确认”') sc.driver.find_element_by_android_uiautomator('text("确认")').click() except NoSuchElementException: sc.logger.info('当前镜头是图片,不支持分割') sc.logger.info('剪辑-镜头编辑-复制') sc.driver.find_element_by_android_uiautomator('text("复制")').click() sc.logger.info('剪辑-镜头编辑-调节速度') try: sc.logger.info('点击“调节速度”') sc.driver.find_element_by_android_uiautomator( 'text("调节速度")').click() sc.logger.info('点击“确认”') sc.driver.find_element_by_android_uiautomator('text("确认")').click() except NoSuchElementException: sc.logger.info('当前镜头是图片,不支持调节速度') sc.logger.info('剪辑-镜头编辑-调节') el_adjust = sc.driver.find_element_by_android_uiautomator('text("调节")') sc.logger.info('点击“调节”') el_adjust.click() sc.logger.info('点击“取消”') sc.driver.find_element_by_android_uiautomator('text("取消")').click() sc.logger.info('剪辑-镜头编辑-静音') time.sleep(1) coord_x = el_adjust.location.get('x') coord_y = el_adjust.location.get('y') sc.swipe_by_ratio(coord_x, coord_y, 'left', 0.6, 500) sc.logger.info('点击“静音”') sc.driver.find_element_by_android_uiautomator('text("静音")').click() sc.logger.info('剪辑-镜头编辑-倒放镜头') sc.logger.info('点击“倒放镜头”') sc.driver.find_element_by_android_uiautomator('text("倒放镜头")').click() try: WebDriverWait( sc.driver, 120).until(lambda reverse: reverse. find_element_by_android_uiautomator('text("倒放镜头")')) except TimeoutError as t: sc.logger.error('倒放镜头超时', t) return False sc.logger.info('剪辑-镜头编辑-动态效果') sc.logger.info('点击“动态效果”') sc.driver.find_element_by_android_uiautomator('text("动态效果")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') sc.driver.press_keycode(4) sc.driver.find_element_by_android_uiautomator('text("确认")').click() for i in range(3): sc.driver.press_keycode(4) sc.logger.info('剪辑-镜头编辑-功能遍历完成') def test_clip_edit_add(self): """剪辑-镜头编辑-添加镜头.""" sc.logger.info('剪辑-镜头编辑-添加镜头') fun_name = 'test_clip_edit_add' start_x = self.width // 2 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击第一个草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() sc.logger.info('点击“镜头编辑”') sc.driver.find_element_by_android_uiautomator('text("镜头编辑")').click() while True: try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_ve_storyboard_item_add_btn' ).click() sc.logger.info('点击添加镜头按钮') break except NoSuchElementException: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.25, 500) sc.logger.info('点击拍摄按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_ve_preview_layout_captrue' ).click() sc.logger.info('点击录像按钮') el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 长按拍摄 sc.logger.info('长按拍摄5s') actions = TouchAction(sc.driver) actions.long_press(el_capture, None, None, 5000).release().perform() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_storyboard_next_btn').click( ) sc.capture_screen(fun_name, self.img_path) sc.logger.info('镜头编辑-删除镜头') el_del_clip = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_delete') el_del_clip.click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/buttonDefaultPositive').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') sc.driver.press_keycode(4) sc.driver.find_element_by_android_uiautomator('text("确认")').click() for i in range(3): sc.driver.press_keycode(4) sc.logger.info('剪辑-镜头编辑-添加镜头测试完成')
class TestUserWorks(object): """测试用户空间作品的测试类,分步截图.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_works_ui(self): """测试用户空间作品页面的初始状态.""" sc.logger.info('用户空间作品页面初始状态检查测试开始') fun_name = 'test_works_ui' time.sleep(1) btn_home = 'com.quvideo.xiaoying:id/img_studio' el_home = sc.driver.find_element_by_id(btn_home) el_home.click() time.sleep(.500) el_tab_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/text_tab_title') for el_tab in el_tab_list: if el_tab.text == '作品': sc.logger.info('点击“作品”tab') el_tab.click() sc.logger.info('作品页面初始状态截图开始') sc.capture_screen(fun_name, self.img_path) assert el_tab is not None def test_works_list(self): """作品页面list view测试.""" sc.logger.info('用户空间作品页面list view测试开始') fun_name = 'test_works_list' start_x = self.width // 2 start_y = self.height // 4 start_bottom = self.height - start_y time.sleep(1) # 先上滑 sc.logger.info('上滑截图开始') result_up = sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.7, 300) time.sleep(.300) sc.capture_screen(fun_name, self.img_path) # 再下滑,同理 sc.logger.info('下滑截图开始') result_down = sc.swipe_by_ratio(start_x, start_y, 'down', 0.3, 300) time.sleep(.300) sc.capture_screen(fun_name, self.img_path) assert result_up and result_down is True def test_works_list_function(self): """作品页面list view内功能测试.""" sc.logger.info('作品页面list view功能测试开始') fun_name = 'test_works_list' start_x = self.width // 2 start_bottom = self.height - self.height // 8 try: el_like_btn = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_like') except NoSuchElementException: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) time.sleep(.300) el_like_btn = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_like') # 操作前先截图记录 sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击点赞按钮') el_like_btn.click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击分享按钮') el_share_btn = 'com.quvideo.xiaoying:id/xiaoying_com_text_share_count' el_share = sc.driver.find_element_by_id(el_share_btn) el_share.click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击下载按钮') time.sleep(1) sc.driver.find_element_by_android_uiautomator('text("下载")').click() sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) sc.logger.info('点击公开/不公开按钮') time.sleep(1) el_more_btn = 'com.quvideo.xiaoying:id/btn_more' el_more = sc.driver.find_element_by_id(el_more_btn) el_more.click() sc.capture_screen(fun_name, self.img_path) try: el_privacy = sc.driver.find_element_by_android_uiautomator( 'text("设置为不公开")') except NoSuchElementException: el_privacy = sc.driver.find_element_by_android_uiautomator( 'text("设置为公开")') el_privacy.click() assert el_privacy is not None
class TestGallery(object): """Gallery的测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_gallery_video(self): """相册-视频.""" sc.logger.info('相册-视频') fun_name = 'test_gallery_video' start_x = self.width // 2 start_bottom = self.height - self.height // 4 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon1').click() time.sleep(1) try: sc.driver.find_element_by_android_uiautomator('text("跳过")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/icon1').click() except NoSuchElementException: sc.logger.info('已跳过订阅页面') sc.logger.info('点击“其它相册”') sc.driver.find_element_by_android_uiautomator('text("其他相册")').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_android_uiautomator('text("全部")').click() sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 500) el_video = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_click_mask') el_video.click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_ratate').click() try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_crop').click() except NoSuchElementException: sc.logger.info('视频尺寸1:1,无此选项') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_start_trim').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_import').click() sc.capture_screen(fun_name, self.img_path) try: WebDriverWait( sc.driver, 60).until(lambda V_improt: V_improt. find_element_by_android_uiautomator('text("下一步")')) except TimeoutError as t: sc.logger.error('导入视频超时', t) return False except Exception as e: sc.logger.error('导入视频出错', e) return False sc.driver.find_element_by_android_uiautomator('text("下一步")').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('相册-视频相关操作测试完成') def test_gallery_img(self): """相册-图片.""" sc.logger.info('相册-图片') fun_name = 'test_gallery_img' sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon1').click() sc.driver.find_element_by_android_uiautomator('text("视频")').click() sc.driver.find_element_by_android_uiautomator('text("图片")').click() sc.driver.find_element_by_android_uiautomator('text("其他相册")').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_android_uiautomator('text("全部")').click() sc.find_by_ids('com.quvideo.xiaoying:id/img_click_mask', fun_name, self.img_path) sc.driver.find_element_by_android_uiautomator('text("下一步")').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/preview_layout_fake').click() sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('相册-图片相关操作测试完成') def test_gallery_storyboard(self): """相册-storyboard.""" sc.logger.info('相册-storyboard') fun_name = 'test_gallery_storyboard' sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon1').click() el_video_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/img_click_mask') for i in range(3): el_video_list[i].click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_import').click() try: WebDriverWait(sc.driver, 60).until( lambda V_improt: V_improt. find_element_by_android_uiautomator('text("下一步")')) except TimeoutError as t: sc.logger.error('导入视频超时', t) return False except Exception as e: sc.logger.error('导入视频出错', e) return False sc.driver.find_element_by_android_uiautomator('text("视频")').click() sc.driver.find_element_by_android_uiautomator('text("图片")').click() sc.find_by_ids('com.quvideo.xiaoying:id/img_icon', fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_expand').click() el_storyboard_del = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_delete') el_storyboard_del.click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.driver.find_element_by_android_uiautomator('text("保存")').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('相册-storyboard相关操作测试完成') def test_gallery_giveup(self): """相册-放弃操作.""" sc.logger.info('相册-放弃操作') fun_name = 'test_gallery_giveup' start_x = self.width // 2 start_bottom = self.height - self.height // 4 sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon1').click() el_video = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_click_mask') el_video.click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_android_uiautomator('text("视频")').click() sc.driver.find_element_by_android_uiautomator('text("图片")').click() sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 500) sc.find_by_ids('com.quvideo.xiaoying:id/img_icon', fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.driver.find_element_by_android_uiautomator('text("丢弃")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('相册-放弃操作相关操作测试完成')
class TestPreviewMusic(object): """预览页面的music测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] @staticmethod def test_music_create(): """导出-创建视频.""" sc.logger.info('分享-创建视频') time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“拍摄”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍 el_capture.click() time.sleep(5) el_capture.click() time.sleep(1) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.logger.info('分享-创建视频完成') def test_music_add(self): """预览页-配乐.""" sc.logger.info('预览页-配乐') fun_name = 'test_music_add' sc.logger.info('点击第一个草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“配乐”') sc.driver.find_element_by_android_uiautomator('text("配乐")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击添加配乐') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/txtview_bgm_name').click() el_download = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_download') el_music_name = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_name') sc.logger.info('下载音乐') el_download.click() sc.logger.info('添加音乐') el_music_name.click() while True: try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_play_state').click() sc.logger.info('点击播放状态') break except NoSuchElementException: time.sleep(5) sc.capture_screen(fun_name, self.img_path) sc.logger.info('使用音乐') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_use').click() # sc.driver.tap([(start_x, start_bottom), (start_x, start_bottom)], 100) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/preview_layout_fake').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击声音按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgview_icon_video').click() sc.logger.info('点击音乐按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgview_icon_bgm').click() sc.logger.info('点击删除音乐按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_del_music').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('预览页-配乐测试完成') def test_preview_recommend(self): """音乐库-推荐音乐下载.""" sc.logger.info('音乐库-推荐音乐下载') fun_name = 'test_preview_recommend' start_x = self.width // 2 start_bottom = self.height - self.height // 4 sc.logger.info('点击添加配乐') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/txtview_bgm_name').click() sc.logger.info('点击“推荐”tab') sc.driver.find_element_by_android_uiautomator('text("推荐")').click() # 推荐音乐下载 while True: try: sc.driver.find_element_by_android_uiautomator( 'text("没有更多了…")').click() break except NoSuchElementException: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 500) el_download = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_download') el_download.click() time.sleep(5) sc.capture_screen(fun_name, self.img_path) sc.logger.info('音乐库-推荐音乐下载测试完成') def test_preview_other(self): """音乐库-其他分类音乐下载.""" sc.logger.info('音乐库-其他分类音乐下载') fun_name = 'test_preview_other' start_x = self.width - self.width // 5 start_bottom = self.height // 2 # 切换到流行分类 sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.7, 500) sc.logger.info('点击第一个可下载按钮') el_download = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_download') el_download.click() time.sleep(5) sc.capture_screen(fun_name, self.img_path) sc.logger.info('音乐库-其他分类音乐下载测试完成') def test_preview_use(self): """音乐库-使用已下载音乐.""" sc.logger.info('音乐库-使用已下载音乐') fun_name = 'test_preview_use' sc.logger.info('点击“已下载”tab') sc.driver.find_element_by_android_uiautomator('text("已下载")').click() sc.capture_screen(fun_name, self.img_path) el_music_name = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_name') el_music_name.click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_play_state').click() sc.logger.info('点击“添加”按钮') sc.driver.find_element_by_android_uiautomator('text("添加")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/preview_layout_fake').click() sc.capture_screen(fun_name, self.img_path) time.sleep(1) sc.logger.info('音乐库-使用已下载音乐测试完成') def test_preview_delete(self): """音乐库-删除已下载音乐.""" sc.logger.info('音乐库-删除已下载音乐') fun_name = 'test_preview_delete' sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/txtview_bgm_name').click() sc.logger.info('点击删除按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_rubbish_icon').click() sc.logger.info('依次选择已下载音乐') sc.find_by_ids('com.quvideo.xiaoying:id/music_item_check_box', fun_name, self.img_path) sc.logger.info('再次点击删除按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_rubbish_icon').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('音乐库-删除已下载音乐测试完成') def test_preview_local(self): """音乐库-使用本地音乐.""" sc.logger.info('音乐库-使用本地音乐') fun_name = 'test_preview_local' sc.driver.find_element_by_android_uiautomator('text("本地")').click() sc.capture_screen(fun_name, self.img_path) m_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/music_item_name') try: m_list[0].click() except Exception: sc.logger.info('本地音乐不存在!返回创作中心主界面。') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) return True sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_play_state').click() sc.driver.find_element_by_android_uiautomator('text("添加")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/preview_layout_fake').click() sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('音乐库-使用本地音乐测试完成') def test_preview_time(self): """预览页-时长.""" sc.logger.info('预览页-时长') fun_name = 'test_preview_time' sc.logger.info('点击“相册MV') sc.driver.find_element_by_android_uiautomator('text("相册MV")').click() sc.logger.info('添加图片') sc.find_by_ids('com.quvideo.xiaoying:id/img_click_mask', fun_name, self.img_path) sc.logger.info('点击“下一步”') sc.driver.find_element_by_android_uiautomator('text("下一步")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/preview_layout_fake').click() sc.logger.info('点击“时长”') sc.driver.find_element_by_android_uiautomator('text("时长")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.logger.info('点击左上角返回创作中心主界面') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('预览页-时长测试完成')
class TestCreationUI(object): """创作页面的测试类,分步截图""" width, heigh = sc.get_size() @staticmethod def test_origin(): """测试创作页面初始UI状态""" sc.logger.info(u'创作页面初始状态检查测试开始') time.sleep(2) el_home = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation') el_home.click() time.sleep(.500) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert el_home is not None def test_refresh(self): """测试下拉刷新""" sc.logger.info(u'创作页面下拉刷新测试开始') start_x = self.width // 2 start_y = self.heigh // 8 result = sc.swipe_by_ratio(start_x, start_y, 'down', 0.6, 600) time.sleep(.300) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert result is True def test_swipe_vertical(self): """测试上下方向的滑动""" sc.logger.info(u'创作页面上下滑动测试开始') start_x = self.width // 2 start_y = self.heigh // 8 start_bottom = self.heigh - start_y # 先上滑 sc.logger.info(u'上滑截图开始') result_up = sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.7, 300) time.sleep(.300) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # 再下滑,同理 sc.logger.info(u'下滑截图开始') result_down = sc.swipe_by_ratio(start_x, start_y, 'down', 0.7, 300) time.sleep(.300) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert result_up and result_down is True def test_origin_home(self): """测试创作页home tab的功能""" sc.logger.info(u'创作页面home tab功能检查测试开始') start_x = self.width // 2 start_bottom = self.heigh - self.heigh // 8 # 先上滑一点 result_up = sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.6, 500) time.sleep(.300) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # 再按home tab el_home = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation') el_home.click() time.sleep(.300) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert result_up and el_home is not None
class TestPlanetNotify(object): """小影圈通知页的测试类,分步截图.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_planet_notify_ui(self): """小影圈推荐页面初始状态测试.""" sc.logger.info('小影圈推荐页面初始状态检查开始') fun_name = 'test_planet_notify_ui' time.sleep(1) sc.logger.info('开始查找小影圈按钮') el_planet = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_find') el_planet.click() time.sleep(.500) sc.logger.info('开始查找小影圈消息中心图标') el_notify = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/btn_message') el_notify.click() time.sleep(5) sc.logger.info('小影圈推荐页面初始状态截图开始') sc.capture_screen(fun_name, self.img_path) assert el_notify is not None def test_notify_activity(self): """测试消息中心动态.""" sc.logger.info('开始测试消息中心动态') fun_name = 'test_notify_activity' time.sleep(3) el_tab_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/text_viewpager_tab') for el_tab in el_tab_list: if el_tab.text == '动态': el_tab.click() break sc.logger.info('消息中心动态页截图') sc.capture_screen(fun_name, self.img_path) assert el_tab is not None def test_notify_info(self): """测试消息中心通知页.""" sc.logger.info('开始测试消息中心通知页.') fun_name = 'test_notify_info' time.sleep(1) el_tab_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/text_viewpager_tab') for el_tab in el_tab_list: if el_tab.text == '通知': el_tab.click() break sc.logger.info('消息中心通知页截图') sc.capture_screen(fun_name, self.img_path) assert el_tab is not None def test_notify_message(self): """测试消息中心动态.""" sc.logger.info('开始测试消息中心私信.') fun_name = 'test_notify_message' time.sleep(1) el_tab_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/text_viewpager_tab') for el_tab in el_tab_list: if el_tab.text == '私信': el_tab.click() break sc.logger.info('消息中心私信页截图') sc.capture_screen(fun_name, self.img_path) sc.logger.info('通知中心测试完成,返回主页') sc.driver.press_keycode(4) assert el_tab is not None
class TestPlanetRec(object): """小影圈推荐页的测试类,分步截图.""" width, heigh = sc.get_size() @staticmethod def test_planet_page(): """小影圈推荐页面初始状态测试.""" sc.logger.info('小影圈推荐页面初始状态检查开始') time.sleep(2) sc.logger.info('开始查找小影圈按钮') el_planet = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_find') el_planet.click() time.sleep(.500) sc.logger.info('开始查找小影圈推荐tab') el_tab_list = sc.driver.find_elements_by_id('android:id/text1') for el_tab in el_tab_list: if el_tab.text == '推荐': sc.logger.info('点击“推荐”tab') el_tab.click() break sc.logger.info('小影圈推荐页面初始状态截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert el_tab is not None def test_refresh(self): """测试下拉刷新.""" sc.logger.info('推荐页面下拉刷新测试开始') start_x = self.width // 2 start_y = self.heigh // 8 result = sc.swipe_by_ratio(start_x, start_y, 'down', 0.6, 600) time.sleep(.300) sc.logger.info('小影圈推荐页面下拉刷新截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert result is True def test_swipe_vertical(self): """测试上下方向的滑动.""" sc.logger.info(u'推荐页面滑动测试开始') start_x = self.width // 2 start_y = self.heigh // 8 start_bottom = self.heigh - start_y # 先上滑 sc.logger.info(u'上滑截图开始') result_up = sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.7, 300) time.sleep(.300) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # 再下滑,同理 sc.logger.info(u'下滑截图开始') result_down = sc.swipe_by_ratio(start_x, start_y, 'down', 0.3, 300) time.sleep(.300) sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert result_up and result_down is True def test_origin_home(self): """推荐页tab的功能.""" sc.logger.info('推荐页面tab功能检查测试开始') start_x = self.width // 2 start_bottom = self.heigh - self.heigh // 8 # 先上滑一点 result_up = sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.6, 500) time.sleep(.300) sc.logger.info('小影圈推荐页面轻微上滑截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # 再按推荐tab sc.logger.info('开始查找小影圈推荐tab') el_tab_list = sc.driver.find_elements_by_id('android:id/text1') for el_tab in el_tab_list: if el_tab.text == '推荐': sc.logger.info('点击“推荐”tab') el_tab.click() break time.sleep(.300) sc.logger.info('小影圈推荐页面点击“推荐”tab截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) assert result_up and el_tab is not None @staticmethod def test_recommend_video(): """测试推荐页面的视频.""" sc.logger.info('推荐页面视频检查开始') el_video = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_video_thumb') el_video.click() time.sleep(1) sc.logger.info('小影圈推荐页面进入视频feed流截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # sc.driver.back() sc.logger.info('点击返回键') sc.driver.press_keycode(4) assert el_video is not None @staticmethod def test_recommend_user(): """测试推荐页面的用户.""" sc.logger.info('推荐页面用户检查开始') el_video = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_owner_avatar') el_video.click() time.sleep(1) sc.logger.info('小影圈推荐页面点击用户头像进入用户空间截图开始') sc.capture_screen(inspect.stack()[0][3], sc.path_lists[0]) # sc.driver.back() sc.logger.info('点击返回键') sc.driver.press_keycode(4) assert el_video is not None
class TestCameraMusic(object): """camera音乐视频的基本测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_music_shot(self): """拍摄-音乐视频(3:4).""" sc.logger.info('拍摄-音乐视频(3:4)') fun_name = 'test_music_shot' start_x = self.width - self.width // 10 start_bottom = self.height // 2 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.8, 500) sc.logger.info('点击“音乐视频”') sc.driver.find_element_by_android_uiautomator('text("音乐视频")').click() time.sleep(1) sc.logger.info('点击视频比例按钮,切换到3:4') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_ratio').click() sc.logger.info('切换摄像头') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_switch').click() time.sleep(2) sc.logger.info('点击“请选择音乐”按钮') sc.driver.find_element_by_android_uiautomator('text("请选择音乐")').click() time.sleep(2) try: el_download = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_download') except NoSuchElementException: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.4, 500) el_download = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_download') sc.logger.info('点击第一个下载按钮') el_download.click() time.sleep(5) el_music_name = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_name') sc.logger.info('点击第一首音乐名') el_music_name.click() sc.logger.info('点击播放/暂停按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_play_state').click() sc.logger.info('点击“添加”按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_use').click() el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍5s sc.logger.info('点击录制按钮') el_capture.click() time.sleep(5) sc.logger.info('拍摄5s后点击录制按钮停止拍摄') el_capture.click() try: sc.logger.info('点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() except NoSuchElementException: sc.logger.info('音乐时长较短,已自动跳转预览页') sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('拍摄-音乐视频(3:4)完成') def test_music_change(self): """拍摄-音乐视频-更换音乐重录.""" sc.logger.info('拍摄-音乐视频-更换音乐重录') fun_name = 'test_music_change' start_x = self.width - self.width // 10 start_bottom = self.height // 2 sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.8, 500) sc.logger.info('点击“音乐视频”') sc.driver.find_element_by_android_uiautomator('text("音乐视频")').click() sc.logger.info('点击“请选择音乐”') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/icon_tool_music_control_arrow').click() # sc.driver.find_element_by_android_uiautomator('text("请选择音乐")').click() el_music_name = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_name') sc.logger.info('点击第一首音乐名') el_music_name.click() sc.logger.info('点击播放/暂停按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_play_state').click() sc.logger.info('点击“添加”按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_use').click() el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍 sc.logger.info('点击录制按钮') el_capture.click() time.sleep(5) sc.logger.info('拍摄5s后点击录制按钮停止拍摄') el_capture.click() try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() sc.logger.info('点击确认按钮') except NoSuchElementException: sc.logger.info('音乐时长较短,已自动跳转预览页') sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击左上角返回按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('点击音乐标题') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/icon_tool_music_control_arrow').click() try: sc.driver.find_element_by_android_uiautomator( 'text("更换音乐重录")').click() except NoSuchElementException: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/icon_tool_music_control_arrow').click( ) el_title_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_title in el_title_list: if el_title.text == '更换音乐重录': sc.logger.info('点击“更换音乐重录”') el_title.click() sc.logger.info('点击音乐名') time.sleep(2) el_music_name = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_name') el_music_name.click() sc.logger.info('点击播放/暂停按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_play_state').click() sc.logger.info('点击“添加”按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_use').click() el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍 sc.logger.info('点击录制按钮') el_capture.click() time.sleep(5) sc.logger.info('拍摄5s后点击录制按钮停止拍摄') el_capture.click() try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() sc.logger.info('点击“确认”按钮') except NoSuchElementException: sc.logger.info('音乐时长较短,已自动跳转预览页') sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.logger.info('点击左上角返回按钮返回创作中心主页面') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('拍摄-音乐视频-更换音乐重录完成') def test_music_redo(self): """拍摄-音乐视频-重新录制.""" sc.logger.info('拍摄-音乐视频-直接重录') fun_name = 'test_music_redo' sc.logger.info('点击“音乐视频”') sc.driver.find_element_by_android_uiautomator('text("音乐视频")').click() sc.logger.info('点击“请选择音乐”') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/icon_tool_music_control_arrow').click() el_music_name = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_name') sc.logger.info('点击音乐标题') el_music_name.click() sc.logger.info('点击播放/暂停按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_play_state').click() sc.logger.info('点击“添加”按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/music_item_use').click() el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍5s el_capture.click() sc.logger.info('点击拍摄按钮') time.sleep(5) sc.logger.info('拍摄5s后点击录制按钮停止拍摄') el_capture.click() try: sc.logger.info('点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() except NoSuchElementException: sc.logger.info('音乐时长较短,已自动跳转预览页') sc.logger.info('点击左上角返回按钮返回') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('点击音乐标题') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/icon_tool_music_control_arrow').click() try: sc.driver.find_element_by_android_uiautomator( 'text("直接重录")').click() except NoSuchElementException: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/icon_tool_music_control_arrow').click( ) sc.capture_screen(fun_name, self.img_path) el_title_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_title in el_title_list: if el_title.text == '直接重录': sc.logger.info('直接重录') el_title.click() sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击确认放弃操作') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/buttonDefaultPositive').click() sc.driver.press_keycode(4) sc.logger.info('拍摄-音乐视频-直接重录完成')
class TestEditSticker(object): """动画贴纸的测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_edit_sticker_add(self): """剪辑-动画贴纸-添加.""" sc.logger.info('剪辑-动画贴纸-添加') fun_name = 'test_edit_sticker_add' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) el_edit_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '动画贴纸': sc.logger.info('开始点击动画贴纸') el_item.click() break sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_add_subtitle').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): sc.driver.press_keycode(4) sc.logger.info('剪辑-动画贴纸-添加测试完成') def test_edit_sticker_cancel(self): """剪辑-动画贴纸-放弃.""" sc.logger.info('剪辑-动画贴纸-放弃') fun_name = 'test_edit_sticker_cancel' start_x = self.width - self.width // 4 start_bottom = self.height - self.height // 10 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() time.sleep(1) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.6, 500) el_edit_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '动画贴纸': sc.logger.info('开始点击动画贴纸') el_item.click() break sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_add_subtitle').click() sticker_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/icon') sticker_list[1].click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_android_uiautomator('text("确认")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): sc.driver.press_keycode(4) sc.logger.info('剪辑-动画贴纸-放弃测试完成')
class TestSettings(object): """设置页面的测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_settings_ui(self): """设置:默认值UI遍.""" sc.logger.info('设置:默认UI遍历') fun_name = 'test_settings_ui' time.sleep(3) sc.logger.info('点击按钮“我”') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_studio').click() sc.logger.info('开始进入个人空间截图') sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_setting').click() el_set_list = sc.driver.find_elements_by_class_name( 'android.widget.TextView') for el_set_content in el_set_list: el_set_content.click() sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) time.sleep(1) """ try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_setting').click() except NoSuchElementException: sc.logger.info('[%s]: 未找到设置按钮', fun_name) """ sc.logger.info('设置选项UI第一页遍历完成') def test_settings_net(self): """设置:自动播放/网络/推送/分享设置.""" sc.logger.info('设置:自动播放/网络/推送/分享设置遍历测试') fun_name = 'test_settings_net' try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_setting').click() except NoSuchElementException: sc.logger.info('已经在设置页面了,直接进行下一步') sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("自动播放设置")').click() sc.find_by_classes('android.widget.TextView', fun_name, self.img_path) sc.logger.info('自动播放设置遍历完成') sc.driver.press_keycode(4) time.sleep(1) el_net_wifi = sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("只在WIFI网络上传/下载视频")') sc.logger.info('点击网络设置选项') el_net_wifi.click() sc.logger.info('开始网络设置选项截图') sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/buttonDefaultNegative').click() el_net_wifi.click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/buttonDefaultPositive').click() el_net_wifi.click() sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("接收通知推送")').click() sc.find_by_classes('android.widget.TextView', fun_name, self.img_path) sc.logger.info('通知推送设置遍历完成') sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("分享帐号设置")').click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_back').click() sc.logger.info('网络设置相关测试完成') def test_settings_live(self): """设置:摄像头校正.""" sc.logger.info('设置:摄像头校正') fun_name = 'test_settings_live' sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("摄像头校正")').click() sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("校正前置摄像头")').click() time.sleep(3) sc.logger.info('校正前置摄像头时截图') sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/cam_adjust_dialog_btn_rotate_left').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/cam_adjust_dialog_btn_rotate_right').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/cam_adjust_dialog_btn_flip_horizontal').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/cam_adjust_dialog_btn_flip_vertical').click() sc.driver.press_keycode(4) time.sleep(3) sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("摄像头校正")').click() sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("校正后置摄像头")').click() time.sleep(3) sc.logger.info('校正后置摄像头时截图') sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/cam_adjust_dialog_btn_rotate_left').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/cam_adjust_dialog_btn_rotate_right').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/cam_adjust_dialog_btn_flip_horizontal').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/cam_adjust_dialog_btn_flip_vertical').click() sc.driver.press_keycode(4) sc.logger.info('设置:摄像头校正测试完成') def test_settings_privacy(self): """设置:隐私设置.""" sc.logger.info('设置:隐私设置') fun_name = 'test_settings_privacy' start_x = self.width // 2 start_bottom = self.height - self.height // 10 sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("私信权限")').click() sc.find_by_classes('android.widget.TextView', fun_name, self.img_path) sc.logger.info('隐私权限设置遍历完成') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_back').click() sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("隐私帐号")').click() time.sleep(1) try: sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("水印显示昵称")').click() except NoSuchElementException: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.3, 500) sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("水印显示昵称")').click() sc.logger.info('设置:隐私设置测试完成') def test_settings_feedback(self): """设置:意见反馈.""" sc.logger.info('设置:意见反馈') fun_name = 'test_settings_feedback' start_x = self.width // 2 start_bottom = self.height - self.height // 10 sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.8, 500) sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("意见反馈")').click() try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/feedback_btn_issue_create').click() except NoSuchElementException: sc.logger.info('当前是第一次反馈') el_question_msg = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/feedback_question_msg') el_question_msg.send_keys('QA test001') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/feedback_question_type').click() time.sleep(2) sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("完成")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/feedback_layout_sh_').click() sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) time.sleep(1) el_qq_contact = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/feedback_contact_edit_1') el_qq_contact.send_keys('245603638') sc.driver.hide_keyboard() time.sleep(2) el_ph_contact = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/feedback_contact_edit_2') el_ph_contact.send_keys('15857154810') sc.driver.hide_keyboard() time.sleep(2) sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("提交")').click() time.sleep(2) sc.capture_screen(fun_name, self.img_path) sc.logger.info('查看反馈') el_feedback = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/feedback_layout_history_item') el_feedback.click() sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/feedback_left_icon').click() sc.logger.info('意见反馈测试完成') def test_settings_senior(self): """设置:高级设置和其他.""" sc.logger.info('设置:高级设置和其他') fun_name = 'test_settings_senior' sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("视频处理硬件加速")').click() sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("视频保存位置")').click() sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("关于小影")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_back').click() sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("评价小影")').click() sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) time.sleep(1) sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("铂金会员")').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_back').click() sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("恢复购买")').click() sc.logger.info('设置:高级设置和其他测试完成') def test_settings_recommend(self): """设置:推荐小影给好友.""" sc.logger.info('设置:推荐小影给好友') fun_name = 'test_settings_recommend' sc.driver.find_element_by_android_uiautomator( 'new UiSelector().text("推荐小影给好友")').click() time.sleep(1) sc.capture_screen(fun_name, self.img_path) for i in range(3): sc.driver.press_keycode(4) time.sleep(1) sc.logger.info('推荐到微信好友测试完成')
class TestEditCollage(object): """编辑页面画中画的基本操作测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_edit_collage(self): """剪辑-画中画-图片添加.""" sc.logger.info('剪辑-画中画-图片添加') fun_name = 'test_edit_collage' start_x = self.width // 2 start_bottom = self.height // 3 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '画中画': sc.logger.info('开始点击画中画') el_item.click() break sc.logger.info('开始添加图片') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_editor_btn_gif_add').click() el_pic = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/collage_pic_item_cover') sc.logger.info('添加一张图片') el_pic.click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.driver.swipe(start_x, start_bottom, start_x, start_bottom, 100) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.logger.info('再次点击确认按钮回到预览页') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-画中画-图片添加测试完成') def test_edit_collage_add(self): """剪辑-画中画-GIF添加.""" sc.logger.info('剪辑-画中画-GIF添加') fun_name = 'test_edit_collage_add' start_x = self.width // 2 start_bottom = self.height // 3 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '画中画': sc.logger.info('开始点击画中画') el_item.click() break sc.logger.info('开始添加图片') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_editor_btn_gif_add').click() sc.logger.info('点击上方"gif" tab') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_editor_title_gif_choose_gif').click( ) try: WebDriverWait( sc.driver, 60).until(lambda gif: gif.find_element_by_id( 'com.quvideo.xiaoying:id/collage_gif_item_cover')) el_gif = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/collage_gif_item_cover') el_gif.click() time.sleep(5) el_gif.click() except Exception as e: sc.logger.error('GIF图片加载异常', e) return False sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.driver.swipe(start_x, start_bottom, start_x, start_bottom, 1000) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.logger.info('再次点击确认按钮回到预览页') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-画中画-GIF添加测试完成') def test_edit_collage_search(self): """剪辑-画中画-GIF搜索.""" sc.logger.info('剪辑-画中画-GIF搜索') fun_name = 'test_edit_collage_search' start_x = self.width // 2 start_bottom = self.height // 3 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '画中画': sc.logger.info('开始点击画中画') el_item.click() break sc.logger.info('开始添加图片') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_editor_btn_gif_add').click() sc.logger.info('点击上方"gif" tab') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_editor_title_gif_choose_gif').click( ) el_gif_search = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_search_gif') el_gif_search.clear() el_gif_search.send_keys('a') sc.logger.info('用字符"a"搜索gif') sc.driver.press_keycode(66) try: WebDriverWait( sc.driver, 60).until(lambda gif: gif.find_element_by_id( 'com.quvideo.xiaoying:id/collage_gif_item_cover')) el_gif = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/collage_gif_item_cover') sc.logger.info('下载gif') el_gif.click() time.sleep(5) el_gif.click() sc.capture_screen(fun_name, self.img_path) except Exception as e: sc.logger.error('GIF图片加载异常', e) sc.capture_screen(fun_name, self.img_path) return False sc.logger.info('点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.driver.swipe(start_x, start_bottom, start_x, start_bottom, 1000) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.logger.info('再次点击确认按钮回到预览页') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-画中画-GIF搜索测试完成') def test_edit_collage_cancel(self): """剪辑-画中画-放弃.""" sc.logger.info('剪辑-画中画-放弃') fun_name = 'test_edit_collage_cancel' start_x = self.width // 2 start_bottom = self.height // 3 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '画中画': sc.logger.info('开始点击画中画') el_item.click() break sc.logger.info('开始添加图片') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_editor_btn_gif_add').click() el_pic = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/collage_pic_item_cover') sc.logger.info('添加一张图片') el_pic.click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_right_button').click() sc.driver.swipe(start_x, start_bottom, start_x, start_bottom, 1000) sc.logger.info('放弃所有操作') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_left_button').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/video_title_left_button').click() sc.driver.find_element_by_android_uiautomator('text("确认")').click() sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-画中画-放弃测试完成')
class TestCameraNormal(object): """camera的基本操作测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_normal_filter_download(self): """拍摄-滤镜下载.""" sc.logger.info('拍摄-滤镜下载') fun_name = 'test_normal_filter_download' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“拍摄”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() sc.logger.info('点击滤镜图标') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_filter_effect').click() try: el_filter_download = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/icon_filter_download') sc.logger.info('点击下载按钮') el_filter_download.click() try: WebDriverWait(sc.driver, 30).until( lambda download_flt: download_flt.find_element_by_id( 'com.quvideo.xiaoying:id/item_fitler_child_cover')) except Exception as e: sc.logger.error('滤镜下载失败', e) except NoSuchElementException: el_filter_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/item_fitler_parent_cover') sc.logger.info('点击第三个滤镜主题') el_filter_list[2].click() time.sleep(1) el_child_filter = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/item_fitler_child_cover') sc.logger.info('点击第一个滤镜') el_child_filter.click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('退出滤镜选项') sc.driver.press_keycode(4) sc.logger.info('返回创作中心主界面') sc.driver.press_keycode(4) sc.logger.info('拍摄-滤镜下载测试完成') def test_camera_normal_settings(self): """拍摄-设置相关.""" sc.logger.info('拍摄-设置相关') fun_name = 'test_camera_normal_settings' sc.logger.info('点击“拍摄”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() sc.logger.info('点击设置按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_setting').click() sc.find_by_classes('android.widget.ImageView', fun_name, self.img_path) sc.logger.info('退出设置选项') sc.driver.press_keycode(4) sc.logger.info('返回创作中心主界面') sc.driver.press_keycode(4) sc.logger.info('拍摄-设置相关测试完成') def test_camera_normal_shot(self): """拍摄-高清相机(全屏).""" sc.logger.info('拍摄-高清相机(全屏)') fun_name = 'test_camera_normal_shot' sc.logger.info('点击“拍摄”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() sc.logger.info('点击摄像头切换按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_switch').click() time.sleep(2) el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍 sc.logger.info('点击录制按钮') el_capture.click() time.sleep(5) sc.logger.info('录制5s后点击录制按钮停止录制') el_capture.click() sc.capture_screen(fun_name, self.img_path) # 长按拍摄 sc.logger.info('长按拍摄5s') actions = TouchAction(sc.driver) actions.long_press(el_capture, None, None, 5000).release().perform() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击撤销按钮两次') sc.driver.find_element_by_android_uiautomator('text("撤销")').click() sc.driver.find_element_by_android_uiautomator('text("撤销")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.logger.info('点击左上角返回按钮退回创作中心') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('拍摄-高清相机拍摄完成')
class TestCameraCollage(object): """camera的画中画功能测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_collage_settings(self): """拍摄-画中画拍摄-设置.""" sc.logger.info('拍摄-画中画拍摄-设置') fun_name = 'test_collage_settings' start_x = self.width - self.width // 10 start_bottom = self.height // 2 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.8, 500) sc.logger.info('点击"画中画拍摄"') sc.driver.find_element_by_android_uiautomator('text("画中画拍摄")').click() sc.logger.info('切换样式') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_effect').click() el_wheel = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/wheel_img_content') sc.logger.info('点击第一个样式效果') el_wheel.click() sc.driver.press_keycode(4) time.sleep(1) sc.capture_screen(fun_name, self.img_path) sc.logger.info('摄像位置互换') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_mode').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('切换前后置') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_switch').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('camera设置') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_setting').click() try: sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/v4_img_flash').click() except NoSuchElementException: sc.logger.info('前置摄像头不支持闪光灯') sc.logger.info('点击倒计时按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/v4_img_timer').click() sc.logger.info('点击曝光锁定按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/v4_img_aelock').click() sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) time.sleep(2) sc.logger.info('点击返回按钮返回创作中心主页面') sc.driver.press_keycode(4) sc.logger.info('拍摄-画中画拍摄-设置完成') def test_collage_shot(self): """拍摄-画中画拍摄-拍摄.""" sc.logger.info('拍摄-画中画拍摄-拍摄') fun_name = 'test_collage_shot' sc.logger.info('点击"画中画拍摄"') sc.driver.find_element_by_android_uiautomator('text("画中画拍摄")').click() el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍 sc.logger.info('点击录制按钮') el_capture.click() time.sleep(5) sc.logger.info('拍摄5s后点击录制按钮停止拍摄') el_capture.click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_cam_img_pip_add').click() sc.logger.info('添加第二段视频') el_capture.click() try: WebDriverWait( sc.driver, 300).until(lambda capture: capture. find_element_by_android_uiautomator('text("存草稿")')) sc.logger.info('点击“存草稿”按钮') sc.driver.find_element_by_android_uiautomator( 'text("存草稿")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击左上角返回按钮返回创作中心主页') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('拍摄-音乐视频拍摄完成') except Exception as e: sc.logger.error('拍摄完成跳转预览页异常', e) sc.driver.press_keycode(4) return False sc.logger.info('拍摄-画中画拍摄-拍摄完成') def test_collage_album(self): """拍摄-画中画拍摄-拍摄.""" sc.logger.info('拍摄-画中画拍摄-相册视频') fun_name = 'test_collage_album' sc.logger.info('点击"画中画拍摄"') sc.driver.find_element_by_android_uiautomator('text("画中画拍摄")').click() sc.logger.info('从相册选择视频') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_cam_btn_pip_gallery').click() sc.logger.info('点击相册第一个视频') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_click_mask').click() sc.logger.info('点击“添加”按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_import').click() try: WebDriverWait( sc.driver, 60).until(lambda V_improt: V_improt.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec')) except TimeoutError as t: sc.logger.error('导入视频超时', t) return False except Exception as e: sc.logger.error('导入视频出错', e) return False sc.logger.info('添加第二段视频') el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') # 点拍 el_capture.click() time.sleep(5) el_capture.click() try: WebDriverWait( sc.driver, 300).until(lambda capture: capture. find_element_by_android_uiautomator('text("存草稿")')) sc.logger.info('点击"存草稿"按钮') sc.driver.find_element_by_android_uiautomator( 'text("存草稿")').click() sc.logger.info('点击左上角返回按钮返回创作中心主页面') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('拍摄-音乐视频拍摄完成') except Exception as e: sc.logger.error('拍摄完成跳转预览页异常', e) sc.driver.press_keycode(4) return False sc.logger.info('拍摄-画中画拍摄-相册视频完成') def test_collage_edit(self): """拍摄-画中画编辑.""" sc.logger.info('拍摄-画中画编辑') fun_name = 'test_collage_edit' sc.logger.info('点击"画中画编辑"') sc.driver.find_element_by_android_uiautomator('text("画中画编辑")').click() sc.logger.info('选择第2个样式') el_style_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/xiaoying_imagebtn_style_thumb') el_style_list[1].click() sc.driver.press_keycode(4) sc.capture_screen(fun_name, self.img_path)
class TestEditText(object): """添加字幕的基本操作测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_edit_text(self): """剪辑-字幕-添加.""" sc.logger.info('剪辑-字幕-添加') fun_name = 'test_edit_text' start_x = self.width // 2 start_bottom = self.height // 2 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '字幕': sc.logger.info('开始点击字幕') el_item.click() break sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_add_subtitle').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.swipe(start_x, start_bottom, start_x, start_bottom, 100) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-字幕-添加测试完成') def test_edit_text_cancel(self): """剪辑-字幕-放弃.""" sc.logger.info('剪辑-字幕-放弃') fun_name = 'test_edit_text_cancel' start_x = self.width // 2 start_bottom = self.height // 2 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() el_edit_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '字幕': sc.logger.info('开始点击字幕') el_item.click() break sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/imgbtn_add_subtitle').click() sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.driver.swipe(start_x, start_bottom, start_x, start_bottom, 100) sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.driver.find_element_by_android_uiautomator('text("确认")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-字幕-放弃测试完成')
class TestEditMusic(object): """音乐相关操作测试测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_edit_music_add(self): """剪辑-多段配乐-添加.""" sc.logger.info('剪辑-多段配乐-添加') fun_name = 'test_music_add' start_x = self.width // 2 start_bottom = self.height // 4 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() el_edit_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '多段配乐': sc.logger.info('开始点击“多段配乐”按钮') el_item.click() break while True: try: sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_add_music').click() sc.logger.info('点击添加音乐按钮') break except NoSuchElementException: sc.logger.info('当前视频已经有配乐') sc.logger.info('删除原有音乐') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_speed_close').click() sc.logger.info('点击删除按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_del_music').click() el_download = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/music_item_download') el_music_name = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/music_item_name') sc.logger.info('下载音乐') el_download.click() sc.logger.info('添加音乐') el_music_name.click() while True: try: sc.driver.find_element_by_id('com.quvideo.xiaoying:id/music_item_play_state').click() sc.logger.info('点击播放状态') break except NoSuchElementException: time.sleep(5) sc.logger.info('使用音乐') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/music_item_use').click() sc.driver.swipe(start_x, start_bottom, start_x, start_bottom, 100) sc.logger.info('点击右上角确认按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-多段配乐-添加测试完成') def test_edit_music_del(self): """剪辑-多段配乐-删除.""" sc.logger.info('剪辑-多段配乐-删除') fun_name = 'test_camera_music_del' time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() edit_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/title') for item in edit_list: if item.text == '多段配乐': sc.logger.info('开始点击多段配乐') item.click() break sc.logger.info('点击编辑按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_speed_close').click() sc.logger.info('点击删除按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_del_music').click() sc.logger.info('点击右上角确认按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_right').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-多段配乐-删除测试完成') def test_edit_music_cancel(self): """剪辑-多段配乐-放弃.""" sc.logger.info('剪辑-多段配乐-放弃') fun_name = 'test_camera_music_cancel' start_x = self.width // 2 start_bottom = self.height // 4 time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“更多草稿”') sc.driver.find_element_by_android_uiautomator('text("更多草稿")').click() sc.logger.info('点击草稿封面') el_draft = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb') el_draft.click() sc.logger.info('点击“剪辑”') sc.driver.find_element_by_android_uiautomator('text("剪辑")').click() el_edit_list = sc.driver.find_elements_by_id('com.quvideo.xiaoying:id/title') for el_item in el_edit_list: if el_item.text == '多段配乐': sc.logger.info('开始点击多段配乐') el_item.click() break while True: try: time.sleep(1) sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_add_music').click() sc.logger.info('点击添加音乐按钮') break except NoSuchElementException: sc.logger.info('当前视频已经有配乐') sc.logger.info('删除原有音乐') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_speed_close').click() sc.logger.info('点击删除按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/imgbtn_del_music').click() el_download = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/music_item_download') el_music_name = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/music_item_name') el_download.click() time.sleep(5) el_music_name.click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/music_item_play_state').click() sc.driver.find_element_by_id('com.quvideo.xiaoying:id/music_item_use').click() sc.driver.swipe(start_x, start_bottom, start_x, start_bottom, 1000) sc.logger.info('点击左上角放弃操作按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('确认放弃操作') sc.driver.find_element_by_android_uiautomator('text("确认")').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作中心主界面') for i in range(4): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-多段配乐-放弃测试完成')
class TestUserFans(object): """测试用户空间粉丝的测试类,分步截图.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_user_fans(self): """测试用户空间粉丝页面的初始状态.""" sc.logger.info('用户空间粉丝页面初始状态检查测试开始') fun_name = 'test_user_fans' time.sleep(1) btn_home = 'com.quvideo.xiaoying:id/img_studio' el_home = sc.driver.find_element_by_id(btn_home) el_home.click() time.sleep(.500) el_tab_list = sc.driver.find_elements_by_id( 'com.quvideo.xiaoying:id/text_tab_title') for el_tab in el_tab_list: if el_tab.text == '粉丝': sc.logger.info('点击“粉丝”tab') el_tab.click() sc.logger.info('粉丝页面初始状态截图开始') sc.capture_screen(fun_name, self.img_path) assert el_tab is not None def test_fans_follow(self): """粉丝关注/取消关注测试.""" sc.logger.info('用户空间粉丝页面关注状态测试开始') fun_name = 'test_fans_follow' time.sleep(1) btn_follow = 'com.quvideo.xiaoying:id/btn_follow_state' el_btn_follow = sc.driver.find_element_by_id(btn_follow) if el_btn_follow.text == '已关注': sc.logger.info('点击第一个已关注状态按钮') el_btn_follow.click() el_btn_yes = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/buttonDefaultPositive') el_btn_yes.click() sc.logger.info('第一次取消点击后,关注状态截图') sc.capture_screen(fun_name, self.img_path) else: sc.logger.info('点击第一个关注状态按钮') el_btn_follow.click() sc.logger.info('第一次点击关注后,关注状态截图') sc.capture_screen(fun_name, self.img_path) assert el_btn_follow is not None def test_fans_home(self): """点击粉丝头像进入粉丝空间测试.""" sc.logger.info('粉丝空间空间测试') fun_name = 'test_fans_home' time.sleep(.500) el_avatar = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/avatar_img') el_avatar.click() sc.logger.info('点击粉丝头像后,进入粉丝空间截图') sc.capture_screen(fun_name, self.img_path) sc.driver.press_keycode(4) assert el_avatar is not None def test_fans_list(self): """粉丝页面上下滑动测试.""" sc.logger.info('用户空间作品页面上下滑动测试开始') fun_name = 'test_fans_list' start_x = self.width // 2 start_y = self.height // 4 start_bottom = self.height - start_y time.sleep(1) # 先上滑 sc.logger.info('上滑截图开始') result_up = sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.7, 300) time.sleep(.300) sc.capture_screen(fun_name, self.img_path) # 再下滑,同理 sc.logger.info('下滑截图开始') result_down = sc.swipe_by_ratio(start_x, start_y, 'down', 0.3, 300) time.sleep(.300) sc.capture_screen(fun_name, self.img_path) assert result_up and result_down is True
class TestCameraCancel(object): """camera取消操作相关的测试类.""" width, height = sc.get_size() img_path = sc.path_lists[0] def test_cancel_shot(self): """拍摄-拍摄页放弃.""" sc.logger.info('拍摄-拍摄页放弃') time.sleep(1) sc.logger.info('点击创作中心主按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/img_creation').click() sc.logger.info('点击“拍摄”按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') sc.logger.info('点击录制按钮') el_capture.click() time.sleep(5) sc.logger.info('拍摄5s后点击录制按钮停止拍摄') el_capture.click() try: WebDriverWait(sc.driver, 60).until(lambda capture: capture.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_cancel')) except Exception as e: sc.logger.error('拍摄完成但未找到返回按钮', e) return False sc.logger.info('点击左上角取消按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_cancel').click() sc.logger.info('点击“丢弃”按钮') sc.driver.find_element_by_android_uiautomator('text("丢弃")').click() sc.logger.info('拍摄-拍摄页放弃测试完成') def test_cancel_save(self): """拍摄-拍摄页保存.""" sc.logger.info('拍摄-拍摄页保存') sc.logger.info('点击创作中心“拍摄”按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') sc.logger.info('点击录制按钮') capture.click() time.sleep(5) sc.logger.info('拍摄5s后点击录制按钮停止拍摄') capture.click() try: WebDriverWait(sc.driver, 60).until(lambda capture: capture.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_cancel')) except Exception as e: sc.logger.error('拍摄完成但未找到返回按钮', e) return False sc.logger.info('点击左上角取消按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_cancel').click() sc.logger.info('点击“保存”按钮') sc.driver.find_element_by_android_uiautomator('text("保存")').click() sc.logger.info('点击左上角返回按钮退回主页面') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('拍摄-拍摄页保存测试完成') def test_cancel_preview(self): """拍摄-预览页放弃.""" sc.logger.info('拍摄-预览页放弃)') fun_name = 'test_cancel_preview' sc.logger.info('点击创作中心“拍摄”按钮') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() el_capture = sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/btn_rec') sc.logger.info('点击录制按钮') el_capture.click() time.sleep(5) sc.logger.info('拍摄5s后点击录制按钮停止拍摄') el_capture.click() try: WebDriverWait(sc.driver, 60).until(lambda capture: capture.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next')) except Exception as e: sc.logger.error('拍摄完成但未找到返回按钮', e) return False sc.logger.info('录制完成后点击确认按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_next').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击左上角返回按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('点击左上角取消按钮') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/cam_btn_cancel').click() sc.logger.info('点击左上角返回按钮退回主页面') sc.driver.find_element_by_id( 'com.quvideo.xiaoying:id/xiaoying_com_btn_left').click() sc.logger.info('拍摄-预览页放弃测试完成')