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


Python CommonFunctions.wait_for_elements方法代码示例

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


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

示例1: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [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

示例2: open_installed_app

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [as 别名]
class open_installed_app():
    def __init__(self):
        self.common_fn = CommonFunctions()
    
    def app_homePage(self):
        try:
            manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            if manage_buttons[4].text==u'管理':
                manage_buttons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
            else:
                print u'manageButton[4].text do not equal to 管理'    
        except:
            print u'not find manage button\n'
            
            
    def app_installedList(self):
        try:
            self.app_homePage()
            installed_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
            installed_buttons[2].click()
            time.sleep(2)
            try:
                title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
                if title.text==u'已安装':
                    print u'get installed apps list\n'
                    try:
                        
                        appName = self.common_fn.wait_for_elements(r'com.tclmarket:id/name',By.ID)[5].text
                        click_apps=self.common_fn.wait_for_elements(r'com.tclmarket:id/fold_tag',By.ID)
                        click_apps[5].click()
                        open_button=self.common_fn.wait_for_element(r'com.tclmarket:id/bottom_action_left')
                        open_button.click()  
                        
                        print u'open app "%s" \n' % appName
                        self.common_fn.driver.keyevent('4')
                        return True
                    except Exception as e:
                        
                        print u'not find apps\n'
                        s = sys.exc_info()
                        print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)                        
                else:
                    pass
            except:
                pass        
        except:
            print u'fail to go into installed apps page\n'
            s = sys.exc_info()
            print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
                       
      
    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_installedList()) 
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:60,代码来源:open_installed_app.py

示例3: open_app_of_apklists

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [as 别名]
class open_app_of_apklists():
    def __init__(self):
        self.common_fn = CommonFunctions()
    
    def app_homePage(self):
        try:
            manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            if manage_buttons[4].text==u'管理':
                manage_buttons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
            else:
                print u'manageButton[4].text do not equal to 管理'    
        except:
            print u'not find manage button\n'
            
            
    def app_installedList(self):
        try:
            self.app_homePage()
            installed_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
            installed_buttons[3].click()
            time.sleep(2)
            try:
                title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
                if title.text==u'安装包扫描':
                    print u'get apks list\n'
                    try:
                        appName = self.common_fn.wait_for_element(r'com.tclmarket:id/name').text
                        click_apps=self.common_fn.wait_for_elements(r'com.tclmarket:id/icon',By.ID)
                        click_apps[0].click()
                        print u'open app "%s" \n' % appName
                        self.common_fn.driver.keyevent('4')
                        base = baseFunc()
                        base.uninstallAPP(appName)    
                        return True
                    except Exception as e:
                        print e
                        print u'not find apps\n'
                        return False
                else:
                    return False
            except:
                return False
        except:
            print u'fail to go into installed apps page\n'    
            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_installedList()) 
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:55,代码来源:open_app_of_apklists.py

示例4: start_set_from_apkslist

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [as 别名]
class start_set_from_apkslist():
    def __init__(self):
        self.common_fn = CommonFunctions()
    
    def app_homepage(self):
        try:
            manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            if manage_buttons[4].text==u'管理':
                manage_buttons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
            else:
                print u'manage_button[4].text do not equal to 管理'    
        except:
            print u'not find manage button\n'
            
            
    def apks_list(self):
        try:
            apks_list_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
            apks_list_buttons[3].click()
            time.sleep(2)
            print u'go into apks list page'
        except:
            print u'fail to go into apks list page'
                       
    def start_set_page(self):
        try:
            self.app_homepage()
            self.apks_list()
            set_button=self.common_fn.wait_for_element(r'com.tclmarket:id/actionbar_settings')
            set_button.click()
            time.sleep(2)
            try:
                title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
                if title.text==u'设置':
                    print u'get set page\n'
                    return True
                else:
                    return False
            except:
                print u'not get the title\n'
                return False
        except:
            print u'fail to find set button\n'
            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.start_set_page())                   
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:54,代码来源:start_set_from_apkslist.py

示例5: installedAppPage

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [as 别名]
class installedAppPage():
    def __init__(self):
        self.common_fn = CommonFunctions()
              
    def appHomePage(self):
        try:
            manageButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            if manageButtons[4].text==u'管理':
                manageButtons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
                return True
            else:
                print u'manageButton[4].text do not equal to 管理'   
                return False
        except:
            print u'not find manage button\n'
            return False
            
            
    def appInstalledList(self):
        try:
            self.appHomePage()
            installedButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
            installedButtons[2].click()
            time.sleep(2)
            try:
                title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
                if title.text==u'已安装':
                    print u'get installed apps list\n'
                    return True
                else:
                    return False
            except:
                return False    
        except:
            print u'fail to go into installed apps page\n'
            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.appInstalledList())          
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:46,代码来源:installedAppPage.py

示例6: __init__

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

    def searchpageVerify(self):

        button = self.com.wait_for_element('com.tclmarket:id/actionbar_search')
        button.click()
        time.sleep(5)
        try:
            frame = self.com.wait_for_element('com.tclmarket:id/keywordflow')
            keywords = frame.find_elements_by_class_name('android.widget.TextView')
            apps = self.com.wait_for_elements(value='com.tclmarket:id/name', by=By.ID)
            for k in keywords:
                if k.text != '':
                    print u'48小时热门搜索 is ok'
                else:
                    print u'48小时热门搜索 Load Fail'
                    return False
            for a in apps:
                if a.text != '':
                    print u'search chats is ok'
                else:
                    print u'search chats Load Fail'
                    return False

            backicon = self.com.wait_for_element('com.tclmarket:id/actionbar_up')
            backicon.click()
            banner = self.com.wait_for_element('com.tclmarket:id/banner1')
            if banner:
                print 'You have successfully from the search page'
                return True
            else:
                print 'wrong'
                return False
        except:

            print 'searchpage Load Fail'
            s = sys.exc_info()
            print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)
            return False

    def run_searchpageVerify(self):
        return self.com.run_test_case(lambda: self.com.launch_app(),
                                      lambda: self.searchpageVerify())
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:47,代码来源:SearchpageVerify.py

示例7: share_app

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [as 别名]
class share_app():
    '''
                                版本 应用商店4.0.1
                               编号 AppStore2-931 
                              标题    分享应用程序
    '''
    def __init__(self):
        self.common_fn = CommonFunctions()
    
    def app_homepage(self):
        try:
            manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            if manage_buttons[4].text==u'管理':
                manage_buttons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
            else:
                print u'manageButton[4].text do not equal to 管理'    
        except:
            print u'not find manage button\n'
            
            
    def app_update_task(self):
        try:
            self.app_homepage()
            download_task_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
            download_task_buttons[1].click()
            time.sleep(2)
            print u'go into update task page'
            try:
                app_list_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/fold_tag',By.ID)
                if app_list_buttons:
                    app_list_buttons[0].click()
                    try:
                        ignore_button=self.common_fn.wait_for_element(r'com.tclmarket:id/bottom_action_middle')
                        ignore_button.click()
                        time.sleep(2)
                        try:
                            alert_title=self.common_fn.wait_for_element(r'android:id/alertTitle')
                            ok_button=self.common_fn.wait_for_element(r'android:id/button1')
                            if alert_title.text==u'忽略更新':
                                ok_button.click()
                                print u'ignore app update\n'
                            else:
                                print u'the alert is not about ignore\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 ignore page\n'
                else:
                    print u'not find any apps to be updated\n' 
                if app_list_buttons:
                    app_list_buttons[0].click()
                    try:
                        share_button=self.common_fn.wait_for_element(r'com.tclmarket:id/bottom_action_left')
                        share_button.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'
                                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()
#.........这里部分代码省略.........
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:103,代码来源:share_app.py

示例8: __init__

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

    def appdownload(self):
        try:
            adButtons = self.common_fn.wait_for_elements(r"android.widget.ImageView")
        except:
            time.sleep(3)
            adButtons = self.common_fn.wait_for_elements(r"android.widget.ImageView")
        adButtons[1].click()
        time.sleep(5)
        print u"get adButton\n"
        try:
            download_keys = self.common_fn.wait_for_elements(r"com.tclmarket:id/action_text", By.ID)
            download_values = self.common_fn.wait_for_elements(r"com.tclmarket:id/action", By.ID)
            if download_keys:
                for i in range(len(download_keys)):

                    if download_keys[i].text == u"下载":
                        download_values[i].click()
                        print u"start to download the app\n"
                        break
                    elif download_keys[i].text == u"继续":
                        download_values[i].click()
                        print u"continue to download the app\n"

                    elif download_keys[i].text == u"安装":
                        download_values[i].click()
                        print u"start to setup the app\n"

                    elif download_keys[i].text == u"更新":
                        download_values[i].click()
                        print u"start to update the app\n"

                    elif download_keys[i].text == u"打开":
                        print u"the app has downloaded"

                    else:
                        download_values[i].click()
                        print u"stop download the app"
            else:
                print u"not find any download buttons\n"
                return False
        except:
            print u"fail to download single app\n"
            return False

        try:
            button = self.common_fn.wait_for_element(r"com.tclmarket:id/download_all_button")
            if button.text == u"下载全部":
                button.click()
                time.sleep(5)
                print u"all ad apps are downloading\n"
                self.cleanAPP()
                return True
            else:
                print u'not find "download all"button\n'
                return False
        except:
            print u"download fail"
            return False
        finally:
            self.common_fn.driver.remove_app("com.tencent.qqlive")

    def cleanAPP(self):
        """清除全部下载任务"""
        try:
            config_file = os.path.join(self.common_fn.program_path, "config/conf.ini")
            config = ConfigParser.ConfigParser()
            config.readfp(open(config_file))
            packageName = config.get("Device", "app-package")
            os.system("adb shell pm clear %s" % packageName)
            return True
        except:
            s = sys.exc_info()
            print 'Error "%s" happend on line %d' % (s[1], s[2].tb_lineno)

    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.appdownload()
        )
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:85,代码来源:DownloadAdApp.py

示例9: __init__

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

    def app_homePage(self):
        try:
            manage_buttons = self.common_fn.wait_for_elements(r"com.tclmarket:id/text", By.ID)
            if manage_buttons[4].text == u"管理":
                manage_buttons[4].click()
                time.sleep(2)
                print u"go into manage page\n"
            else:
                print u"manageButton[4].text do not equal to 管理"
        except:
            print u"not find manage button\n"

    def app_installedList(self):
        try:
            self.app_homePage()
            installed_buttons = self.common_fn.wait_for_elements(r"com.tclmarket:id/manage_image", By.ID)
            installed_buttons[2].click()
            time.sleep(2)
            try:
                title = self.common_fn.wait_for_element(r"com.tclmarket:id/home_title")
                if title.text == u"已安装":
                    print u"get installed apps list\n"
                    try:
                        uninstall_name = self.common_fn.wait_for_element(r"com.tclmarket:id/name").text
                        uninstall_button = self.common_fn.wait_for_element(r"com.tclmarket:id/actionOne")
                        uninstall_button.click()
                        try:
                            uninstall_title = self.common_fn.wait_for_element(r"android:id/alertTitle")
                            if uninstall_title.text == uninstall_name:
                                print u"uninstall apps\n"
                                return True
                            else:
                                print u"can not uninstall apps\n"
                                return False
                        except:
                            s = sys.exc_info()
                            print "Error %s happend on line %d" % (s[1], s[2].tb_lineno)
                            return False

                    except:
                        s = sys.exc_info()
                        print "Error %s happend on line %d" % (s[1], s[2].tb_lineno)
                        print u"not find uninstall buttons\n"
                        return False
                else:
                    return False
            except:
                s = sys.exc_info()
                print "Error %s happend on line %d" % (s[1], s[2].tb_lineno)
                return False
        except:
            s = sys.exc_info()
            print "Error %s happend on line %d" % (s[1], s[2].tb_lineno)
            print u"fail to go into installed apps page\n"
            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_installedList()
        )
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:67,代码来源:uninstalled_app.py

示例10: startSearchPage

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

    def appHomePage(self):
        try:
    
            downloadApps=self.common_fn.wait_for_elements(r'com.tclmarket:id/item_container',By.ID)
            isClick = False
            for app in downloadApps:
                downloadBtn = app.find_element(By.ID,r'com.tclmarket:id/action_text')
                if downloadBtn.text == u'下载':
                    downloadBtn.click()
                    isClick = True
                    break
            if not isClick:
                raise Exception('do not have download app at installedAppOpen')
            print u'start to download an app\n'
            time.sleep(50)
        except:
            print u'fail to download the first app\n ' 
        try:
            for i in range(4):
                self.common_fn.element_clk(r'com.android.packageinstaller:id/ok_button',timeout=50)
                print u'click the next button %d\n' % (i+1)
            time.sleep(30)
            print u'finish clicking ok\n'
        except:
            print u'something wrong with ok button\n'
        try:
            doneButton=self.common_fn.element_clk(r"com.android.packageinstaller:id/done_button",timeout=30)
            time.sleep(2)
            print u'install the first app\n'         
        except:
            print u'fail to install the first app\n'           
        try:
            manageButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            if manageButtons[4].text==u'管理':
                manageButtons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
            else:
                print u'manageButton[4].text do not equal to 管理'    
        except:
            print u'not find manage button\n'
            s = sys.exc_info()
            print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
              
            
    def appDownloadTask(self):
        try:
            
            downloadTaskButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
            downloadTaskButtons[0].click()
            time.sleep(2)
            
            print u'go into download task page'
        except:
            print u'fail to go into download task page'
                        
    def startSearchPage(self):
        try:
            self.appHomePage()
            self.appDownloadTask()
            appName = self.common_fn.wait_for_element(r'com.tclmarket:id/name').text
            searchButton=self.common_fn.wait_for_element(r'com.tclmarket:id/actionbar_search')
            searchButton.click()
            time.sleep(2)
            try:
                findAppButton=self.common_fn.wait_for_element(r'com.tclmarket:id/search_editor')
                if findAppButton.text==u'搜您喜欢的应用':
                    print u'get search page\n'
                    try:
                        gobackButton=self.common_fn.wait_for_element(r'com.tclmarket:id/actionbar_up')
                        gobackButton.click()
                        time.sleep(2)
                        try:
                            title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
                            if title:
                                print u'goback to download task page\n'
                                base = baseFunc()
                                base.uninstallAPP(appName)                                
                                return True
                            else:
                                print u'fail to goback to download task page\n'    
                                return False
                        except:
                            s = sys.exc_info()
                            print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
                            return False        
                    except:
                        print u'not find gobackButton\n'    
                        return False
                else:
                    print u'fail to get search page\n'
                    return False
            except:
                print u'not get the findAppButton'        
                return False
        except:
#.........这里部分代码省略.........
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:103,代码来源:startSearchPage.py

示例11: start_search_from_apks

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

    def app_homepage(self):
        try:
            manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            if manage_buttons[4].text==u'管理':
                manage_buttons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
            else:
                print u'manageButton[4].text do not equal to 管理'    
        except:
            print u'not find manage button\n'
            
            
    def apks_list(self):
        try:
            
            download_task_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
            download_task_buttons[3].click()
            time.sleep(2)
            print u'go into apks list page\n'
        except:
            print u'fail to go into apks list page\n'
                   
    def start_search_page(self):
        try:
            self.app_homepage()
            self.apks_list()
            search_button=self.common_fn.wait_for_element(r'com.tclmarket:id/actionbar_search')
            search_button.click()
            time.sleep(2)
            try:
                findApp_button=self.common_fn.wait_for_element(r'com.tclmarket:id/search_editor')
                if findApp_button.text==u'搜您喜欢的应用':
                    print u'get search page\n'
                    try:
                        goback_button=self.common_fn.wait_for_element(r'com.tclmarket:id/actionbar_up')
                        goback_button.click()
                        time.sleep(2)
                        try:
                            title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
                            if title:
                                print u'goback to apks list page\n'
                                return True
                            else:
                                print u'fail to goback to apks list page\n'    
                                return False
                        except:
                            s = sys.exc_info()
                            print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
                            return False
                    except:
                        print u'not find gobackButton\n'  
                        s = sys.exc_info()
                        print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
                        return False                        
                else:
                    print u'fail to get search page\n'
                    s = sys.exc_info()
                    print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
                    return False                    
            except:
                print u'not get the findAppButton' 
                s = sys.exc_info()
                print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
                return False                
        except:
            print u'fail to find search button\n'
            s = sys.exc_info()
            print 'Error %s happend on line %d' % (s[1],s[2].tb_lineno)
            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.start_search_page())  
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:83,代码来源:start_search_from_apks.py

示例12: __init__

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [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

示例13: startSetPage

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [as 别名]
class startSetPage():
    def __init__(self):
        self.common_fn = CommonFunctions()
    
        
    def appHomePage(self):
        try:
            downloadApps=self.common_fn.wait_for_elements(r'com.tclmarket:id/action',By.ID)
            downloadApps[0].click()
            print u'start to download an app\n'
            time.sleep(30)
        except:
            print u'fail to download the first app\n ' 
        try:
            for i in range(4):
                OKButton=self.common_fn.wait_for_element(r'com.android.packageinstaller:id/ok_button')
                OKButton.click()
                print u'click the next button %d\n' % (i+1)
            time.sleep(30)
            print u'finish clicking ok\n'
        except:
            print u'something wrong with ok button\n'
        try:
            doneButton=self.common_fn.wait_for_element(r"com.android.packageinstaller:id/done_button")
            doneButton.click()
            time.sleep(2)
            print u'install the first app\n'         
        except:
            print u'fail to install the first app\n'           
        try:
            manageButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            if manageButtons[4].text==u'管理':
                manageButtons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
            else:
                print u'manageButton[4].text do not equal to 管理'    
        except:
            print u'not find manage button\n'
            
            
    def appDownloadTask(self):
        try:
            downloadTaskButtons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
            downloadTaskButtons[0].click()
            time.sleep(2)
            print u'go into download task page'
        except:
            print u'fail to go into download task page'
                      
    def startSetPage(self):
        try:
            #self.appHomePage()
            self.appDownloadTask()
            setButton=self.common_fn.wait_for_element(r'com.tclmarket:id/actionbar_settings')
            setButton.click()
            time.sleep(2)
            try:
                title=self.common_fn.wait_for_element(r'com.tclmarket:id/home_title')
                if title.text==u'设置':
                    print u'get set page\n'
                    return True
                else:
                    return False
            except:
                print u'not get the title\n'     
                return False
        except:
            print u'fail to find set button\n'
            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.startSetPage())        
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:79,代码来源:startSetPage.py

示例14: app_manage_page

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [as 别名]
class app_manage_page():
    '''
                             版本 应用商店4.0.1
                             编号 AppStore2-909
                            标题    管理界面验证
        '''
    def __init__(self):
        self.common_fn = CommonFunctions()
      
    def manage_page(self):
        try:
            manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            manage_button_num=self.common_fn.wait_for_element(r'com.tclmarket:id/manager_update_app_tips')
            manage_num=manage_button_num.text
            print manage_num
            if manage_buttons[4].text==u'管理':
                manage_buttons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
            else:
                print u'manage_button[4].text do not equal to 管理' 
                
            try:
                action_texts=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_text',By.ID)
                for i in range(5):
                    print action_texts[i].text
                print u'manage page is right\n'
                try:            
                    action_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/manage_image',By.ID)
                    action_buttons[1].click()
                    time.sleep(2)
                    try:
                        updated_titles=self.common_fn.wait_for_elements('com.tclmarket:id/header_text',By.ID)
                        if updated_titles:
                            print updated_titles[0].text
                            print manage_num
                            manage_num_str=u'可更新('+manage_num+u')'
                            if updated_titles[0].text==manage_num_str:
                                print u'the number of apps to be updated is right\n'
                                return True
                        else:
                            print u'no app to be updated\n' 
                            return True
                    except Exception as e:
                        print u'error 3:'+e
                        print u'can not get number of updated_title \n'
                        return False
                except Exception as e:
                    print u'error 2:'+e
                    print u'action_buttons are wrong\n'    
                    return False
            except Exception as e:
                print u'error 1:'+e
                print u'fail to go into download task page'  
                return False
        except Exception as e:
            print e
            print u'not find manage button\n'
            s = sys.exc_info()
            print 'Error %s on line %d' % (s[1],s[2].tb_lineno)
            return False
        finally:
            self.common_fn.driver.remove_app('com.tencent.qqlive')        
                
    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.manage_page())        
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:71,代码来源:app_manage_page.py

示例15: apk_scanning_page

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import wait_for_elements [as 别名]
class apk_scanning_page():
    '''
                      版本 应用商店4.0.1
                     编号  AppStore2-935 
                    标题    安装包扫描界面
      '''
    def __init__(self):
        self.common_fn = CommonFunctions()
    
                                    
    def app_homepage(self):
        try:
            downloadApps=self.common_fn.wait_for_elements(r'com.tclmarket:id/item_container',By.ID)
            isClick = False
            for app in downloadApps:
                downloadBtn = app.find_element(By.ID,r'com.tclmarket:id/action_text')
                if downloadBtn.text == u'下载':
                    downloadBtn.click()
                    appName = app.find_element(By.ID,r'com.tclmarket:id/name').text
                    isClick = True
                    break
            if not isClick:
                raise Exception('do not have download app at installedAppOpen')
            print u'start to download an app\n'
            time.sleep(50)
        except:
            print u'fail to download the first app\n ' 
        try:
            for i in range(4):
                self.common_fn.element_clk(r'com.android.packageinstaller:id/ok_button')
                #print u'click the next button %d\n' % (i+1)
            time.sleep(30)
            #print u'finish clicking ok\n'
        except Exception as e:
            print e
            print u'something wrong with ok button\n'
            return False 
        try:
            self.common_fn.element_clk(r"com.android.packageinstaller:id/done_button")
            time.sleep(2)
            #print u'install the first app\n'         
        except:
            print u'fail to install the first app\n'     
            return False
        try:
            download_apps=self.common_fn.wait_for_elements(r'com.tclmarket:id/action',By.ID)
            download_apps[1].click()
            print u'start to download the second app\n'
            time.sleep(55)
        except:
            print u'fail to download the second app\n ' 
            return False
        try:    
            self.common_fn.wait_for_element(r'com.android.packageinstaller:id/cancel_button',time_out=90).click() 
            time.sleep(2)
            print u'refuse to install downloaded apk\n'
        except:
            print u'fail to refuse install\n'     
            return False
        finally:
            self.common_fn.driver.remove_app('com.tencent.qqlive') 
            
        try:
            manage_buttons=self.common_fn.wait_for_elements(r'com.tclmarket:id/text',By.ID)
            if manage_buttons[4].text==u'管理':
                manage_buttons[4].click()
                time.sleep(2)
                print u'go into manage page\n'
            else:
                print u'manageButton[4].text do not equal to 管理'
                return False
            try:
                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[3].text==u'安装包扫描' :
                    action_buttons[3].click()
                    print u'get apks scanning page\n'
                else:
                    print u'not get apks scanning page\n'
                    return False 
                try:
                    title=self.common_fn.wait_for_elements(r'com.tclmarket:id/header_text',By.ID)
                    base = baseFunc()
                    if title and len(title) == 1 and u'已安装' in title[0].text:
                        base.uninstallAPP(appName)
                        return True
                    elif title and len(title) == 2 and u'已安装' in title[0].text and u'未安装' in title[1].text:
                        #print u'installed apk is right\n'
                        base.uninstallAPP(appName)
                        return True
                    else:
                        print u'没有发现已安装或未安装列表'
                        return False 
                except:
                    print u'not find apks\n'  
                    s = sys.exc_info()
                    print 'Error "%s" happend on line %d' % (s[1],s[2].tb_lineno)                   
                    return False 
            except:
                print u'not find apks scanning button\n'
#.........这里部分代码省略.........
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:103,代码来源:apk_scanning_page.py


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