def test_camera_self(self): """拍摄-自拍视频(1:1).""" sc.logger.info('拍摄-美颜趣拍(1:1)') fun_name = 'test_camera_self' sc.logger.info('点击创作中心主按钮') sc.first_step(self.c_btn) sc.logger.info('点击“美颜趣拍”') sc.driver.find_element_by_android_uiautomator('text("美颜趣拍")').click() sc.logger.info('点击摄像头反转按钮') switch_btn = 'com.quvideo.xiaoying:id/img_switch' sc.driver.find_element_by_id(switch_btn).click() sc.capture_screen(fun_name, self.img_path) el_cp = sc.driver.find_element_by_id('com.quvideo.xiaoying:id/btn_rec') # 长按拍摄5s sc.logger.info('长按拍摄5s') actions = TouchAction(sc.driver) actions.long_press(el_cp, None, None, 5000).release().perform() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击确认按钮') next_btn = 'com.quvideo.xiaoying:id/cam_btn_next' sc.driver.find_element_by_id(next_btn).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') sc.driver.find_element_by_android_uiautomator('text("存草稿")').click() sc.logger.info('美颜趣拍测试完成,点击返回按钮返回主页面') left_btn = 'com.quvideo.xiaoying:id/xiaoying_com_btn_left' sc.driver.find_element_by_id(left_btn).click() sc.logger.info('拍摄-美颜趣拍拍摄完成')
def test_video_origin(self): """video详情页面的初始状态.""" sc.logger.info('video详情页初始状态检查开始') fun_name = 'test_video_origin' sc.logger.info('点击个人中心主按钮') sc.first_step(self.p_btn) sc.logger.info('点击第一个视频标题') el_video_til = 'com.quvideo.xiaoying:id/xiaoying_com_video_card_title' WebDriverWait( sc.driver, 10, 1).until(lambda el: el.find_element_by_id(el_video_til)).click() sc.logger.info('video详情页面初始状态截图开始') sc.capture_screen(fun_name, self.img_path)
def test_normal_filter_download(self): """拍摄-滤镜下载.""" sc.logger.info('拍摄-滤镜下载') fun_name = 'test_normal_filter_download' effect_btn = 'com.quvideo.xiaoying:id/cam_btn_filter_effect' sc.logger.info('点击创作中心主按钮') sc.first_step(self.c_btn) sc.logger.info('点击“拍摄”') sc.driver.find_element_by_id('com.quvideo.xiaoying:id/icon2').click() sc.logger.info('点击滤镜图标') sc.driver.find_element_by_id(effect_btn).click() try: filter_down_btn = 'com.quvideo.xiaoying:id/icon_filter_download' el_filter_download = sc.driver.find_element_by_id(filter_down_btn) 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: filter_p_btn = 'com.quvideo.xiaoying:id/item_fitler_parent_cover' el_filter_list = sc.driver.find_elements_by_id(filter_p_btn) sc.logger.info('点击第三个滤镜主题') el_filter_list[2].click() time.sleep(1) filter_cover_btn = 'com.quvideo.xiaoying:id/item_fitler_child_cover' el_child_filter = sc.driver.find_element_by_id(filter_cover_btn) sc.logger.info('点击第一个滤镜') el_child_filter.click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('退出滤镜选项') sc.driver.press_keycode(4) time.sleep(1) sc.logger.info('返回创作中心主界面') sc.driver.press_keycode(4) sc.logger.info('拍摄-滤镜下载测试完成')
def test_login_origin(self): """测试登录页面未登录时的初始状态.""" sc.logger.info('登录页面初始状态检查测试开始') fun_name = 'test_login_origin' sc.logger.info('点击个人中心主按钮') if sc.first_step(self.p_btn) is True: time.sleep(1) sc.capture_screen(fun_name, self.img_path) assert True else: assert False
def test_login_qq(self): """国内用户测试使用qq登录.""" sc.logger.info('登录页面QQ登录测试开始') sc.first_step(self.p_btn) login_res = TestUserLogin.login_judge() if login_res is True: assert True else: sc.logger.info('点击“注册/登录”按钮') login_res.click() WebDriverWait( sc.driver, 10, 1).until(lambda el: el.find_element_by_android_uiautomator( 'text("使用其他账号登录")')).click() # username = '******' username = '******' # passwd = 'qa123456' passwd = 'qqqqaaaa' login_res = TestUserLogin.login_method('qq', username, passwd) assert login_res is not False
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 sc.logger.info('点击创作中心主按钮') sc.first_step(self.c_btn) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.8, 500) sc.logger.info('点击"画中画拍摄"') WebDriverWait(sc.driver, 5, 1).until( lambda el: el.find_element_by_android_uiautomator( 'text("画中画拍摄")')).click() # sc.driver.find_element_by_android_uiautomator('text("画中画拍摄")').click() sc.logger.info('切换样式') effect_img = 'com.quvideo.xiaoying:id/img_effect' content_img = 'com.quvideo.xiaoying:id/wheel_img_content' sc.driver.find_element_by_id(effect_img).click() el_wheel = sc.driver.find_element_by_id(content_img) 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('摄像位置互换') mode_img = 'com.quvideo.xiaoying:id/img_mode' sc.driver.find_element_by_id(mode_img).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('切换前后置') switch_btn = 'com.quvideo.xiaoying:id/img_switch' sc.driver.find_element_by_id(switch_btn).click() sc.capture_screen(fun_name, self.img_path) sc.logger.info('camera设置') setting_btn = 'com.quvideo.xiaoying:id/img_setting' sc.driver.find_element_by_id(setting_btn).click() try: flash_btn = 'com.quvideo.xiaoying:id/v4_img_flash' sc.driver.find_element_by_id(flash_btn).click() except NoSuchElementException: sc.logger.info('前置摄像头不支持闪光灯') sc.logger.info('点击倒计时按钮') timer_btn = 'com.quvideo.xiaoying:id/v4_img_timer' sc.driver.find_element_by_id(timer_btn).click() sc.logger.info('点击曝光锁定按钮') clock_btn = 'com.quvideo.xiaoying:id/v4_img_aelock' sc.driver.find_element_by_id(clock_btn).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_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 sc.logger.info('点击创作中心主按钮') sc.first_step(self.c_btn) time.sleep(2) sc.swipe_by_ratio(start_x, start_bottom, 'left', 0.8, 500) sc.logger.info('点击“音乐视频”') WebDriverWait(sc.driver, 5, 1).until( lambda el: el.find_element_by_android_uiautomator( 'text("音乐视频")')).click() # sc.driver.find_element_by_android_uiautomator('text("音乐视频")').click() sc.logger.info('点击视频比例按钮,切换到3:4') ratio_btn = 'com.quvideo.xiaoying:id/cam_btn_ratio' WebDriverWait(sc.driver, 10, 1).until( lambda el: el.find_element_by_id(ratio_btn)).click() sc.logger.info('切换摄像头') switch_btn = 'com.quvideo.xiaoying:id/img_switch' sc.driver.find_element_by_id(switch_btn).click() sc.logger.info('点击“请选择音乐”按钮') WebDriverWait(sc.driver, 5, 1).until( lambda el: el.find_element_by_android_uiautomator( 'text("请选择音乐")')).click() download_btn = 'com.quvideo.xiaoying:id/music_item_download' try: el_download = WebDriverWait(sc.driver, 10, 1).until( lambda el: el.find_element_by_id(download_btn)) except TimeoutException: sc.swipe_by_ratio(start_x, start_bottom, 'up', 0.4, 500) el_download = WebDriverWait(sc.driver, 10, 1).until( lambda el: el.find_element_by_id(download_btn)) sc.logger.info('点击第一个下载按钮') el_download.click() music_row = 'com.quvideo.xiaoying:id/music_item_name' sc.logger.info('点击第一首音乐名') WebDriverWait(sc.driver, 10, 1).until( lambda el: el.find_element_by_id(music_row)).click() sc.logger.info('点击播放/暂停按钮') play_btn = 'com.quvideo.xiaoying:id/music_item_play_state' WebDriverWait(sc.driver, 10, 1).until( lambda el: el.find_element_by_id(play_btn)).click() sc.logger.info('点击“添加”按钮') use_btn = 'com.quvideo.xiaoying:id/music_item_use' WebDriverWait(sc.driver, 10, 1).until( lambda el: el.find_element_by_id(use_btn)).click() el_cp = WebDriverWait(sc.driver, 10, 1).until( lambda x: x.find_element_by_id('com.quvideo.xiaoying:id/btn_rec')) # 长按拍摄5s sc.logger.info('长按拍摄5s') actions = TouchAction(sc.driver) actions.long_press(el_cp, None, None, 5000).release().perform() sc.capture_screen(fun_name, self.img_path) try: sc.logger.info('点击确认按钮') n_btn = 'com.quvideo.xiaoying:id/cam_btn_next' WebDriverWait(sc.driver, 10, 1).until( lambda el: el.find_element_by_id(n_btn)).click() except TimeoutException: sc.logger.info('音乐时长较短,已自动跳转预览页') sc.capture_screen(fun_name, self.img_path) sc.logger.info('点击“存草稿”按钮') draft_btn = 'com.quvideo.xiaoying:id/editor_draft' WebDriverWait(sc.driver, 10, 1).until( lambda el: el.find_element_by_id(draft_btn)).click() left_btn = 'com.quvideo.xiaoying:id/xiaoying_com_btn_left' WebDriverWait(sc.driver, 10, 1).until( lambda el: el.find_element_by_id(left_btn)).click() sc.logger.info('拍摄-音乐视频(3:4)完成')