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


Python Device.dump方法代码示例

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


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

示例1: ui_interact

# 需要导入模块: from uiautomator import Device [as 别名]
# 或者: from uiautomator.Device import dump [as 别名]
                filehandler = logging.FileHandler(dir_data + '/UiDroid-Console.log')
                filehandler.setLevel(logging.DEBUG)
                logger.addHandler(filehandler)
                filehandler.setFormatter(formatter)

        
                #time.sleep(30)
                ui_interact()
                flag = False
            except:
                pass
        # dev.screenshot(dir_data + current_time + ".png")
        os.system('adb -s ' + series + ' shell /system/bin/screencap -p /sdcard/screenshot.png')
        os.system('adb -s ' + series + ' pull /sdcard/screenshot.png ' + dir_data)
        try:
            dev.dump(dir_data + current_time + "hierarchy.xml")
        except:
            print 'except xml'
        logger.info('screen shot at ' + current_time)

        
        dev.screen.on()
        dev.press.home()
        #time.sleep(20)
        #package_list = os.popen('adb -s ' + series + ' shell cat /data/system/packages.list')
        #logger.info(package_list.readlines())
        #ps_list = os.popen('adb -s ' + series + ' shell ps')
        #logger.info(ps_list.readlines())
        os.popen('adb -s ' + series + ' shell am force-stop ' + package)
        os.popen('adb -s ' + series + ' uninstall ' + package)
        logger.info('uninstall')
开发者ID:majestyhao,项目名称:Traffic_UI,代码行数:33,代码来源:privicy_pcap.py

示例2: ModelInfo

# 需要导入模块: from uiautomator import Device [as 别名]
# 或者: from uiautomator.Device import dump [as 别名]

#.........这里部分代码省略.........
        return self.mstrDevice.drag(sx, sy, ex, ey, steps)
       
    #screen action of the device   
    def setOrientation(self,scrAct='natural', choiceDevice='mstr'):
        '''
            Description
                
            param
                d.orientation = 'l' or 'left'
                d.orientation = 'r' or 'right'
                d.orientation = 'n' or 'natural'
            return : None
        '''
        self.mstrDevice.orientation = scrAct
    
    def setFreezeRotation(self,condition=False,choiceDevice='mstr'):
        '''
            param:
                condition : False un-freeze rotation
            return : None
        '''
        self.mstrDevice.freeze_rotation(condition)
    
    
            
    def takeScreenShot(self, choiceDevice = 'mstr'):
        '''
            Description:
                take screenshot and save to local file 'home.png' can work until android 4.2
            param
                image name
        '''
        
    def dumpWindowHeirarchy(self,filename='./log/hierachy.xml'):
        return self.mstrDevice.dump(filename)
        
    def dumpWindowHeirarchyStream(self):
        return self.mstrDevice.dump()
        
    def notification(self):
        '''
            Open notification, can not work until android 4.3
            return : Boolean
        '''
        return self.mstrDevice.open.Notification()
    
    def quickSettings(self):
        '''
            open quick settins, can not work until android 4.3
            return : Boolean 
        '''
        return self.mstrDevice.open.quick_settings()
    def waitidle(self):
        '''
            wait for current window to idle
            return : None
        '''
        self.mstrDevice.wait.idle()
        
    def waitWindowUpdate(self):
        '''
            wait until window upate event occurs
            return : Boolean
        '''
        self.mstrDevice.wait.update()
        
开发者ID:sqler21c,项目名称:Python,代码行数:69,代码来源:ModelInfo.py

示例3: AdbDevice

# 需要导入模块: from uiautomator import Device [as 别名]
# 或者: from uiautomator.Device import dump [as 别名]
class AdbDevice(object):
    hiddenService = 'com.fuhu.settingshelper/.SettingsHelperService'
    LIST_SYSTEM = 'system'
    LIST_ALL = 'all'
    LIST_3RD_PARTY = '3rd'
    LIST_RECENT = 'recent'
    orientation = ['natural', 'left', 'upsidedown', 'right']

    def __init__(self, serialno=None):
        self.lock = threading.Semaphore()
        self.cmd = AdbCmd(serialno)
        self.serialno = serialno

    def connect(self):
        self.d = Device(self.serialno)
        self.d.orientation # notify to connect

        #         self.d, self.serialno = ViewClient.connectToDeviceOrExit(serialno=self.serialno)
    #         self.vc = ViewClient(self.d, self.serialno, compresseddump=False, ignoreuiautomatorkilled=True, autodump=False)

    def startActivity(self, component):
        component = component.replace('$', '\$')
        self.cmd.shell(['am', 'start', '-n', component, '--activity-clear-task'])

    def isConnected(self):
        if self.__getDevices(self.serialno):
            return True
        else:
            return False

    def listPackages(self):
        return self.cmd.shell(['pm', 'list', 'package'], output=True)

    def reboot(self):
        self.cmd.reboot()

    def dump(self, compressed=False):
        return self.d.dump(compressed=compressed).encode('utf-8')

    @staticmethod
    def retrieveSelector(point, selectors):
        shortestDistance = 500000
        result = None
        for selector in selectors:
            print selector.className
            bounds = selector.info['bounds']
            if bounds['right'] >= point[0] >= bounds['left'] and bounds['top'] >= point[1] >= bounds['bottom']:
                return selector

        for selector in selectors:

            bounds = selector.info['bounds']
            distance = (((bounds['left'] + bounds['top']) / 2 - point[0]) ** 2 + (
                (bounds['left'] + bounds['bottom']) / 2 - point[1]) ** 2) ** 0.5
            if shortestDistance > distance:
                shortestDistance = distance
                result = selector
        return result

    def checkSamePoint(self, point, info, isLongClick=False):
        if not self.isScreenOn():
            self.powerBtn()
            if self.isLocked():
                self.unlock()

        if len(info) == 2:
            if self.d.info['currentPackageName'] == info['packageName']:
                self.cmd.shell(['input', 'tap', str(point[0]), str(point[1])])
                return {'answer': True, 'reason': 'it is the navigation bar'}
            else:
                return {'answer': False, 'reason': 'unknown view'}

        if info['content-desc'] != '':
            uiObject = self.d(description=info['content-desc'])
            if self.__checkIncludePoint(uiObject, point):
                self.cmd.shell(['input', 'tap', str(point[0]), str(point[1])])
            else:
                uiObject.click()

            return {'answer': True, 'reason': 'find by description'}

        if info['text'] != '':
            uiObject = self.d(text=info['text'])
            if self.__checkIncludePoint(uiObject, point):
                self.cmd.shell(['input', 'tap', str(point[0]), str(point[1])])
            else:
                uiObject.click()
            return {'answer': True, 'reason': 'find by text'}

        currentViewMap = self.getTouchViewInfo(point)
        if currentViewMap:
            if currentViewMap['package'] == info['package']:
                if currentViewMap['class'] == info['class']:
                    self.d.click(point[0], point[1])
                    return {'answer': True, 'reason': 'Find the similar view'}
                else:
                    return {'answer': False, 'reason': 'the view doesn\'t be found.'}
            else:
                return {'answer': False, 'reason': 'In the wrong page'}
        else:
#.........这里部分代码省略.........
开发者ID:ChenYuTingJerry,项目名称:AutoSense_2,代码行数:103,代码来源:Adb.py


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