def test_preview_theme(self): """预览页-主题页面.""" sc.logger.info('预览页-主题页面') fun_name = 'test_preview_theme' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“主题”') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name("主题")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('使用“主题”') try: WebDriverWait(sc.driver, 3, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_theme_use)).click() except TimeoutException: sc.logger.info('当前页面无已下载的主题') WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_theme_download)).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name("存草稿")).click() sc.logger.info('预览页-主题测试完成')
def test_edit_collage_01_img(self): """剪辑-画中画-图片添加.""" sc.logger.info('剪辑-画中画-图片添加') fun_name = 'test_edit_collage_img' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“效果”') WebDriverWait(sc.driver, 5, 1).until( lambda x: x.find_element_by_name("效果")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击"画中画"') WebDriverWait(sc.driver, 5, 1).until( lambda x: x.find_element_by_name('画中画')).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('添加图片画中画') ba.collage_add('图片') sc.capture_screen(fun_name, self.img_path) sc.logger.info('确认添加') ba.effect_add_confirm() sc.logger.info('剪辑-画中画-图片添加测试完成')
def test_edit_music_01(self): """剪辑-多段配乐-添加.""" sc.logger.info('剪辑-多段配乐-添加') fun_name = 'test_music_add' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“效果”') WebDriverWait(sc.driver, 5, 1).until( lambda x: x.find_element_by_name("效果")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info("添加一段'配乐'") ba.effects_music() sc.capture_screen(fun_name, self.img_path) sc.logger.info('确认添加') ba.effect_add_confirm() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') WebDriverWait(sc.driver, 5, 1).until( lambda el: el.find_element_by_name("存草稿")).click() sc.logger.info('剪辑-多段配乐-添加测试完成')
def test_clips_add_01(self): """剪辑-添加镜头-相册添加.""" sc.logger.info('剪辑-添加镜头-相册添加') fun_name = 'test_edit_add_clips' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“镜头编辑”') WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name("镜头编辑")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('从相册添加') ba.clip_add('相册') sc.capture_screen(fun_name, self.img_path) sc.logger.info('退出预览页') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_pre_clo)).click() sc.logger.info('剪辑-添加镜头-相册添加测试完成')
def test_edit_proportion(self): '''剪辑-比例&多选.''' sc.logger.info('剪辑-比例') fun_name = 'test_edit_proportion' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“镜头编辑”') WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name("镜头编辑")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击"比例"') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name("比例")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('切换到"比例tab"') try: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.btn_bg_pro)).click() sc.capture_screen(fun_name, self.img_path) except TimeoutException: sc.logger.info('已经在"比例tab"') sc.logger.info('选择"1:1 比例"') el_proportion = "vivavideo_edit_icon_proportion_1_1" ba.clip_proportion(el_proportion) sc.capture_screen(fun_name, self.img_path) sc.logger.info('进入多选') try: WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_xpath( '//XCUIElementTypeStaticText[@name="点击多选"]')).click() sc.capture_screen(fun_name, self.img_path) except TimeoutException: sc.logger.info('当前工程只有一个镜头,无法进入多选') return True sc.logger.info('多选-删除') ba.clip_mult_select() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name("存草稿")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('剪辑-比例测试完成')
def test_camera_self(self): """拍摄-自拍视频(全屏).""" sc.logger.info('拍摄-美颜趣拍(全屏)') fun_name = 'test_camera_self' sc.logger.info('点击“美颜趣拍”') ba.home_first_click("美颜趣拍") sc.capture_screen(fun_name, self.img_path) # 第一次从次要功能位打开自拍,拍摄按钮是音乐视频的控件,所以先关闭再打开 sc.logger.info('退出拍摄') time.sleep(1) WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_cam_close)).click() sc.logger.info('点击“美颜趣拍”') WebDriverWait( sc.driver, 5).until(lambda x: x.find_element_by_name('美颜趣拍')).click() sc.logger.info('点击人脸贴纸icon') ba.find_element_click('name', 10, iOS_elements.el_sticker_icon) sc.capture_screen(fun_name, self.img_path) sc.logger.info('下载人脸贴纸') WebDriverWait(sc.driver, 5).until(lambda x: x.find_element_by_xpath( iOS_elements.el_sticker_download)).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('使用下载的人脸贴纸') ba.find_element_click('xpath', 10, iOS_elements.el_sticker_used) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击屏幕消除贴纸控件') actions = TouchAction(sc.driver) actions.tap(None, 200, 200).release().perform() sc.capture_screen(fun_name, self.img_path) # 点拍 sc.logger.info('拍摄一段5s的视频') btn_rec = WebDriverWait(sc.driver, 10).until( lambda x: x.find_element_by_xpath(iOS_elements.el_cp_self)) ba.video_capture('点拍', btn_rec, 5) sc.logger.info('取消限制弹窗') try: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_cancel)).click() except TimeoutException: sc.logger.info('限制弹窗已取消') sc.logger.info('点击“存草稿”按钮') sc.driver.find_element_by_name("存草稿").click() sc.logger.info('拍摄-美颜趣拍(全屏)测试完成')
def test_edit_sound_01_rec(self): """剪辑-配音-录制.""" sc.logger.info('剪辑-配音-录制') fun_name = 'test_edit_sound_rec' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“效果”') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name("效果")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('左滑并点击"配音和音效"') el_loc = WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name('画中画')) ba.swipe_left(el_loc, 0.3, 300) WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name('配音和音效')).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('删除已添加的配音或音效') try: WebDriverWait( sc.driver, 3, 1).until(lambda x: x.find_element_by_accessibility_id( iOS_elements.btn_rec_start)) except TimeoutException: sc.logger.info('当前位置已添加配音或音效,删除后录制') sc.driver.find_element_by_name('删除').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('"录制"一段音频') ba.sound_rec_add() sc.capture_screen(fun_name, self.img_path) sc.logger.info('确认添加') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_confirm_btn)).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('剪辑-配音-录制添加测试完成')
def test_preview_time(self): """预览页-时长.""" sc.logger.info('预览页-时长') fun_name = 'test_preview_time' sc.logger.info('相册MV') ba.home_first_click('相册MV') sc.capture_screen(fun_name, self.img_path) sc.logger.info('添加图片') ba.gallery_clip_add('图片', 5) sc.logger.info('点击下一步进入预览页') ba.find_element_click('predicate', 10, iOS_elements.el_gallery_next) sc.logger.info('点击“镜头编辑”') WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name("镜头编辑")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“图片时长”') try: WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name("图片时长")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('应用于全部镜头') sc.driver.find_element_by_name('应用于全部镜头').click() sc.logger.info('点击“确认”') sc.driver.find_element_by_name(iOS_elements.el_confirm_btn).click() sc.capture_screen(fun_name, self.img_path) except TimeoutException: sc.logger.info('当前镜头是gif图片,直接存草稿') sc.logger.info('点击“存草稿”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name("存草稿")).click() sc.logger.info('预览页-时长测试完成')
def test_music_01_add(self): """预览页-配乐.""" sc.logger.info('配乐操作相关') fun_name = 'test_music_add' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“主题”') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name("主题")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('配乐相关操作') ba.preview_music() sc.capture_screen(fun_name, self.img_path) sc.logger.info('预览页-配乐测试完成')
def test_edit_filter(self): """剪辑-滤镜.""" sc.logger.info('剪辑-滤镜') fun_name = 'test_edit_filter' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“镜头编辑”') WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name("镜头编辑")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击"滤镜"') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name("滤镜")).click() sc.logger.info('点击"下载更多"') btn_more = '下载更多' ba.more_download(btn_more) sc.logger.info('使用滤镜') ba.material_used(iOS_elements.el_store_download2) sc.logger.info('确认添加') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_confirm_btn)).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name("存草稿")).click() sc.logger.info('剪辑-滤镜测试完成')
def test_edit_transition(self): """剪辑-转场-添加.""" sc.logger.info('剪辑-转场-添加') fun_name = 'test_edit_transition' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“镜头编辑”') WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name("镜头编辑")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“转场icon”') try: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.btn_transition_icon)).click() sc.capture_screen(fun_name, self.img_path) except TimeoutException: sc.logger.info('只有一个镜头,无法使用转场') return True sc.logger.info('下载并使用转场') ba.clip_transition() sc.logger.info('点击“存草稿”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name("存草稿")).click() sc.logger.info('剪辑-转场-添加测试完成')
def test_music_01_shot(self): """拍摄-音乐视频(3:4).""" sc.logger.info('拍摄-音乐视频(3:4)') fun_name = 'test_music_shot' sc.logger.info('点击音乐视频') ba.home_first_click('音乐视频') # 第一次从次要功能位打开音乐视频,拍摄按钮是另一个控件,所以先关闭再打开 sc.logger.info('退出拍摄') time.sleep(0.5) WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_cam_close)).click() # 退回首页后,常无法再次获取到音乐视频控件,此处重启一次app sc.logger.info('重启app') sc.driver.close_app() time.sleep(1) sc.driver.launch_app() sc.logger.info('点击音乐视频') ba.home_first_click('音乐视频') sc.logger.info('切换到3:4拍摄') time.sleep(1) ba.find_element_click('name', 5, iOS_elements.el_ful) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“点击添加配乐”按钮') sc.driver.find_element_by_name("点击添加配乐").click() time.sleep(2) sc.logger.info('下拉刷新') start_x = self.width // 2 start_bottom = self.height // 5 sc.swipe_by_ratio(start_x, start_bottom, 'down', 0.3, 300) sc.logger.info('下载音乐') music_list = sc.driver.find_elements_by_name( iOS_elements.el_mus_download) # music_list.pop(0) if len(music_list) >= 4: music_list = music_list[1:4] for el_music in music_list: el_music.click() time.sleep(0.5) time.sleep(10) sc.logger.info('点击一首已下载音频试听') WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_mus_play)).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“添加”按钮') time.sleep(5) WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_name('添加')).click() sc.capture_screen(fun_name, self.img_path) # 点拍 sc.logger.info('拍摄一段5s的视频') btn_rec = WebDriverWait(sc.driver, 10).until( lambda x: x.find_element_by_xpath(iOS_elements.el_cp_music)) ba.video_capture('点拍', btn_rec, 5) sc.logger.info('取消限制弹窗') try: WebDriverWait(sc.driver, 3, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_cancel)).click() except TimeoutException: sc.logger.info('限制弹窗已取消') sc.logger.info('返回创作页') ba.back_to_home() sc.logger.info('拍摄-音乐视频(3:4)完成')
def test_template_06_sticker(self): """素材中心-动画贴纸.""" sc.logger.info('素材中心-动画贴纸') fun_name = 'test_template_sticker' ba.home_first_click('素材中心') sc.capture_screen(fun_name, self.img_path) sc.logger.info('向上滑动') el_text = sc.driver.find_element_by_name("字幕") coord_x = el_text.location.get('x') coord_y = el_text.location.get('y') sc.swipe_by_ratio(coord_x, coord_y, 'up', 0.5, 500) sc.logger.info('点击“动画贴纸”') WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name('动画贴纸')).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('下载并使用动画贴纸') ba.material_used(iOS_elements.el_store_download1) sc.capture_screen(fun_name, self.img_path) sc.logger.info('添加"视频"') ba.gallery_clip_add('视频', 2) sc.logger.info('点击下一步进入预览页') ba.find_element_click('predicate', 10, iOS_elements.el_gallery_next) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“确认”') ba.effect_add_confirm() sc.logger.info('点击“存草稿”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name("存草稿")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作页') WebDriverWait(sc.driver, 5, 1).until(lambda el: el.find_element_by_name( iOS_elements.el_com_back)).click() WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name('素材中心')).click() sc.logger.info('向上滑动') sc.swipe_by_ratio(coord_x, coord_y, 'up', 0.5, 500) sc.logger.info('点击“动画贴纸”') WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name('动画贴纸')).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('删除下载的动画贴纸') ba.material_manager('动画贴纸', iOS_elements.el_store_del) sc.capture_screen(fun_name, self.img_path) sc.logger.info('素材中心-动画贴纸测试完成')
def test_template_01_theme(self): """素材中心-主题.""" sc.logger.info('素材中心-主题') fun_name = 'test_template_theme' ba.home_first_click('素材中心') sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击顶部banner') WebDriverWait(sc.driver, 5, 1).until(lambda el: el.find_element_by_accessibility_id( iOS_elements.el_banner)).click() sc.logger.info('返回') try: WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_xpath( '//XCUIElementTypeButton[@name="vivavideo com nav back n"]' )).click() except TimeoutException: WebDriverWait( sc.driver, 3, 1).until(lambda el: el.find_element_by_xpath( '//XCUIElementTypeButton[@name="vivavideo back n"]') ).click() sc.logger.info('点击“主题”') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name('主题')).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('下载并使用主题') ba.material_used(iOS_elements.el_store_download1) sc.capture_screen(fun_name, self.img_path) sc.logger.info('添加"视频"') ba.gallery_clip_add('视频', 2) sc.logger.info('点击下一步进入预览页') ba.find_element_click('predicate', 10, iOS_elements.el_gallery_next) sc.capture_screen(fun_name, self.img_path) sc.logger.info('取消限制弹窗') try: WebDriverWait(sc.driver, 3, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_cancel)).click() except TimeoutException: sc.logger.info('限制弹窗已取消') sc.logger.info('点击“存草稿”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name("存草稿")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('返回创作页') WebDriverWait(sc.driver, 5, 1).until(lambda el: el.find_element_by_name( iOS_elements.el_com_back)).click() WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name('素材中心')).click() sc.logger.info('点击“主题”') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name('主题')).click() sc.logger.info('删除下载的主题') ba.material_manager('主题', iOS_elements.el_store_del) sc.capture_screen(fun_name, self.img_path) sc.logger.info('素材中心-主题测试完成')
def test_edit_sticker(self): """剪辑-动画贴纸-添加.""" sc.logger.info('剪辑-动画贴纸-添加') fun_name = 'test_edit_sticker' sc.logger.info('打开一个草稿视频') ba.home_first_click('更多草稿') sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_studio_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“效果”') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name("效果")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“贴纸”') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name("贴纸")).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('添加一个普通"贴纸"') ba.sticker_comm_add() sc.logger.info('确认添加') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_confirm_btn)).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('添加第二个贴纸并放弃') WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_name('添加')).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击GIF') WebDriverWait( sc.driver, 10, 1).until(lambda x: x.find_element_by_name('GIF')).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('添加一个GIF"贴纸"') ba.material_used('下载') sc.capture_screen(fun_name, self.img_path) sc.logger.info('确定') time.sleep(0.5) WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_confirm_btn)).click() sc.logger.info('取消添加') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_cancel_btn)).click() sc.capture_screen(fun_name, self.img_path) # iOS此处有一个bug,贴纸未添加完成时,点击x,未弹出放弃弹窗(7.2.2已修复) sc.logger.info('确定放弃') try: WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name('确认')).click() sc.capture_screen(fun_name, self.img_path) except TimeoutException: sc.logger.error('iOS此处有一个bug,贴纸未添加完成时,点击x,未弹出放弃弹窗') sc.logger.info('点击“存草稿”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name("存草稿")).click() sc.logger.info('剪辑-动画贴纸-添加测试完成')