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


Python CommonFunctions.element_clk方法代码示例

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


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

示例1: __init__

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

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import element_clk [as 别名]
class startOperate():
    """4.0.1启动类"""

    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        self.common_fn = CommonFunctions()
        
    #----------------------------------------------------------------------
    def baseOperate(self):
        """4.0.1版本基本操作"""
        
        #关闭升级提示
        if not self.common_fn.wait_for_element(r'android:id/alertTitle',By.ID) == None:
            print 'find alertTitle'
            self.common_fn.element_clk(r'android:id/button2')
            
        time.sleep(5)
        
        return True
开发者ID:sunshine2176,项目名称:TCLMarketAutoTest,代码行数:22,代码来源:startOperate.py

示例3: startSearchPage

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

示例4: apk_scanning_page

# 需要导入模块: from common.py_common_keyword.CommonFunctions import CommonFunctions [as 别名]
# 或者: from common.py_common_keyword.CommonFunctions.CommonFunctions import element_clk [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.element_clk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。