当前位置: 首页>>代码示例>>Python>>正文


Python CommonFunctions.swipe_screen方法代码示例

本文整理汇总了Python中common.py_common_keyword.CommonFunctions.CommonFunctions.swipe_screen方法的典型用法代码示例。如果您正苦于以下问题:Python CommonFunctions.swipe_screen方法的具体用法?Python CommonFunctions.swipe_screen怎么用?Python CommonFunctions.swipe_screen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.py_common_keyword.CommonFunctions.CommonFunctions的用法示例。


在下文中一共展示了CommonFunctions.swipe_screen方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import swipe_screen [as 别名]
class loadApp:
    def __init__(self):
        self.com = CommonFunctions()

    def loadApp(self):
        newapp_list = ''
        while True:
            try:
                app_list = []
                buttons = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
                for b in buttons:
                    app = b.text
                    app_list.append(app)

                if app_list[-1] != newapp_list:
                    newapp_list = app_list[-1]
                    print 'loading app successfully'
                    self.com.swipe_screen()
                    time.sleep(10)
                else:
                    print 'you load all app on the page'
                    return True
            except Exception, e:
                print 'you load all app on the page error'
                print '%s:%s' % (e.message, e)
                return False
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:28,代码来源:loadApp.py

示例2: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import swipe_screen [as 别名]
class baseFunc:
    """基本功能类"""

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        self.common_fn = CommonFunctions()
        
    #----------------------------------------------------------------------
    def uninstallAPP(self,name):
        """卸载指定应用"""
        isHome = False
        while not isHome:
            self.common_fn.driver.keyevent('4')
            time.sleep(2)
            if self.common_fn.driver.current_activity == '.activity.MarketHomeActivity':
                isHome = True
        print 'uninstall app'
        time.sleep(5)
        tabs = self.common_fn.com_find_element(r'android:id/tabs')
        tabs.find_element(By.NAME,u'管理').click()
        action_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
        action_texts=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_text',By.ID)
        if action_texts[2].text==u'已安装' :
            action_buttons[2].click()
            time.sleep(2)
            print u'get installed apks page\n'
            self.findByName(name)
        else:   
            print u'not get installed apks page\n'
            return False        

            #print self.common_fn.com_find_element(name,By.NAME)

        #----------------------------------------------------------------------
    def findByName(self,name):
        """查找指定应用列表"""
        try:
            isLast = False
            lastAPP = ''
            while not isLast:
                apps = self.common_fn.wait_for_elements(r'android.widget.RelativeLayout',By.CLASS_NAME)
                for i in range(len(apps)):
                    #print '------------',apps[i].find_element(By.ID,r'com.tclmarket:id/name').text
                    try:
                        if apps[i].find_element(By.ID,r'com.tclmarket:id/name').text == name:
                            apps[i].find_element(By.ID,r'com.tclmarket:id/actionOne').click()
                            self.common_fn.element_clk('OK',By.NAME)
                            return True
                    except:
                        s = sys.exc_info()
                        print 'Error "%s" happend on line %d' % (s[1],s[2].tb_lineno)
                newLastAPP = apps[-1].find_element(By.ID,r'com.tclmarket:id/name').text
                if lastAPP == newLastAPP:
                    return False
                lastAPP = newLastAPP
                self.common_fn.swipe_screen(percent=0.7,duration=2000)
        except:
            s = sys.exc_info()
            print 'Error "%s" happend on line %d' % (s[1],s[2].tb_lineno)
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:62,代码来源:baseFunc.py

示例3: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import swipe_screen [as 别名]
class onekey_report:
    def __init__(self):
        self.com = CommonFunctions()

    # 打开应用详情
    def openDetailpage(self):
        global app
        try:
            apps = self.com.driver.find_elements_by_id("com.tclmarket:id/name")
            for app in apps:
                if app.text != "":
                    app.click()
                    time.sleep(8)

                    appname = self.com.wait_for_element("com.tclmarket:id/name")
                    if appname.text == app.text:
                        print "you have entered appdetailpage"
                        self.com.swipe_screen(percent=0.7)
                        time.sleep(3)
                        return True
                    else:
                        print "you have entered wrong"
                        return False

        except:
            print "No app in the page"
            return False

    def onekeyVerify(self):
        try:
            report = self.com.wait_for_element("com.tclmarket:id/one_key_submit")
            report.click()
            report_message = self.com.wait_for_element("com.tclmarket:id/report_message")
            report_items = self.com.driver.find_elements_by_id("com.tclmarket:id/linerlayout_two")
            for item in report_items:
                item.click()
            submit = self.com.wait_for_element("com.tclmarket:id/submit")
            report_message.send_keys(u"测试一件举报")
            submit.click()
            if report:
                print "you back the detail page"
                return True
            else:
                print "back  failed"
                return False
        except:
            s = sys.exc_info()
            print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
            return False

    def run_onekey_report(self):
        return self.com.run_test_case(
            lambda: self.com.launch_app(), lambda: self.openDetailpage(), lambda: self.onekeyVerify()
        )
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:56,代码来源:onekey_report.py

示例4: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import swipe_screen [as 别名]
class commentpageVerify:
    def __init__(self):
        self.com = CommonFunctions()

    # 打开应用详情
    def openDetailpage(self):
        try:
            apps = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
            for app in apps:
                if app.text != '':
                    app.click()
                    time.sleep(5)

                    appname = self.com.wait_for_element('com.tclmarket:id/name')
                    if appname.text == app.text:
                        print 'you have entered appdetailpage'
                        self.com.swipe_screen(percent=0.7)
                        time.sleep(3)
                        return True
                    else:
                        print 'you have entered wrong'
                        return False


        except:
            print 'No app in the page'
            return False

    def commentpafeVerify(self):
        try:
            comment = self.com.wait_for_element('com.tclmarket:id/remark_tv')
            comment.click()
            time.sleep(5)
            writeComment = self.com.wait_for_element('com.tclmarket:id/write_commment')
            grade = self.com.wait_for_element('com.tclmarket:id/avgscore_lyout')

            if writeComment and grade:
                print 'You enter commentpage successfully'
                return True
            else:
                print 'Enter the commentpage failure'
                return False
        except:
            print 'commentpafe verify failure'
            return False

    def run_commentpafeVerify(self):
        return self.com.run_test_case(lambda: self.com.launch_app(),
                                      lambda: self.openDetailpage(),
                                      lambda: self.commentpafeVerify())
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:52,代码来源:commentpageVerify.py

示例5: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import swipe_screen [as 别名]
class loadHotapps:
    def __init__(self):
        self.com = CommonFunctions()

    def loadHotapps(self):
        try:
            hot_button = self.com.wait_for_element(value='com.tclmarket:id/remark_text1', element_text=u'最热')
            if hot_button:
                hot_button.click()
                return True
            return False
        except:
            print 'No hot labels'
            s = sys.exc_info()
            print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
            return False

    def loadApps(self):
        newapp_list = ''
        while True:
            try:
                app_list = []
                time.sleep(2)
                buttons = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
                for b in buttons:
                    app = b.text
                    app_list.append(app)

                if app_list[-1] != newapp_list:
                    newapp_list = app_list[-1]
                    print 'loading app successfully'
                    self.com.swipe_screen()
                    time.sleep(10)
                else:
                    print 'you load all app on the page'
                    return True
            except:
                print 'loadApps error'
                s = sys.exc_info()
                print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
                return False

    def run_loadHotapps(self):
        return self.com.run_test_case(lambda: self.com.launch_app(),
                                      lambda: self.loadHotapps(),
                                      lambda: self.loadApps())
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:48,代码来源:loadHotapps.py

示例6: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import swipe_screen [as 别名]
class versionVerify:
    def __init__(self):
        self.com = CommonFunctions()

    # 获取应用列表中应用的版本号
    def getVersion(self):
        global version_NO
        try:
            versions = self.com.driver.find_elements_by_id('com.tclmarket:id/version')
            for v in versions:
                version = v.text
                version_no = version.split('|')[0]
                version_NO = version_no[1:-1]
                print version_NO
                return True
        except:
            print 'getVersion Failed'
            return False

    # 打开应用详情
    def openDetailpage(self):
        global app
        try:
            apps = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
            for app in apps:
                if app.text != '':
                    app.click()
                    time.sleep(8)

                    appname = self.com.wait_for_element('com.tclmarket:id/name')
                    if appname.text == app.text:
                        print 'you have entered appdetailpage'
                        self.com.swipe_screen(percent=0.7)
                        time.sleep(3)
                        return True
                    else:
                        print 'you have entered wrong'
                        return False

        except:
            print 'No app in the page'
            return False

    def checkVersion(self):
        try:
            fr = self.com.wait_for_element('com.tclmarket:id/version_info_content')
            v = fr.find_element_by_id('com.tclmarket:id/version_name')
            UT = fr.find_element_by_id('com.tclmarket:id/update_time')
            DL = fr.find_element_by_id('com.tclmarket:id/download_times')
            ok = fr.find_element_by_id('com.tclmarket:id/one_key_submit')

            version = v.text
            update = UT.text
            download = DL.text
            one_key = ok.text

            versioncode = version.split(u':')[-1]
            print versioncode

            if versioncode == version_NO and update and download and one_key:
                print 'Version information in detail page is OK'
                return True
            else:
                print 'Version information in detail page is Failed'
                return False
        except:
            s = sys.exc_info()
            print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
            return False

    def run_versionVerify(self):
        return self.com.run_test_case(lambda: self.com.launch_app(),
                                      lambda: self.getVersion(),
                                      lambda: self.openDetailpage(),
                                      lambda: self.checkVersion())
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:77,代码来源:versionVerify.py

示例7: share_app

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import swipe_screen [as 别名]

#.........这里部分代码省略.........
                            if alert_title.text==u'分享':
                                print u'get share list\n'
                                try:
                                    shareBtn=self.common_fn.wait_for_elements(r'android:id/text1',By.ID)
                                    for bluetooth_share in shareBtn:
                                        if bluetooth_share.text == 'Bluetooth':
                                            bluetooth_share.click()
                                            time.sleep(2)
                                            break
                                    try:
                                        open_alert=self.common_fn.wait_for_element(r'com.android.bluetooth:id/content')
                                        if open_alert:
                                            print u'get open bluetooth alert\n'
                                            turn_on_button=self.common_fn.wait_for_element(r'android:id/button1')
                                            turn_on_button.click()
                                            time.sleep(2)
                                    except:
                                        print u'not get open bluetooth alert\n'  
                                        s = sys.exc_info()
                                        print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)   
                                    
                                    try:
                                        if self.common_fn.driver.current_activity == u'.bluetooth.DevicePickerActivity':
                                            print u'the app can be shared by bluetooth\n'
                                        else:
                                            pass
                                    except:
                                        print u'not get the title\n'    
                                        s = sys.exc_info()
                                        print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)                                        
                                except:
                                    print u'not get bluetooth share button\n'
                                    s = sys.exc_info()
                                    print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)                                         
                            else:
                                print u'the alert is not about share\n'
                        except:
                            print u'not get alert page\n'  
                            s = sys.exc_info()
                            print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)                            
                    except:
                        print u'not get share button\n'
                    try:
                        self.common_fn.driver.back()
                        time.sleep(5)
                        self.common_fn.swipe_screen()
                        try:
                            action_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/fold_tag_btn',By.ID)
                            text_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/actionOne_text',By.ID)
                            if text_buttons[-1].text==u'取消忽略':
                                print u'get ignored app\n'
                                action_buttons[-1].click()
                                try:
                                    ignore_share=self.common_fn.wait_for_element(r'com.tclmarket:id/bottom_action_left')
                                    ignore_share.click()
                                    time.sleep(2)
                                    try:
                                        alert_title=self.common_fn.wait_for_element(r'android:id/title')
                                        if alert_title.text==u'分享':
                                            print u'get share list\n'
                                            return True  
                                        else:
                                            return False
                                    except:
                                        print u'not get bluetooth share button\n'
                                        s = sys.exc_info()
                                        print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)                                        
                                except Exception as e:
                                    print e
                                    print u'not find share button\n'    
                            elif text_buttons[-1].text ==u'更新':
                                print u'no ignored app\n'
                                return True
                            else:
                                return False
                        except:
                            print u'no app\n'
                            s = sys.exc_info()
                            print 'Error %s happened on lineno %d' % (s[1],s[2].tb_lineno)
                            return False
                    except:
                        print u'fail to swipe\n'  
                        s = sys.exc_info()
                        print 'Error %s happened on lineno %d' % (s[1],s[2].tb_lineno)                        
                        return False
                else:
                    
                    print u'only one app to be updated\n'  
                    return False
            except:
                print u'not get ignore button'                
        except:
            print u'fail to go into update task page'   
            return False
            
    def run(self):
        start = startOperate()
        return self.common_fn.run_test_case(lambda: self.common_fn.launch_app('4.0.1'),
                                     lambda: start.baseOperate(),
                                     lambda: self.app_update_task())             
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:104,代码来源:share_app.py

示例8: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import swipe_screen [as 别名]
class writecoment:
    def __init__(self):
        self.com = CommonFunctions()

    # 打开应用详情ssss
    def openDetailpage(self):
        try:
            apps = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
            for app in apps:
                if app.text != '':
                    app.click()
                    time.sleep(5)

                    appname = self.com.wait_for_element('com.tclmarket:id/name')
                    if appname.text == app.text:
                        print 'you have entered appdetailpage'
                        self.com.swipe_screen(percent=0.7)
                        time.sleep(3)
                        return True
                    else:
                        print 'you have entered wrong'
                        return False

        except:
            print 'No app in the page'
            return False

    def writecomment(self):
        try:
            comment = self.com.wait_for_element('com.tclmarket:id/remark_tv')
            comment.click()
            time.sleep(2)

            writeComment = self.com.wait_for_element('com.tclmarket:id/write_commment')
            writeComment.click()

            commentbox = self.com.wait_for_element('com.tclmarket:id/comment_content')
            submit = self.com.wait_for_element('com.tclmarket:id/submit_comment')
            submit.click()
            if commentbox:
                print 'network is well'
            else:
                print 'pelase check your network'
                return False

            commentbox.send_keys(u'等等')
            submit.click()
            time.sleep(2)
            if writeComment:
                print 'You have successfully submit comments'
                return True
            return False

        except:
            print 'writecomment error '
            return False

    def run_writecoment(self):
        return self.com.run_test_case(lambda: self.com.launch_app(),
                                      lambda: self.openDetailpage(),
                                      lambda: self.writecomment())
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:63,代码来源:writecoment.py

示例9: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import swipe_screen [as 别名]
class hoursSearch48:
    def __init__(self):
        self.com = CommonFunctions()

    def clickKeyword(self):
        global keyword

        button = self.com.wait_for_element('com.tclmarket:id/actionbar_search')
        button.click()
        time.sleep(5)

        try:
            button = self.com.wait_for_element('com.tclmarket:id/loading_error_info')
            if button.text == u'加载失败,请检查您的网络连接':
                return False

            return True
        except:
            buttons = self.com.wait_for_elements(value='android.widget.TextView')
            for number in range(len(buttons)):
                if buttons[number].text == u'48小时热门搜索':
                    keyword = buttons[number + 1].text
                    print 'keyword is %s' % keyword
                    time.sleep(5)
                    buttons[number + 1].click()
                    time.sleep(5)
                    return True

    def searchresultValidation(self):
        buttons = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
        for i in buttons:
            app = i.text
            if keyword in app:
                print 'app is %s' % app
                return True
            else:
                print 'error happened on searchresultValidation'
                return False

    def loadPage(self):
        newapp_list = ''
        while True:
            self.searchresultValidation()
            try:
                app_list = []
                buttons = self.com.driver.find_elements_by_id('com.tclmarket:id/name')
                for b in buttons:
                    app = b.text
                    app_list.append(app)

                if app_list[-1] != newapp_list:
                    newapp_list = app_list[-1]
                    print 'loading app successfully'
                    self.com.swipe_screen()
                    time.sleep(10)
                else:
                    print 'you load all app on the page'
                    return True
            except Exception, e:
                print 'loadpage error'
                print '%s:%s' % (Exception.message, e)
                return False
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:64,代码来源:hoursSearch48.py


注:本文中的common.py_common_keyword.CommonFunctions.CommonFunctions.swipe_screen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。