예제 #1
0
class MyCommentBasicTest(unittest.TestCase):

    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = MODE
        self.db = DbLib()
        self.new_phone = '13187654321'
        self.db.delete_user_by_phone(self.new_phone)
        self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
        start_to_index(self.driver,self.mode)
        sleep(WAIT_TIME)
        if is_login(self.driver):
            logout_to_index(self.driver,self.mode)
        dc = get_config_by_adb()['dc']
        self.api = ChnlRequest(self.mode,dc=dc)


    def tearDown(self):
        print 'Test End...................................'
        try:
             self.tsl.set_tc_status(self.case_id,self.result,self.msg)
             self.driver.quit()
            self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
            start_to_index(self.driver,self.mode)
            sleep(WAIT_TIME)
            if is_login(self.driver):
                logout_to_index(self.driver,self.mode)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down',e
예제 #2
0
class CityPushTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = MODE
        self.db = DbLib()
        self.jpush = JpushHandler()
        #self.api = ChnlRequest(self.mode)
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub',
                                       self.desired_caps)
        start_to_index(self.driver, self.mode)
        sleep(WAIT_TIME)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    #excute TestCase
    def testCityPush(self):
        step = 1
        go_to_settings(self.driver)
        sleep(WAIT_TIME)
        assert set_push_state(self.driver, 'true')
        clear_notification(self.driver)

        app_location = '宜昌'
        push_location = '大悟'
        push_location_code = self.db.get_domaincode_by_name(push_location)
        app_location_code = self.db.get_domaincode_by_name(app_location)
        #print push_location_code,app_location_code
        msg1 = u'test'
        assert set_location(self.driver, app_location)
        push_info_a = self.db.get_push_info_by_name(NORMAL_ARTICLE)
        print self.jpush.push_notification(msg1, audience=push_location_code)
        ret = get_push_info(self.driver)
        assert ret == False
        clear_notification(self.driver)
        sleep(WAIT_TIME)
        print u'Step %s:无法接受其他地域推送测试:OK' % (str(step))
        step += 1

        print self.jpush.push_notification(msg1, audience=app_location_code)
        ret = get_push_info(self.driver)
        assert ret[0] == msg1
        clear_notification(self.driver)
        sleep(WAIT_TIME)
        print u'Step %s:可正确接收地域推送测试:OK' % (str(step))
        step += 1

        print self.jpush.push_notification(msg1)
        ret = get_push_info(self.driver)
        assert ret[0] == msg1
        clear_notification(self.driver)
        sleep(WAIT_TIME)
        print u'Step %s:可正确接收全部地区推送测试:OK' % (str(step))
        step += 1
예제 #3
0
파일: Login.py 프로젝트: ban666/UITestForDx
 def del_user(mid):
     db = DbLib()
     try:
         db.delete_user_by_db(mid)
         print 'del mid ' + str(mid) + 'success'
     except Exception as e:
         print e
예제 #4
0
class AnonymousMyCommentTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = MODE
        self.db = DbLib()
        self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
        start_to_index(self.driver, self.mode)
        if is_login(self.driver):
            logout_to_index(self.driver, self.mode)
        dc = get_config_by_adb()['dc']
        self.api = ChnlRequest(self.mode, dc=dc)
        self.first_article = self.api.get_first_chnl_article_by_model(13)
        self.db.change_comment_state_by_db(self.first_article['infoid'], 2)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.db.change_comment_state_by_db(self.first_article['infoid'], 0)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    def common_check(self, content, quote_content):
        step = 1

        go_to_mycomm(self.driver, self.mode)
        sleep(WAIT_TIME)
        #对此评论点赞
        reply_comment = self.driver.find_element_by_id(COMMENT)
        reply_info = get_comment_info(
            self.driver, reply_comment,
            1)  #[点赞次数,地理位置_时间,评论用户名,评论内容,引用用户名,引用评论详情]
        assert reply_info[-1] == content
        assert reply_info[3] == quote_content
        print u'Step %s:我的评论-发布评论 未登录评论测试结果:OK' % (str(step))
        step += 1

        self.driver.find_element_by_id(MY_COMM_REPLY).click()
        slide_down(self.driver, 2)
        sleep(WAIT_TIME)
        reply_comment = self.driver.find_element_by_id(COMMENT)
        reply_info = get_comment_info(
            self.driver, reply_comment,
            1)  #[点赞次数,地理位置_时间,评论用户名,评论内容,引用用户名,引用评论详情]
        assert reply_info[-1] == content
        assert reply_info[3] == quote_content
        print u'Step %s:我的评论-回复评论 未登录评回复评论测试结果:OK' % (str(step))
        step += 1

    #excute TestCase
    def testAnonymous(self):
        article = NORMAL_ARTICLE
        content = u'评论' + str(randint(1, 1000))
        quote_content = u'回复评论' + str(randint(1, 1000))
        comid = self.api.send_comment_by_name(article, content)
        self.api.send_comment_by_name(article, quote_content, comid)
        self.common_check(content, quote_content)
예제 #5
0
 def get_last_myhead_info(self, dc):
     db = DbLib()
     m = Mongo()
     if dc.find('#') != -1:
         dc = dc.split('#')[0]
     mid = m.get_mid(dc)
     head_info = db.get_last_head_info_by_db(mid)
     return head_info
예제 #6
0
class AmazingCommentTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.result = 'f'
        self.msg = ''
        self.tsl = TestlinkHandler()
        self.mode = MODE
        self.db = DbLib()
        self.api = ChnlRequest(self.mode)
        self.first_article = self.api.get_first_chnl_article_by_model(13)
        self.db.change_comment_state_by_db(self.first_article['infoid'], 2)
        self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
        start_to_index(self.driver, self.mode)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.tsl.set_tc_status(self.case_id, self.result, self.msg)
            self.db.change_comment_state_by_db(self.first_article['infoid'], 0)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    def common_check(self):
        step = 1
        #发表评论
        type_title = self.driver.find_element_by_id(AMAZING_COMMENT_TIPS).text
        print type_title
        assert type_title == u'精彩评论'
        print u'Step %s:评论页存在精彩评论测试:OK' % (str(step))
        step += 1
        return True

    def non_exsist_check(self):
        step = 1
        #发表评论
        type_title = self.driver.find_element_by_id(AMAZING_COMMENT_TIPS).text
        print type_title
        assert type_title == u'最新评论'
        print u'Step %s:评论页不存在精彩评论测试:OK' % (str(step))
        step += 1
        return True

    #excute TestCase
    def testExsit(self):
        get_to_article_by_search(self.driver, WONDERFUL_COMMENT_ARTICLE,
                                 self.mode)
        go_to_comment_page(self.driver)
        self.case_id = get_case(__file__)
        self.result = self.common_check()

    def testNonExsit(self):
        get_to_article_by_search(self.driver, NORMAL_ARTICLE, self.mode)
        go_to_comment_page(self.driver)
        self.case_id = get_case(__file__)
        self.result = self.non_exsist_check()
예제 #7
0
class MyCommentSlideTest(unittest.TestCase):

    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = MODE
        self.db = DbLib()
        self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
        start_to_index(self.driver,self.mode)
        if not is_login(self.driver):
            login_to_index(self.driver,self.mode,self.desired_caps['appPackage'],TEST_PHONE,DEVICE_TID)
        dc = get_config_by_adb()['dc']
        self.api = ChnlRequest(self.mode,dc=dc)
        self.first_article = self.api.get_first_chnl_article_by_model(13)
        self.db.change_comment_state_by_db(self.first_article['infoid'],2)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.db.change_comment_state_by_db(self.first_article['infoid'],0)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down',e

    def common_check(self):
        step = 1

        go_to_mycomm(self.driver,self.mode)
        assert self.driver.find_element_by_id(MY_COMM_REPLY).get_attribute('checked') == 'false'
        assert self.driver.find_element_by_id(MY_COMM_SEND).get_attribute('checked') == 'true'

        #点击切换
        self.driver.find_element_by_id(MY_COMM_REPLY).click()
        assert self.driver.find_element_by_id(MY_COMM_REPLY).get_attribute('checked') == 'true'
        assert self.driver.find_element_by_id(MY_COMM_SEND).get_attribute('checked') == 'false'
        print u'Step %s:点击切换我的评论-回复评论测试:OK' % (str(step))
        step+=1

        #右划切换
        slide_right(self.driver)
        sleep(3)
        assert self.driver.find_element_by_id(MY_COMM_REPLY).get_attribute('checked') == 'false'
        assert self.driver.find_element_by_id(MY_COMM_SEND).get_attribute('checked') == 'true'
        print u'Step %s:右划切换我的评论-回复评论测试:OK' % (str(step))
        step+=1

        #左划切换
        slide_left(self.driver)
        assert self.driver.find_element_by_id(MY_COMM_REPLY).get_attribute('checked') == 'true'
        assert self.driver.find_element_by_id(MY_COMM_SEND).get_attribute('checked') == 'false'
        print u'Step %s:左划切换我的评论-回复评论测试:OK' % (str(step))
        step+=1

    #excute TestCase
    def testMyComment(self):
        self.common_check()
예제 #8
0
class SendNineImagesClueTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = MODE
        self.db = DbLib()
        self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
        self.extend = Appium_Extend(self.driver)
        start_to_index(self.driver, self.mode)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    def testSend9ImagesClue(self):
        """测试点:报料图片保存,发布九张图报料,报料搜索列表检查,报料详情页报料内容检查,我的报料报料内容检查"""
        BeLogin(self.driver)
        clean_image_save_dir()
        image_path = search_cLue_and_save_images(self.driver, self.extend)
        username = get_user_name(self.driver)
        # image_path = 'f:/pic/nine_clue_images.png'
        go_to_clue(self.driver)
        current_time = time.strftime(ISOTIMEFORMAT, time.localtime())
        # current_date = '02-14'
        current_date = time.strftime(ISODAYFORMAT, time.localtime())
        content = 'test for sending clue with nine images ' + str(current_time)
        # content = 'test for sending clue with nine images 2017-02-14 08:21:51'
        loc = u'湖北省武汉市武昌区东湖路靠近湖北日报传媒集团'
        print u"===================测试点1:发布九张图报料====================="
        send_txt_clue_with_image(self.driver, content, 1)
        self.db.review_clue_by_content(content)
        print u"===================测试点2:校验列表九张图报料================="
        cluetestDic = {
            'content': content,
            'time': current_date,
            'username': username,
            'image_path': image_path,
            'loc': loc,
            'image_nums': 9
        }
        self.driver.find_element_by_name(NEWSTABTXT).click()
        assert check_clue(self.driver, self.extend, cluetestDic, 1)
        print u"===================测试点3:校验详情页报料内容================="
        self.driver.find_element_by_id(HEAD_CONTENT).click()
        assert check_clue_without_type(self.driver, self.extend, cluetestDic)
        self.driver.press_keycode(4)
        sleep(1)
        self.driver.press_keycode(4)
        print u"===================测试点4:校验我的报料中显示================="
        go_to_myclue(self.driver)
        sleep(WAIT_TIME)
        assert check_my_clue(self.driver, self.extend, self.db, cluetestDic,
                             30)
예제 #9
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.db = DbLib()
     self.mode = MODE
     self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
     self.extend = Appium_Extend(self.driver)
     start_to_index(self.driver, self.mode)
예제 #10
0
 def get_hotword_by_db_and_check_ret(self):
     db = DbLib()
     print self.ak
     db_ret = db.get_hotwords_by_db(self.ak)
     hotword_db_list = [x['word'].decode('utf-8') for x in db_ret]
     result = self.get_hotwords()['data']['list']
     for i in range(len(result)):
         print hotword_db_list[i], result[i]
     return result == hotword_db_list
예제 #11
0
파일: test.py 프로젝트: ban666/UITestForDx
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.mode = MODE
     self.db = DbLib()
     #self.api = ChnlRequest(self.mode)
     self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
     start_to_index(self.driver, self.mode)
예제 #12
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.mode = MODE
     self.db = DbLib()
     #self.api = ChnlRequest(self.mode)
     self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
     start_to_index(self.driver,self.mode)
예제 #13
0
class AnonymousDiggTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = 'mcp/dx'
        self.db = DbLib()
        self.api = ChnlRequest(self.mode)
        self.article_list = [
            NORMAL_ARTICLE, VIDEO_ARTICLE, EXT_ARTICLE, PHOTO_ARTICLE
        ]
        for article in self.article_list:
            self.api.send_comment_by_name(article, 'A' + str(randint(1, 100)))
            self.api.send_comment_by_name(article, 'B' + str(randint(1, 100)))
        self.first_article = self.api.get_first_chnl_article_by_model(13)
        self.db.change_comment_state_by_db(self.first_article['id'], 2)
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub',
                                       self.desired_caps)
        start_to_index(self.driver, self.mode)
        if is_login(self.driver):
            logout_to_index(self.driver, self.mode)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.db.change_comment_state_by_db(self.first_article['id'], 0)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    def common_check(self):
        step = 1
        #对第一个评论气泡点赞
        find_first_comment_and_support(self.driver)
        first_digg_count = self.driver.find_elements_by_id(
            'com.zc.hubei_news:id/tv_digg')[0].text
        assert first_digg_count == '1'
        print u'Step %s:匿名气泡点赞测试结果:OK' % (str(step))
        step += 1

        #对第二个评论按钮点赞
        self.driver.find_elements_by_id(
            'com.zc.hubei_news:id/iv_common_zan')[1].click()
        second_digg_count = self.driver.find_elements_by_id(
            'com.zc.hubei_news:id/tv_digg')[1].text
        assert second_digg_count == '1'
        print u'Step %s:匿名按钮点赞测试结果:OK' % (str(step))
        step += 1

    #excute TestCase
    def testArticleComment(self):
        get_to_article_by_search(self.driver, u'自动化文字新闻', self.mode)
        sleep(5)
        self.driver.find_element_by_id(
            'com.zc.hubei_news:id/rl_coments').click()
        self.common_check()
예제 #14
0
class UpdateBasicTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.result = 'f'
        self.msg = ''
        self.tsl = TestlinkHandler()
        self.mode = MODE
        self.db = DbLib()
        #self.api = ChnlRequest(self.mode)
        self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
        start_to_index(self.driver, self.mode)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.tsl.set_tc_status(self.case_id, self.result, self.msg)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    def common_check(self):
        step = 1
        go_to_settings(self.driver)
        version = get_version_code(self.driver)
        db_ver = self.db.get_update_version()['version']
        if db_ver > version:
            self.db.set_update_version(version)
        self.driver.quit()
        self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
        start_to_index(self.driver, self.mode)
        sleep(10)

        #验证设置中手动升级情况
        go_to_settings(self.driver)
        self.driver.find_element(*VERSIONS).click()
        sleep(WAIT_TIME)
        assert element_exsist(self.driver, *VERSIONS)
        print u'Step %s:服务器未配置升级时,设置中手动检测到无更新且不弹出任何窗口测试:OK' % (str(step))
        step += 1
        # el_list = [UPDATE_MSG,BUTTON_OK,BUTTON_CANCEL]
        # for el in el_list:
        #     assert element_exsist(self.driver,'id',el)
        # self.driver.find_element_by_id(BUTTON_CANCEL).click()
        # self.driver.find_element_by_id(VERSION).click()
        # self.driver.find_element_by_id(BUTTON_OK).click()
        # assert self.driver.current_activity == ACTIVITY.get('install')
        # print u'Step %s:非强制更新时,设置中手动检测到更新将会弹出提示,更新和取消功能有效测试:OK' % (str(step))
        # step+=1
        return True

    #excute TestCase
    def test(self):
        self.case_id = get_case(__file__)
        self.result = self.common_check()
예제 #15
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.mode = MODE
     self.db = DbLib()
     self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
     start_to_index(self.driver,self.mode)
     if not is_login(self.driver):
         login_to_index(self.driver,TEST_PHONE)
예제 #16
0
 def check_bullet_from_db_and_delete(self, urlid, vtime, content):
     db = DbLib()
     latest_danmu = db.get_latest_danmu_by_db()
     print latest_danmu['content'] == content
     print latest_danmu['timePoint'] == long(vtime)
     if latest_danmu['content'] == content and latest_danmu['timePoint'] == long(vtime) and \
         latest_danmu['uricode'] == urlid:
         db.del_latest_danmu_by_db(latest_danmu['dmkid'])
         return True
     return False
예제 #17
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.mode = MODE
     self.db = DbLib()
     #self.api = ChnlRequest(self.mode)
     remote_url = get_appium_url_from_config()
     self.driver = webdriver.Remote(remote_url, self.desired_caps)
     start_to_index(self.driver, self.mode)
예제 #18
0
class AnonymousCommentTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = 'mcp/dx'
        self.db = DbLib()
        self.api = ChnlRequest(self.mode)
        self.first_article = self.api.get_first_chnl_article_by_model(13)
        self.db.change_comment_state_by_db(self.first_article['id'], 2)
        self.driver = webdriver.Remote('http://localhost:4732/wd/hub',
                                       self.desired_caps)
        start_to_index(self.driver, self.mode)
        if is_login(self.driver):
            logout_to_index(self.driver, self.mode)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.db.change_comment_state_by_db(self.first_article['id'], 0)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    def common_check(self):
        step = 1
        #发表评论
        type_title = self.driver.find_element_by_id(AMAZING_COMMENT_TIPS).text
        print type_title
        assert type_title == u'精彩评论'
        print u'Step %s:评论页存在精彩评论测试:OK' % (str(step))
        step += 1

    def non_exsit_check(self):
        step = 1
        #发表评论
        type_title = self.driver.find_element_by_id(AMAZING_COMMENT_TIPS).text
        print type_title
        assert type_title == u'最新评论'
        print u'Step %s:评论页不存在精彩评论测试:OK' % (str(step))
        step += 1

    #excute TestCase
    def testExsit(self):
        get_to_article_by_search(self.driver, WONDERFUL_COMMENT_ARTICLE,
                                 self.mode)
        sleep(WAIT_TIME)
        self.driver.find_element_by_id(COMMENT_ITEM).click()
        self.common_check()

    def testNonExsit(self):
        get_to_article_by_search(self.driver, NORMAL_ARTICLE, self.mode)
        sleep(WAIT_TIME)
        self.driver.find_element_by_id(COMMENT_ITEM).click()
        self.non_exsit_check()
예제 #19
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.mode = MODE
     self.db = DbLib()
     self.article_list = [NORMAL_ARTICLE,VIDEO_ARTICLE,EXT_ARTICLE,PHOTO_ARTICLE,AUDIO_ARTICLE]
     for article in self.article_list:
         self.db.close_comment_by_name(article)
     self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
     start_to_index(self.driver,self.mode)
예제 #20
0
class MyCommentPopupTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = MODE
        self.db = DbLib()
        self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
        start_to_index(self.driver, self.mode)
        if not is_login(self.driver):
            login_to_index(self.driver, self.mode,
                           self.desired_caps['appPackage'], TEST_PHONE,
                           DEVICE_TID)
        dc = get_config_by_adb()['dc']
        self.api = ChnlRequest(self.mode, dc=dc)
        self.first_article = self.api.get_first_chnl_article_by_model(13)
        self.db.change_comment_state_by_db(self.first_article['infoid'], 2)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.db.change_comment_state_by_db(self.first_article['infoid'], 0)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    def common_check(self):
        step = 1

        go_to_mycomm(self.driver, self.mode)
        self.driver.find_element_by_id(COMMENT).click()
        assert element_exsist(self.driver, 'id', REPLY_BUTTON)
        assert element_exsist(self.driver, 'id', COPY_BUTTON)
        assert element_exsist(self.driver, 'id', MY_COMM_SUPPORT_BUTTON)
        back(self.driver)
        print u'Step %s:我的评论气泡菜单测试:OK' % (str(step))
        step += 1

        self.driver.find_element_by_id(MY_COMM_REPLY).click()
        self.driver.find_element_by_id(COMMENT).click()
        assert element_exsist(self.driver, 'id', REPLY_BUTTON)
        assert element_exsist(self.driver, 'id', COPY_BUTTON)
        assert element_exsist(self.driver, 'id', MY_COMM_SUPPORT_BUTTON)
        print u'Step %s:回复我的气泡菜单测试:OK' % (str(step))
        step += 1

    #excute TestCase
    def testMyComment(self):
        article = PHOTO_ARTICLE
        comid = self.api.send_comment_by_name(article,
                                              'A' + str(randint(1, 100)))
        self.api.send_comment_by_name(article, 'B' + str(randint(1, 100)),
                                      comid)
        self.common_check()
예제 #21
0
class ArticleAmazingCommentTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.result = 'f'
        self.msg = ''
        self.tsl = TestlinkHandler()
        self.mode = MODE
        self.db = DbLib()
        self.api = ChnlRequest(self.mode)
        self.first_article = self.api.get_first_chnl_article_by_model(13)
        self.db.change_comment_state_by_db(self.first_article['infoid'], 2)
        self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
        start_to_index(self.driver, self.mode)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.tsl.set_tc_status(self.case_id, self.result, self.msg)
            self.db.change_comment_state_by_db(self.first_article['infoid'], 0)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    def common_check(self):
        step = 1
        #验证精彩评论模块是否存在且仅存3条
        slide_up(self.driver, 7)
        print self.driver.contexts
        self.driver.switch_to.context(self.driver.contexts[-1])
        type_title = self.driver.find_element_by_xpath(
            '//*[@id="comment_box"]/h2/em').text
        comment_count = len(
            self.driver.find_elements_by_class_name('comment-avatar'))
        assert type_title == u'精彩评论'
        assert comment_count == 3
        print u'Step %s:正文页存在精彩评论且最大显示为3条测试:OK' % (str(step))
        step += 1

        self.driver.find_element_by_id('btn-comment-more').click()
        sleep(5)
        assert self.driver.current_activity == ACTIVITY.get('comment')
        print u'Step %s:点击精彩评论中查看更多评论按钮跳转测试:OK' % (str(step))
        step += 1
        return True

    #excute TestCase
    def testExsit(self):
        print get_to_article_by_search(self.driver, WONDERFUL_COMMENT_ARTICLE,
                                       self.mode)
        sleep(WAIT_TIME)
        self.case_id = get_case(__file__)
        self.result = self.common_check()
예제 #22
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.mode = 'mcp/dx'
     self.db = DbLib()
     self.api = ChnlRequest(self.mode)
     self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
     start_to_index(self.driver,self.mode)
     if not is_login(self.driver):
         login_to_index(self.driver,self.mode,self.desired_caps['appPackage'],TEST_PHONE,DEVICE_TID)
예제 #23
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.mode = MODE
     self.db = DbLib()
     self.api = ChnlRequest(self.mode)
     self.first_article = self.api.get_first_chnl_article_by_model(13)
     self.db.change_comment_state_by_db(self.first_article['infoid'],2)
     self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
     start_to_index(self.driver,self.mode)
예제 #24
0
def invite_user(info_a,info_b):
    api = UserRequest(mode)
    db = DbLib()
    dc_a = info_a['dc']
    mid_a = info_a['data']['userinfo']['uid']
    code_a = db.get_inv_code_by_db(mid_a)
    dc_b = info_b['dc']
    mid_b = info_b['data']['userinfo']['uid']
    code_b = db.get_inv_code_by_db(mid_b)
    print mid_a,mid_b
    #A邀请B
    return api.invite(dc_b,code_a)
예제 #25
0
class AmazingCommentTest(unittest.TestCase):
    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = MODE
        self.db = DbLib()
        self.api = ChnlRequest(self.mode)
        self.first_article = self.api.get_first_chnl_article_by_model(13)
        self.db.change_comment_state_by_db(self.first_article['infoid'], 2)
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub',
                                       self.desired_caps)
        start_to_index(self.driver, self.mode)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.db.change_comment_state_by_db(self.first_article['infoid'], 0)
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down', e

    def common_check(self):
        step = 1
        #发表评论
        type_title = self.driver.find_element_by_id(
            'com.cnhubei.dxxwhw:id/tv_typetitle').text
        print type_title
        assert type_title == u'精彩评论'
        print u'Step %s:评论页存在精彩评论测试:OK' % (str(step))
        step += 1

    def non_exsist_check(self):
        step = 1
        #发表评论
        type_title = self.driver.find_element_by_id(
            'com.cnhubei.dxxwhw:id/tv_typetitle').text
        print type_title
        assert type_title == u'最新评论'
        print u'Step %s:评论页不存在精彩评论测试:OK' % (str(step))
        step += 1

    #excute TestCase
    def testExsit(self):
        get_to_article_by_search(self.driver, WONDERFUL_COMMENT_ARTICLE,
                                 self.mode)
        go_to_comment_page(self.driver)
        self.common_check()

    def testNonExsit(self):
        get_to_article_by_search(self.driver, NORMAL_ARTICLE, self.mode)
        go_to_comment_page(self.driver)
        self.non_exsist_check()
예제 #26
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.mode = MODE
     self.db = DbLib()
     self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
     self.first_article = self.db.get_infoid_by_article_name(VIDEO_ARTICLE)
     self.db.change_comment_state_by_db(self.first_article, 2)
     start_to_index(self.driver, self.mode)
     if not is_login(self.driver):
         login_to_index(self.driver, TEST_PHONE)
예제 #27
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.result = 'f'
     self.msg = ''
     self.tsl = TestlinkHandler()
     self.mode = MODE
     self.db = DbLib()
     self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
     start_to_index(self.driver, self.mode)
     if not is_login(self.desired_caps['appPackage']):
         login_to_index(self.driver, TEST_PHONE)
예제 #28
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.result = 'f'
     self.msg = ''
     self.tsl = TestlinkHandler()
     self.mode = MODE
     self.db = DbLib()
     self.jpush = JpushHandler()
     #self.api = ChnlRequest(self.mode)
     self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
     start_to_index(self.driver, self.mode)
예제 #29
0
 def setUp(self):
     #self.testcases = conf.readcfg(__file__)
     self.desired_caps = desired_caps
     print 'Test Start...................................'
     self.mode = MODE
     self.db = DbLib()
     self.new_phone = '13187654321'
     self.db.delete_user_by_phone(self.new_phone)
     self.driver = webdriver.Remote(APPIUM_URL, self.desired_caps)
     start_to_index(self.driver, self.mode)
     sleep(WAIT_TIME)
     if is_login(self.driver):
         logout_to_index(self.driver, self.mode)
예제 #30
0
class HeadInReplyCountTest(unittest.TestCase):

    def setUp(self):
        #self.testcases = conf.readcfg(__file__)
        self.desired_caps = desired_caps
        print 'Test Start...................................'
        self.mode = 'mcp/dx'
        self.db = DbLib()
        self.api = ChnlRequest(self.mode)
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
        start_to_index(self.driver,self.mode)
        if not is_login(self.driver):
            login_to_index(self.driver,self.mode,self.desired_caps['appPackage'],TEST_PHONE,DEVICE_TID)

    def tearDown(self):
        print 'Test End...................................'
        try:
            self.driver.quit()
        except Exception as e:
            print u'测试失败,失败环节:tear down',e

    def common_check(self):
        step = 1

        #获取原始评论数
        article = self.api.get_head_list()[0]['id']
        self.count = self.db.get_comment_count_by_id(article)
        #评论数为0显示测试
        self.db.change_comment_count_by_id(article,0)
        slide_down(self.driver,3)
        article_count = self.driver.find_element_by_id(HEAD_REPLY_COUNT).text
        assert article_count == str(0)
        print u'Step %s:上头条列表页评论数为0时显示测试:OK' % (str(step))
        step+=1

        #评论数为0-99999显示测试
        self.db.change_comment_count_by_id(article,99999)
        slide_down(self.driver,3)
        article_count = self.driver.find_element_by_id(HEAD_REPLY_COUNT).text
        assert article_count == str(99999)
        print u'Step %s:上头条列表页评论数为<=99999时显示测试:OK' % (str(step))
        step+=1

        #评论数大于等于10万显示测试
        self.db.change_comment_count_by_id(article,100000)
        slide_down(self.driver,3)
        article_count = self.driver.find_element_by_id(HEAD_REPLY_COUNT).text
        assert article_count == u'99999 +'
        print u'Step %s:上头条列表页评论数大于等于10万时显示测试:OK' % (str(step))
        step+=1

        self.db.change_comment_count_by_id(article,self.count)
    #excute TestCase
    def testHeadCount(self):
        assert go_to_head(self.driver)
        self.common_check()