def test_c_upload_video(self): """上传视频""" video = self.video self.assertEqual('+ 上传', video.text_upload_btn(), '当前页面没有上传按钮,无法继续操作!') self.log.info('上传视频操作开始.') video.click_upload_btn() time.sleep(1) video.input_upload_video_name('测试视频') video.input_upload_video_dec('测试视频描述') typesetting = video.elements_typesetting() self.random_check(typesetting, list_name='typesetting') video.click_upload_img() uploaded() video.click_upload_video() uploaded(type=1) while True: video_success = video.text_upload_success() mb_list = re.findall('(\d+\.\d+)', video_success) if float(mb_list[0]) == float(mb_list[1]): break else: self.log.info('视频大小:{}mb,已上传:{}mb'.format( mb_list[1], mb_list[0])) time.sleep(2) time.sleep(1) video.click_upload_sure_btn() time.sleep(1) self.assertEqual('测试视频', video.text_check_upload_success(), '上传视频失败!') self.log.info('上传视频成功.')
def test_c_edit_article(self): """编辑文章""" article = self.article self.switch_self(article, 1, make=1) article.move_edit_option() time.sleep(1) self.assertEqual('编辑文章', article.text_check_newly(), '没有进入编辑文章页面!') self.log.info('文章编辑中...') time.sleep(1) article.input_article_title('做了父母,我们更要相爱') time.sleep(1) article.click_article_author() time.sleep(1) author_list = article.elements_article_author() self.random_check(author_list, list_name='author_list') time.sleep(1) article.click_article_class1() time.sleep(1) article_class_list = article.elements_article_class2() self.random_check(article_class_list, list_name='article_class_list') time.sleep(1) article_class_list1 = article.elements_article_class3() self.random_check(article_class_list1, list_name='article_class_list1') list_style = article.elements_new_list_style() style = self.random_check(list_style, make=1, list_name='list_style') if style: # 上传图片 for i in range(3): article.click_up_img() uploaded() else: article.click_up_img() uploaded() time.sleep(1) article.click_edit_tag() time.sleep(1) article.input_edit_input_tag('test1') article.send_keys_enter() age_tag_list = article.elements_new_age_tag() self.random_check(age_tag_list, list_name='age_tag_list') other_tag_list = article.elements_other_age_tag() self.random_check(other_tag_list, list_name='other_tag_list') frame_list = article.elements_frame_age_tag() global frame_num frame_num = self.random_check(frame_list, make=1, list_name='frame_list') article.input_link_address('https://mp.weixin.qq.com/s/w0dTikK5q7ov0AbPkQYM5g') # article.click_cancel() article.click_sure_btn() time.sleep(1) if frame_num == 0: pass else: article.click_lower_btn() if self.check_lower_btn(article): self.log.info('选中下架中按钮成功.') else: self.log.error('没有选中下架中按钮!') return self.check_article_new_success(article, '做了父母,我们更要相爱')
def input_test_page_data(self, shop): """输入test页面内容""" shop.input_page_name('test') shop.input_page_share_name('这是一个测试页面.') shop.click_share_img() uploaded() shop.click_is_share() # shop.click_cancel_btn() time.sleep(1) shop.click_new_page_sure_btn()
def two_ad_shop(self, shop, make=False, img=False, carousel=False, left=False): """两列广告、图文广告操作""" if img: shop.click_two_add_img_ad() shop.click_two_add_img() uploaded() if self.img and self.three and self.four: shop.input_two_text3('test3') shop.click_two_choice_link3() elif self.img and self.three: shop.input_two_text2('test2') shop.click_two_choice_link2() else: try: shop.input_two_text1('test1') shop.click_two_choice_link1() except AttributeError: shop.input_two_text('test') shop.click_two_choice_link() if make: if carousel or left: shop.click_add_ad() else: shop.click_two_add_ad() uploaded() if self.two and self.three and self.four: time.sleep(1) shop.click_choice_link3() elif self.three and self.two: shop.click_choice_link2() elif self.two: shop.click_choice_link1() else: shop.click_choice_link() time.sleep(1) self.assertEqual('选择数据', shop.text_check_data(), '选择数据弹窗未弹出!') n = random.randint(0, len(shop.elements_type()) - 1) shop.clicks_type(n) time.sleep(1) if img: self.choice_data(shop, type='ad', make=n, ad=True, two=True, img=True) return True if make: self.choice_data(shop, type='ad', make=n, ad=True, two=True) return True
def test_e_edit_video(self): """视频信息编辑""" video = self.video video.click_video_manage() self.assertEqual('+ 新增视频', video.text_newly_btn_video(), '当前页面不在视频管理页,无法进行编辑操作!') self.log.info('选择视频专辑,进行编辑操作.') video.click_lower_btn() if not self.check_video_is_test(video, make=1, name='这是一个测试视频'): return video.click_teacher() teacher_name = video.elements_check_teacher_name() self.random_check(teacher_name, list_name='teacher_name') time.sleep(1) video.click_video_class1() time.sleep(1) video_class2 = video.elements_video_class2() self.random_check(video_class2, list_name='video_class2') time.sleep(1) video_class3 = video.elements_video_class3() self.random_check(video_class3, list_name='video_class3') video.input_video_title('这是一个编辑测试视频') video.input_description('这是一个编辑测试描述') time.sleep(1) course_tag = video.elements_course_tag() self.random_check(course_tag, list_name='course_user_tag') course_user_tag = video.elements_course_user_tag() self.random_check(course_user_tag, list_name='course_user_tag') img_type = video.elements_img_type() self.random_check(img_type) read_link = video.elements_read_link() read_link_num = self.random_check(read_link, make=1, list_name='read_link') time.sleep(1) if read_link_num: video.input_link_info( 'https://mp.weixin.qq.com/s/w0dTikK5q7ov0AbPkQYM5g') else: video.input_article('test课程介绍.') video.click_cover_img() uploaded() video.click_share_img() uploaded() time.sleep(1) video.click_sure_btn() time.sleep(1) if self.check_lower_btn(video) == 1: video.click_lower_btn() time.sleep(1) if not self.check_video_is_test(video, make=2, name='这是一个编辑测试视频'): self.log.info('视频信息编辑保存失败,跳转页面错误!') else: self.log.info('视频信息编辑保存成功.')
def test_b_newly_scene(self): """新增""" scene = self.scene self.assertEqual(scene.text_check_scene_text(), '情景互动', '当前页面不在情景互动栏,无法进行新增操作!') self.log.info('开始进行新增情景互动操作.') scene_type = scene.elements_scene_type() global _type _type = self.random_check(scene_type, scene, make=1) scene.click_scene_newly_btn() time.sleep(1) self.assertEqual('新增{}类'.format(_type), scene.text_check_newly_text(), '没有弹出新增弹窗!') self.log.info('弹出新增弹窗成功,进行新建操作.') scene.input_description('test') scene.input_popup_title('test标题') if _type in ['课程', '文章']: scene.click_add_type_info() self.check_scene_info(scene) scene.input_config_word('test文案') if _type == '文章': scene.click_upload_img_btn() uploaded() scene.click_again_add() self.check_scene_info(scene) scene.input_second_config_word('第二个test文案') if _type == '文章': scene.click_upload_img_btn() uploaded() time.sleep(1) else: for i in range(3): ran = random.randint(1000, 9999) scene.input_add_goods(ran) scene.click_add_btn() goods_list = scene.elements_delete_goods_btn() self.random_check(goods_list, scene) scene.click_delete_sure_btn() time.sleep(1) upper_list = scene.elements_is_upper_lower() global upper_type upper_type = self.random_check(upper_list, scene, make=3, list_name='upper_list') scene.click_sure_btn() time.sleep(1) if upper_type == 0: for element in scene.elements_scene_page_info(): if element.text == 'test': self.log.info('新增情景互动信息成功1.') elif upper_type == 1: scene.elements_upper_lower_btn()[1].click() time.sleep(1) for element in scene.elements_scene_page_info(): if element.text == 'test': self.log.info('新增情景互动信息成功.')
def test_b_newly_video(self): """新建视频""" video = self.video video.click_newly_video() self.assertEqual(video.text_newly_video(), '新增视频', '进入 新增视频 页失败!') self.log.info('进入 新增视频 页成功.') video.click_teacher() teacher_name = video.elements_check_teacher_name() self.random_check(teacher_name, list_name='teacher_name') time.sleep(1) video.click_video_class1() time.sleep(1) video_class2 = video.elements_video_class2() self.random_check(video_class2, list_name='video_class2') time.sleep(1) video_class3 = video.elements_video_class3() self.random_check(video_class3, list_name='video_class3') video.input_video_title('这是一个测试视频') video.input_description('这是一个测试描述') time.sleep(1) course_tag = video.elements_course_tag() self.random_check(course_tag, list_name='course_user_tag') course_user_tag = video.elements_course_user_tag() self.random_check(course_user_tag, list_name='course_user_tag') img_type = video.elements_img_type() self.random_check(img_type) read_link = video.elements_read_link() read_link_num = self.random_check(read_link, make=1, list_name='read_link') time.sleep(1) if read_link_num: video.input_link_info( 'https://mp.weixin.qq.com/s/w0dTikK5q7ov0AbPkQYM5g') else: video.input_article('test课程介绍.') video.click_cover_img() uploaded() video.click_share_img() uploaded() time.sleep(1) video.click_sure_btn() self.assertEqual('+ 上传', video.text_upload_btn(), '视频信息保存错误!') self.log.info('视频信息保存成功.')
def test_f_single_ad_shop(self): """装修页面-单列广告""" shop = self.shop self.title_list = [] self.assertEqual('test', shop.text_page_title(), '打开页面错误!') self.log.info('已选中新建页面,选择广告进行店铺装修.') time.sleep(1) shop.click_single_model() # 单列 shop.click_add_ad() uploaded() time.sleep(1) shop.click_choice_link4() time.sleep(1) self.assertEqual('选择数据', shop.text_check_data(), '选择数据弹窗未弹出!') n = random.randint(0, len(shop.elements_type()) - 1) shop.clicks_type(n) time.sleep(1) self.single = True self.choice_data(shop, type='ad', make=n, ad=True) self.save_page(shop)
def test_c_edit_teacher(self): """编辑老师""" teacher = self.teacher self.assertEqual(teacher.text_check_teacher_text(), '老师管理', '当前页面不在老师管理栏,无法进行编辑操作!') self.log.info('开始进行编辑老师管理操作.') self.check_add_teacher(teacher, make=1) time.sleep(1) self.assertEqual('修改老师', teacher.text_new_add_teacher(), '修改老师页面弹出异常!') self.log.info('修改老师页面正常显示,开始进行修改操作.') teacher.input_teacher_name('这是一个测试老师') teacher.input_teacher_phone('18701137211') teacher.input_tsocialTitle_phone('这是一个测试职称') sex_list = teacher.elements_teacher_sex() self.random_check(sex_list, teacher) teacher.click_upload_teacher_img() uploaded() time.sleep(1) teacher.click_sure_btn() time.sleep(1) self.check_add_teacher(teacher)
def test_b_newly_teacher(self): """新增老师""" teacher = self.teacher self.assertEqual(teacher.text_check_teacher_text(), '老师管理', '当前页面不在老师管理栏,无法进行新增操作!') self.log.info('开始进行新增老师管理操作.') teacher.click_new_add_teacher_btn() time.sleep(1) self.assertEqual('添加老师', teacher.text_new_add_teacher(), '添加老师页面弹出异常!') self.log.info('添加老师页面正常显示,开始进行添加操作.') teacher.input_teacher_name('test') teacher.input_teacher_phone('18701137212') teacher.input_tsocialTitle_phone('测试职称') sex_list = teacher.elements_teacher_sex() self.random_check(sex_list, teacher) teacher.click_upload_teacher_img() uploaded() time.sleep(1) teacher.click_sure_btn() time.sleep(1) self.check_add_teacher(teacher)