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)
Esempio n. 2
0
def notification_status_judge(driver, status):
    """
    check audio notification status by screenshot
    :param driver:
    :param status: 'play' or 'pause'
    :return: Boolean
    """
    fname = PIC_SAVE_PATH + '\\' + get_now() + '.png'
    pause_image = [IMAGE_PATH + '\\' + x for x in IMAGES['notification_pause']]
    start_image = [IMAGE_PATH + '\\' + x for x in IMAGES['notification_start']]
    status_dict = {'play': start_image, 'pause': pause_image}
    scr = Appium_Extend(driver)
    el = driver.find_element_by_id(NOTIFICATION_AUDIO_PLAY)
    scr.get_screenshot_by_element(el, fname)
    result = False
    for pic in status_dict.get(status):
        if scr.same_as(fname, pic):
            result = True

    return result
Esempio n. 3
0
    def common_check(self,article):
        step = 1

        #音频详情页播放时验证通知栏
        fname_pause =PIC_SAVE_PATH+'\\pause'+get_now()+'.png'
        fname_start =PIC_SAVE_PATH+'\\start'+get_now()+'.png'
        start_image = IMAGE_PATH + '\\'+IMAGES['notification_start']
        pause_image = IMAGE_PATH + '\\'+IMAGES['notification_pause']
        get_to_article_by_search(self.driver,article,self.mode)
        sleep(WAIT_TIME)
        assert element_exsist(self.driver,'id',AUDIO_PAUSE)
        open_notifications(self.driver)
        sleep(WAIT_TIME)
        scr = Appium_Extend(self.driver)
        el = self.driver.find_element_by_id(NOTIFICATION_AUDIO_PLAY)
        scr.get_screenshot_by_element(el,fname_pause)
        assert scr.same_as(fname_pause,pause_image)
        print u'Step %s:音频详情页播放时通知栏图标测试:OK' % (str(step))
        step+=1

        #音频详情页暂停时验证通知栏
        close_notification(self.driver)
        sleep(5)
        self.driver.find_element_by_id(AUDIO_PAUSE).click()
        assert element_exsist(self.driver,'id',AUDIO_START)
        open_notifications(self.driver)
        sleep(WAIT_TIME)
        el = self.driver.find_element_by_id(NOTIFICATION_AUDIO_PLAY)
        scr.get_screenshot_by_element(el,fname_start)
        assert scr.same_as(fname_start,start_image)
        #print self.driver.current_activity
        print u'Step %s:音频详情页暂停时通知栏图标测试:OK' % (str(step))
        step+=1

        #通知栏播放时验证详情页
        open_notifications(self.driver)
        sleep(WAIT_TIME)
        self.driver.find_element_by_id(NOTIFICATION_AUDIO_PLAY).click()
        scr.get_screenshot_by_element(el,fname_pause)
        assert scr.same_as(fname_pause,pause_image)
        close_notification(self.driver)
        sleep(WAIT_TIME)
        assert element_exsist(self.driver,'id',AUDIO_PAUSE)
        print u'Step %s:通知栏播放时详情页状态测试:OK' % (str(step))
        step+=1

        #通知栏暂停时验证详情页
        open_notifications(self.driver)
        sleep(WAIT_TIME)
        self.driver.find_element_by_id(NOTIFICATION_AUDIO_PLAY).click()
        scr.get_screenshot_by_element(el,fname_start)
        assert scr.same_as(fname_start,start_image)
        close_notification(self.driver)
        sleep(WAIT_TIME)
        assert element_exsist(self.driver,'id',AUDIO_START)
        print u'Step %s:通知栏暂停时详情页状态测试:OK' % (str(step))
        step+=1