def testSendNinePics(self): self.case_id = get_case(__file__) if not is_login(self.driver): phone_number = '134' + str(randint(10000000, 99999999)) login_to_index(self.driver, MODE, desired_caps['appPackage'], phone_number) self.AddNinePicsTest()
def testExsit(self): step = 1 self.case_id = get_case(__file__) get_to_article_by_search(self.driver,AUDIO_ARTICLE,self.mode) all_time = get_alltime(self.driver) #print caclulate_for_audio('3:20',0.3) seekbar_sendkey(self.driver,0.7) sleep(WAIT_TIME) played_time = get_played_time(self.driver) real_time = caclulate_for_audio(all_time,0.7) assert abs(time_range_for_audio(played_time,real_time)) < 8 print u'Step %s:进度条右划测试:OK' % (str(step)) step+=1 seekbar_sendkey(self.driver,0.3) sleep(WAIT_TIME) played_time = get_played_time(self.driver) real_time = caclulate_for_audio(all_time,0.3) assert abs(time_range_for_audio(played_time,real_time)) < 8 print u'Step %s:进度条左划测试:OK' % (str(step)) step+=1 self.result = True
def testSearchSlide(self): step = 1 self.case_id = get_case(__file__) get_to_search(self.driver, self.mode) #搜索文章并检查样式 get_to_search(self.driver, self.mode) sleep(WAIT_TIME) seach_by_ui(self.driver, HEAD_ARTICLE) assert element_exsist(self.driver, 'id', SEARCH_EMPTY_TIPS) slide_left(self.driver) assert self.driver.find_element_by_id(SEARCH_ARTICLE).get_attribute( 'checked') == 'false' assert self.driver.find_element_by_id(SEARCH_HEAD).get_attribute( 'checked') == 'true' sleep(WAIT_TIME) assert element_exsist(self.driver, 'id', HEAD_PIC) print u'Step %s:划屏切换到报料搜索测试:OK' % (str(step)) step += 1 slide_right(self.driver) assert element_exsist(self.driver, 'id', SEARCH_EMPTY_TIPS) assert self.driver.find_element_by_id(SEARCH_ARTICLE).get_attribute( 'checked') == 'true' assert self.driver.find_element_by_id(SEARCH_HEAD).get_attribute( 'checked') == 'false' print u'Step %s:划屏切换到文章搜索测试:OK' % (str(step)) step += 1 self.result = True
def testExsit(self): step = 1 self.case_id = get_case(__file__) get_to_article_by_search(self.driver, AUDIO_ARTICLE, self.mode) all_time = get_alltime(self.driver) #print caclulate_for_audio('3:20',0.3) seekbar_sendkey(self.driver, 0.7) play_percent = int( self.driver.find_element( *AUDIO_PROGRESS).get_attribute('value').replace('%', '')) # sleep(WAIT_TIME) # played_time = get_played_time(self.driver) # real_time = caclulate_for_audio(all_time,0.7) # print time_range_for_audio(played_time,real_time) print play_percent assert abs(play_percent - 70) < 5 print u'Step %s:进度条右划测试:OK' % (str(step)) step += 1 seekbar_sendkey(self.driver, 0.3) play_percent = int( self.driver.find_element( *AUDIO_PROGRESS).get_attribute('value').replace('%', '')) print play_percent # sleep(WAIT_TIME) # played_time = get_played_time(self.driver) # real_time = caclulate_for_audio(all_time,0.3) #assert abs(time_range_for_audio(played_time,real_time)) < 8 assert abs(play_percent - 30) < 5 print u'Step %s:进度条左划测试:OK' % (str(step)) step += 1 self.result = True
def testVideoComment(self): article = VIDEO_ARTICLE self.comid = self.api.send_comment_by_name(article, 'digg count test') assert get_to_article_by_search(self.driver, article) self.case_id = get_case(__file__) self.result = self.common_check(self.driver, COMMENT_INPUT_IN_ARTICLE)
def test(self): self.case_id = get_case(__file__) step = 1 go_to_settings(self.driver) sleep(WAIT_TIME) assert set_push_state(self.driver, 'true') clear_notification(self.driver) msg1 = u'test1' msg2 = u'test2' push_info_a = self.db.get_push_info_by_name(NORMAL_ARTICLE) push_info_b = self.db.get_push_info_by_name(PHOTO_ARTICLE) self.jpush.push_article(push_info_a['model'], push_info_a['infoid'], msg=msg1) self.jpush.push_article(push_info_b['model'], push_info_b['infoid'], msg=msg2) ret = get_push_info(self.driver) print ret assert len(ret) == 2 and msg1 in ret and msg2 in ret print u'Step %s:推送多条新闻时测试:OK' % (str(step)) step += 1 self.result = True
def testAudioComment(self): article = AUDIO_ARTICLE self.comid = self.api.send_comment_by_name(article, 'digg count test') assert get_to_article_by_search(self.driver, article) go_to_comment_page(self.driver, COMMENT_ENTRANCE_AUDIO) self.case_id = get_case(__file__) self.result = self.common_check(self.driver)
def testExtComment(self): article = EXT_ARTICLE self.comid = self.api.send_comment_by_name(article, 'digg count test') assert get_to_article_by_search(self.driver, article) go_to_comment_page(self.driver) self.case_id = get_case(__file__) self.result = self.common_check(self.driver)
def test(self): self.case_id = get_case(__file__) step = 1 go_to_settings(self.driver) sleep(WAIT_TIME) assert get_push_state(self.driver) == 'true' print u'Step %s:设置中消息推送默认开启测试:OK' % (str(step)) step += 1 self.result = True
def testBigPicArticle(self): step = 1 self.case_id = get_case(__file__) #搜索文章并检查样式 get_to_search(self.driver, self.mode) seach_by_ui(self.driver, BIG_PIC_ARTICLE) sleep(WAIT_TIME) el_list = [BIG_TITLE, BIG_IMAGE] for el in el_list: assert element_exsist(self.driver, 'id', el) print u'Step %s:搜索结果中单大图新闻显示测试:OK' % (str(step)) step += 1 self.result = True
def testFlagArticle(self): step = 1 self.case_id = get_case(__file__) #搜索文章并检查样式 get_to_search(self.driver, self.mode) seach_by_ui(self.driver, FLAG_ARTICLE) sleep(WAIT_TIME) assert element_exsist(self.driver, 'id', NORMAL_TITLE) and element_exsist( self.driver, 'id', ARTICLE_FLAG) == False print u'Step %s:搜索结果中角标不显示测试:OK' % (str(step)) step += 1 self.result = True
def test(self): self.case_id = get_case(__file__) step = 1 go_to_settings(self.driver) sleep(WAIT_TIME) assert set_push_state(self.driver,'true') clear_notification(self.driver) msg1 = u'test1' self.jpush.push_notification(msg1) ret = get_push_info(self.driver) assert ret[0] ==msg1 print u'Step %s:推送开关打开时可接收推送测试:OK' % (str(step)) step+=1 #关闭推送并测试10秒内是否收的到 clear_notification(self.driver) assert set_push_state(self.driver,'false') msg2 = u'test2' self.jpush.push_notification(msg2) sleep(WAIT_TIME) ret = get_push_info(self.driver,timeout=20) assert ret == False print u'Step %s:推送关闭时无法接收推送测试:OK' % (str(step)) step+=1 #等待20秒打开推送 sleep(20) assert set_push_state(self.driver,'true') assert get_push_info(self.driver)[0] == msg2 print u'Step %s:消息保留时间内打开通知开关接收推送测试:OK' % (str(step)) step+=1 #关闭网络后推送,等待20秒打开网络 assert set_push_state(self.driver,'true') clear_notification(self.driver) change_network(self.driver,'none') msg3 = u'test3' self.jpush.push_notification(msg3) sleep(WAIT_TIME) ret = get_push_info(self.driver,timeout=20) assert ret == False sleep(20) change_network(self.driver,'wifi') assert get_push_info(self.driver,timeout=20)[0] == msg3 assert set_push_state(self.driver,'true') print u'Step %s:消息保留时间内重新打开网络接收推送测试:OK' % (str(step)) step+=1 self.result = True
def testThreePicArticle(self): step = 1 self.case_id = get_case(__file__) #搜索文章并检查样式 get_to_search(self.driver, self.mode) seach_by_ui(self.driver, THREE_PIC_ARTICLE) sleep(WAIT_TIME) el_list = [THREE_PIC_TITLE] el_list.extend(THREE_PIC_IMAGE) for el in el_list: print el assert element_exsist(self.driver, 'id', el) print u'Step %s:搜索结果中三小图新闻显示测试:OK' % (str(step)) step += 1 self.result = True
def testPushMsg(self): step = 1 self.case_id = get_case(__file__) clear_notification(self.driver) t = Thread(target=self.driver.background_app,args=(20,)) t.start() msg1 = u'test1' msg2 = u'test2' self.jpush.push_notification(msg1) self.jpush.push_notification(msg2) ret = get_push_info(self.driver) ret = [x.strip() for x in ret] assert len(ret) == 2 and msg1 in ret and msg2 in ret print u'Step %s:推送多条消息时测试:OK' % (str(step)) step+=1 self.result = True
def test(self): self.case_id = get_case(__file__) step = 1 go_to_settings(self.driver) sleep(WAIT_TIME) assert set_push_state(self.driver, 'true') clear_notification(self.driver) msg1 = u'test1' self.jpush.push_notification(msg1) ret = get_push_info(self.driver) assert ret[0] == msg1 clear_notification(self.driver) ret = get_push_info(self.driver) assert ret == False print u'Step %s:推送类型为notification测试:OK' % (str(step)) step += 1 self.result = True
def testVideoArticle(self): step = 1 self.case_id = get_case(__file__) #搜索文章并检查样式 get_to_search(self.driver, self.mode) seach_by_ui(self.driver, VIDEO_ARTICLE) sleep(WAIT_TIME) el_list = [NORMAL_TITLE, NORMAL_IMAGE] non_exsist_el_list = [VIDEO_TITLE, VIDEO_IMAGE] for el in el_list: assert element_exsist(self.driver, 'id', el) for non_el in non_exsist_el_list: assert element_exsist(self.driver, 'id', non_el) == False print u'Step %s:搜索结果中视频以单小图样式展示测试:OK' % (str(step)) step += 1 self.result = True
def testErrSearch(self): step = 1 self.case_id = get_case(__file__) #搜索文章 self.infoid = self.db.get_infoid_by_article_name(STATUS_ARTICLE) get_to_search(self.driver, self.mode) #文章为发布状态时搜索 seach_by_ui(self.driver, STATUS_ARTICLE) sleep(WAIT_TIME) assert element_exsist(self.driver,'id',SEARCH_EMPTY_TIPS) == False and \ element_exsist(self.driver,'id',SEARCH_ITEM) self.driver.find_element_by_id(SEARCH_CANCEL).click() #文章为被删除状态时搜索 self.db.del_article_by_db(self.infoid) seach_by_ui(self.driver, STATUS_ARTICLE) sleep(WAIT_TIME) assert element_exsist(self.driver, 'id', SEARCH_EMPTY_TIPS) self.driver.find_element_by_id(SEARCH_CANCEL).click() print u'Step %s:被删除新闻无法被搜索到测试:OK' % (str(step)) step += 1 #文章为未审核状态时搜索 self.db.set_article_unpublished_by_db(self.infoid) seach_by_ui(self.driver, STATUS_ARTICLE) sleep(WAIT_TIME) assert element_exsist(self.driver, 'id', SEARCH_EMPTY_TIPS) self.driver.find_element_by_id(SEARCH_CANCEL).click() print u'Step %s:未审核新闻无法被搜索到测试:OK' % (str(step)) step += 1 #文章为审核不通过时搜索 self.db.set_article_faield_by_db(self.infoid) seach_by_ui(self.driver, STATUS_ARTICLE) sleep(WAIT_TIME) assert element_exsist(self.driver, 'id', SEARCH_EMPTY_TIPS) self.driver.find_element_by_id(SEARCH_CANCEL).click() print u'Step %s:审核不通过新闻无法被搜索到测试:OK' % (str(step)) step += 1 self.result = True
def testPushMsg(self): self.case_id = get_case(__file__) step = 1 go_to_settings(self.driver) sleep(WAIT_TIME) assert set_push_state(self.driver, 'true') clear_notification(self.driver) msg1 = u'test1' msg2 = u'test2' self.jpush.push_notification(msg1) self.jpush.push_notification(msg2) ret = get_push_info(self.driver) assert len(ret) == 2 and msg1 in ret and msg2 in ret print u'Step %s:推送多条消息时测试:OK' % (str(step)) step += 1 self.result = True
def testSearchInDiffChnl(self): step = 1 self.case_id = get_case(__file__) #搜索文章并检查样式 chnl_group = self.driver.find_element_by_id( CHNL_GROUP).find_elements_by_class_name('android.widget.TextView') for chnl in chnl_group[:5]: chnl.click() sleep(WAIT_TIME) get_to_search(self.driver, self.mode) sleep(WAIT_TIME) assert self.driver.current_activity == ACTIVITY.get('search') back(self.driver) print u'Step %s:所有新闻列表都能下拉显示搜索框并点击进入搜索界面:OK' % (str(step)) step += 1 self.result = True
def testHeadPic(self): step = 1 self.case_id = get_case(__file__) get_to_search(self.driver, self.mode) #搜索文章并检查样式 get_to_search(self.driver, self.mode) sleep(WAIT_TIME) seach_by_ui(self.driver, HEAD_ARTICLE) self.driver.find_element_by_id(SEARCH_HEAD).click() sleep(WAIT_TIME) pic = self.driver.find_element_by_id(HEAD_PIC) pic.find_element_by_class_name('android.widget.ImageView').click() sleep(WAIT_TIME) assert self.driver.current_activity == ACTIVITY.get('image') print u'Step %s:搜索上头条中的帖子,在列表中点击可查看大图测试:OK' % (str(step)) step += 1 self.result = True
def testSearchBack(self): step = 1 self.case_id = get_case(__file__) #搜索文章并检查样式 chnl_group = self.driver.find_element_by_id( CHNL_GROUP).find_elements_by_class_name('android.widget.TextView') chnl_group[1].click() sleep(WAIT_TIME) first_article_in = self.driver.find_element_by_id(NORMAL_TITLE).text print first_article_in get_to_search(self.driver, self.mode) print self.driver.current_activity seach_by_ui(self.driver, 'ABC') sleep(WAIT_TIME) self.driver.find_element_by_id(SEARCH_BACK).click() first_article_out = self.driver.find_element_by_id(NORMAL_TITLE).text print first_article_in, first_article_out print u'Step %s:取消搜索时能回到搜索前的新闻列表:OK' % (str(step)) step += 1 self.result = True
def test(self): self.case_id = get_case(__file__) step = 1 clear_notification(self.driver) t = Thread(target=self.driver.background_app,args=(20,)) t.start() msg1 = u'test1' msg2 = u'test2' push_info_a = self.db.get_push_info_by_name(NORMAL_ARTICLE) push_info_b = self.db.get_push_info_by_name(PHOTO_ARTICLE) self.jpush.push_article(push_info_a['model'],push_info_a['infoid'],msg =msg1) self.jpush.push_article(push_info_b['model'],push_info_b['infoid'],msg =msg2) ret = get_push_info(self.driver) ret = [x.strip() for x in ret] assert len(ret) == 2 and msg1 in ret and msg2 in ret print u'Step %s:推送多条新闻时测试:OK' % (str(step)) step+=1 self.result = True
def test(self): self.case_id = get_case(__file__) self.result = self.common_check()
def testSubTypeName(self): self.case_id = get_case(__file__) self.result = self.name_check()
def testAudioComment(self): get_to_article_by_search(self.driver, AUDIO_ARTICLE, self.mode) sleep(5) self.case_id = get_case(__file__) self.result = self.photo_check()
def testExtComment(self): get_to_article_by_search(self.driver, EXT_ARTICLE, self.mode) sleep(5) self.case_id = get_case(__file__) self.result = self.common_check()
def testVideoComment(self): get_to_article_by_search(self.driver, VIDEO_ARTICLE, self.mode) sleep(5) self.case_id = get_case(__file__) self.result = self.video_check()
def testExtSearch(self): self.case_id = get_case(__file__) self.result = self.common_check(EXT_ARTICLE,u'外链','ext')
def testAudioSearch(self): self.case_id = get_case(__file__) self.result = self.common_check(AUDIO_ARTICLE,u'音频','audio')
def testVideoSearch(self): self.case_id = get_case(__file__) self.result = self.common_check(VIDEO_ARTICLE,u'视频','video')