def test_edit_fx_01(self): """剪辑-特效下载.""" sc.logger.info('剪辑-特效下载') fun_name = 'test_edit_fx_download' sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('点击视频剪辑') WebDriverWait(sc.driver, 5, 1).until( lambda x: x.find_element_by_xpath(iOS_elements.el_home_edit)).click() sc.logger.info('添加视频') ba.gallery_clip_add('视频', 2) 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('点击“效果”') 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('剪辑-特效下载测试完成')
def test_share_01(self): """分享-标题&描述.""" sc.logger.info('分享-标题&描述.') fun_name = 'test_share_title' sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('点击第一个草稿封面') ba.find_element_click('xpath', 5, iOS_elements.el_home_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_loc_clo)).click() sc.capture_screen(fun_name, self.img_path) except TimeoutException: sc.logger.info('不是第一次点击保存/上传按钮') sc.logger.info('输入标题和描述') ba.publish_input() sc.capture_screen(fun_name, self.img_path) sc.logger.info('导出-标题&描述测试完成')
def test_home_01(self): """首页.""" sc.logger.info('首页') fun_name = 'test_home' sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('VIP订阅页面展示') sc.driver.find_element_by_xpath(iOS_elements.el_home_vip).click() sc.capture_screen(fun_name, self.img_path) sc.driver.find_element_by_name(iOS_elements.el_vip_close).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('首页广告展示及刷新') try: sc.driver.find_element_by_xpath(iOS_elements.el_home_ad).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('刷新广告') time.sleep(5) sc.driver.find_element_by_name(iOS_elements.el_ad_back).click() sc.logger.info('退出广告') try: WebDriverWait(sc.driver, 10, 1).until( lambda x: x.find_element_by_name(iOS_elements.el_ad_clo)).click() except TimeoutException: sc.logger.info('已经退出广告页面了') except NoSuchElementException: sc.logger.error('首页加载出错了') pass
def test_create_draft(self): """添加多个镜头创建草稿视频.""" sc.logger.info('创建一个草稿视频') fun_name = 'test_create_craft' sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('点击“视频剪辑”按钮') try: WebDriverWait(sc.driver, 3, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_home_edit)).click() except TimeoutException: WebDriverWait(sc.driver, 3, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.home_edit)).click() sc.logger.info('添加视频') ba.gallery_clip_add('视频', 3) 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('切换到图片') sc.driver.find_element_by_name("视频").click() sc.driver.find_element_by_name("图片").click() sc.logger.info('添加图片') ba.gallery_clip_add('图片', 5) 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.logger.info('点击“存草稿”按钮') WebDriverWait( sc.driver, 5, 1).until(lambda el: el.find_element_by_name("存草稿")).click() sc.logger.info('创建一个草稿视频完成')
def test_privacy_album(self): """权限获取""" sc.logger.info('权限获取') fun_name = 'test_privacy_album' sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('点击“视频剪辑”按钮') try: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_home_edit)).click() except TimeoutException: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.home_edit)).click() try: sc.driver.find_element_by_name("跳过").click() sc.capture_screen(fun_name, self.img_path) except NoSuchElementException: sc.logger.info('已跳过订阅页面') 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) WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name("好")).click() except TimeoutException: sc.logger.info("已授权") sc.logger.info('返回首页') WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.gallery_back)).click() sc.logger.info('相册授权测试完成')
def test_clip_edit_function(self): """剪辑-镜头编辑-功能遍历.""" sc.logger.info('剪辑-镜头编辑-功能遍历') fun_name = 'test_clip_edit_function' sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('点击草稿封面') ba.open_draft(iOS_elements.el_home_draft) sc.capture_screen(fun_name, self.img_path) sc.logger.info('功能遍历') ba.clip_fun_loop() 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_gallery_01(self): """相册-视频相关操作.""" sc.logger.info('相册-视频相关操作') fun_name = 'test_gallery_video' sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('点击“视频剪辑”按钮') try: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_home_edit)).click() except TimeoutException: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.home_edit)).click() sc.logger.info('选择一个视频并进行相关操作') ba.gallery_clip_op() sc.capture_screen(fun_name, self.img_path) sc.logger.info('相册-视频相关操作测试完成')
def test_cancel_01_shot(self): """拍摄-拍摄页放弃.""" sc.logger.info('拍摄-拍摄页放弃') fun_name = 'test_cancel_shot' sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('点击“美颜趣拍”') WebDriverWait( sc.driver, 5).until(lambda x: x.find_element_by_name('美颜趣拍')).click() sc.logger.info('切换拍摄模式:自拍美颜->高清相机') el_normal = "高清相机" ba.find_element_click('name', 5, el_normal) 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_normal)) 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) sc.logger.info('点击左上角取消按钮') ba.find_element_click('name', 5, iOS_elements.el_cam_close) sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“丢弃”按钮') ba.find_element_click('name', 5, iOS_elements.el_discard) sc.logger.info('拍摄-拍摄页放弃测试完成')
def test_preview_theme(self): """预览页-主题·配乐页面.""" sc.logger.info('预览页-主题·配乐页面') fun_name = 'test_preview_theme' sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('点击“视频剪辑”按钮') try: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_home_edit)).click() except TimeoutException: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.home_edit)).click() sc.logger.info('添加视频') ba.gallery_clip_add('视频', 1) sc.capture_screen(fun_name, self.img_path) sc.logger.info('切换到图片') sc.driver.find_element_by_name("视频").click() sc.driver.find_element_by_name("图片").click() sc.logger.info('添加图片') ba.gallery_clip_add('图片', 2) sc.capture_screen(fun_name, self.img_path) 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('暂停播放') WebDriverWait(sc.driver, 10, 1).until( lambda x: x.find_element_by_name(iOS_elements.btn_stop)).click() 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('下载更多') sc.driver.find_element_by_name('下载更多').click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('下拉刷新') ba.refresh('down', 0.3, 500, 1) time.sleep(3) sc.logger.info('下载并使用主题') try: WebDriverWait( sc.driver, 5, 1).until(lambda x: x.find_element_by_name("使用")).click() except TimeoutException: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_store_download1)).click() 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('暂停播放') WebDriverWait(sc.driver, 10, 1).until( lambda x: x.find_element_by_name(iOS_elements.btn_stop)).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_normal_01_filter(self): """拍摄-滤镜下载.""" sc.logger.info('拍摄-滤镜下载') fun_name = 'test_normal_filter_download' start_x = self.width // 2 start_y = self.height // 8 start_bottom = self.height - start_y sc.logger.info('点击创作中心主按钮') ba.home_enter() sc.logger.info('点击“高清拍摄”按钮') try: WebDriverWait(sc.driver, 3, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.home_camera)).click() except TimeoutException: WebDriverWait(sc.driver, 3, 1).until(lambda x: x.find_element_by_xpath( iOS_elements.el_home_camera)).click() sc.logger.info('点击滤镜图标') time.sleep(1) try: WebDriverWait(sc.driver, 5, 1).until(lambda x: x.find_element_by_name( iOS_elements.el_filter_icon)).click() except TimeoutException: sc.logger.info('滤镜列表已自动弹出') sc.capture_screen(fun_name, self.img_path) sc.logger.info('下载滤镜') try: sc.logger.info('点击下载按钮') sc.driver.find_element_by_xpath( iOS_elements.el_filter_download).click() sc.capture_screen(fun_name, self.img_path) try: sc.driver.find_element_by_name('取消').click() except NoSuchElementException: sc.logger.info('该滤镜不是解锁滤镜') except NoSuchElementException: sc.logger.info('当前页面已无未下载滤镜') sc.logger.info('下载更多') try: time.sleep(0.5) sc.driver.find_element_by_name(iOS_elements.el_filter_more).click() sc.capture_screen(fun_name, self.img_path) except NoSuchElementException: sc.logger.info('当前页面是vip订阅页面') sc.driver.find_element_by_name(iOS_elements.el_vip_close).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('重新点击下载更多') sc.driver.find_element_by_name(iOS_elements.el_filter_more).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('下载并使用滤镜') while True: try: sc.driver.find_element_by_name( iOS_elements.el_store_download2).click() break except NoSuchElementException: sc.logger.info('当前页面已无未下载主题') sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) sc.logger.info('使用滤镜') WebDriverWait(sc.driver, 20, 1).until(lambda x: x.find_element_by_name("使用")).click() sc.logger.info('退出拍摄') ba.find_element_click('name', 5, iOS_elements.el_cam_close) sc.logger.info('拍摄-滤镜下载测试完成')