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_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('首页-我的工作室完成')
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_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_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_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('相册-放弃操作相关操作测试完成')
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_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_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('剪辑-特效-放弃测试完成')
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_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_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_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_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('剪辑-配音-放弃测试完成')
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_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_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
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_edit_clips_shot(self): """剪辑-添加镜头-拍摄添加.""" sc.logger.info('剪辑-添加镜头-拍摄添加') fun_name = 'test_edit_clips_shot' 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_preview_layout_captrue').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.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('返回创作中心主界面') for i in range(3): sc.driver.press_keycode(4) sc.logger.info('剪辑-添加镜头-拍摄添加测试完成')
def test_edit_add_clips(self): """剪辑-添加镜头-相册添加.""" sc.logger.info('剪辑-添加镜头-相册添加') fun_name = 'test_edit_add_clips' 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 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_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.logger.info('返回创作中心主界面') for i in range(3): time.sleep(1) sc.driver.press_keycode(4) sc.logger.info('剪辑-添加镜头-相册添加测试完成')
def test_video_reply(self): """测试视频的评论功能.""" sc.logger.info('开始测试视频的评论功能.') fun_name = 'test_video_reply' start_x = self.width // 2 start_bottom = self.height - self.height // 4 time.sleep(1) # 先上滑半屏,便于处理全屏视频 sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.5, 300) # 查找评论框并输入'QA Reply Test' el_reply_frame = 'com.quvideo.xiaoying:id/comment_editor_view' el_reply = sc.driver.find_element_by_id(el_reply_frame) sc.logger.info('评论框输入“QA Reply Test”并发送') el_reply.send_keys('QA Reply Test') btn_reply = 'com.quvideo.xiaoying:id/comment_send_btn' sc.driver.find_element_by_id(btn_reply).click() sc.capture_screen(fun_name, self.img_path)
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_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_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('剪辑-转场-放弃测试完成')
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')
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
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('预览页-主题测试完成')
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_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
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