def test_gallery_02(self): """相册-图片相关操作.""" sc.logger.info('相册-图片相关操作') fun_name = 'test_gallery_img' sc.logger.info('选择图片') WebDriverWait( sc.driver, 3, 1).until(lambda el: el.find_element_by_name('视频')).click() WebDriverWait( sc.driver, 3, 1).until(lambda el: el.find_element_by_name('图片')).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('选择一个图片并进行相关操作') ba.gallery_clip_op() sc.capture_screen(fun_name, self.img_path) 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.back_to_home() sc.logger.info('相册-图片相关操作测试完成')
def test_template_03_fx(self): """素材中心-特效.""" sc.logger.info('素材中心-特效') fun_name = 'test_template_effect' 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.refresh('down', 0.3, 500, 1) try: sc.logger.info('点击"使用"') WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name("使用")).click() except TimeoutException: sc.logger.info('该素材尚未下载,下载后再"使用"') time.sleep(1) fx_cover = '//*/XCUIElementTypeCollectionView/*/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeButton' WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_xpath(fx_cover)).click() WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name('下载')).click() WebDriverWait( sc.driver, 10, 1).until(lambda x: x.find_element_by_name("使用")).click() 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('返回创作页') ba.back_to_home() ba.home_first_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_manager('特效', iOS_elements.el_store_del) sc.capture_screen(fun_name, self.img_path) sc.logger.info('素材中心-特效测试完成')
def test_template_06_sticker(self): """素材中心-动画贴纸.""" sc.logger.info('素材中心-动画贴纸') fun_name = 'test_template_sticker' 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.7, 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('返回创作页') ba.back_to_home() ba.home_first_click('素材中心') 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.7, 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_02_filter(self): """素材中心-滤镜.""" sc.logger.info('素材中心-滤镜') fun_name = 'test_template_filter' 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_download2) 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('点击“确认”') sc.driver.find_element_by_name(iOS_elements.el_confirm_btn).click() sc.logger.info('返回创作页') ba.back_to_home() 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.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_04_font(self): """素材中心-字体.""" sc.logger.info('素材中心-字体') fun_name = 'test_template_font' ba.home_first_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('点击“确认”') ba.effect_add_confirm() sc.logger.info('返回创作页') ba.back_to_home() ba.home_first_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_manager('字体', iOS_elements.el_store_del) sc.capture_screen(fun_name, self.img_path) sc.logger.info('素材中心-字体测试完成')
def test_music_02(self): """拍摄-音乐视频(3:4)-音频使用.""" sc.logger.info('拍摄-音乐视频(3:4)-音频使用') fun_name = 'test_music_use' sc.logger.info('点击一首已下载音频试听') try: WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_mus_title1)).click() except: WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_mus_title2)).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('拍摄一段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_08_transition(self): """素材中心-转场.""" sc.logger.info('素材中心-转场') fun_name = 'test_template_transition' start_x = self.width // 2 start_y = self.height // 8 start_bottom = self.height - start_y 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.7, 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('向上滑动直到最底部') while True: try: sc.driver.find_element_by_name("没有更多了…").click() break except NoSuchElementException: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.7, 300) 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('点击“确认”') sc.driver.find_element_by_name(iOS_elements.el_confirm_btn).click() sc.logger.info('返回创作页') ba.back_to_home() ba.home_first_click('素材中心') 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.7, 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_xpath( 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: sc.driver.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('返回创作页') ba.back_to_home() 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_music_03(self): """拍摄-音乐视频-更换音乐重录.""" sc.logger.info('拍摄-音乐视频-更换音乐重录') fun_name = 'test_music_change' sc.logger.info('点击音乐视频') time.sleep(1) sc.driver.find_element_by_name('音乐视频').click() sc.logger.info('点击“点击添加配乐”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name('点击添加配乐')).click() sc.logger.info('点击一首已下载音频试听') try: WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_mus_title1)).click() except: WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_mus_title2)).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“添加”按钮') sc.driver.find_element_by_name('添加').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击音乐标题') WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_mus_change)).click() sc.logger.info('更换音乐重录') sc.driver.find_element_by_name("更换音乐重录").click() sc.logger.info('点击一首已下载音频试听') try: WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_mus_title1)).click() except: WebDriverWait(sc.driver, 10, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_mus_title2)).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“添加”按钮') sc.driver.find_element_by_name('添加').click() sc.capture_screen(fun_name, self.img_path) # 点拍 sc.logger.info('开始录制') el_capture = WebDriverWait(sc.driver, 10).until( lambda x: x.find_element_by_xpath(iOS_elements.el_cp_music)) el_capture.click() sc.capture_screen(fun_name, self.img_path) time.sleep(5) sc.logger.info('录制5s后点击录制按钮停止录制') el_capture.click() sc.capture_screen(fun_name, self.img_path) try: sc.logger.info('点击确认按钮') WebDriverWait(sc.driver, 5, 1).until(lambda el: el.find_element_by_name( iOS_elements.el_cam_next)).click() except TimeoutException: sc.logger.info('音乐时长较短,已自动跳转预览页') 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('返回创作页') ba.back_to_home() sc.logger.info('拍摄-音乐视频-更换音乐重录完成')