• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python uiautomator.Adb类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: adb

class adb(object):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
        self.instAdb=Adb()
        
        self.devSerialNoms= self.instAdb.devices().keys()
        self.devcount = len(self.devSerialNoms)
        self.devSerial = self.instAdb.device_serial()
        
        
    def getSerials(self):
        return self.devSerialNoms
        #return self.devSerialNoms
    
    def getDeviceCount(self):
        return self.devcount
    
    def getSerial(self):
        return self.devSerial
开发者ID:sqler21c,项目名称:Python,代码行数:26,代码来源:Adb.py


示例2: test_serial

    def test_serial(self):
        serial = "abcdef1234567890"
        adb = Adb(serial)
        self.assertEqual(adb.default_serial, serial)

        adb.devices = MagicMock()
        adb.devices.return_value = [serial, "123456"]
        self.assertEqual(adb.device_serial(), serial)
开发者ID:Hening,项目名称:uiautomator,代码行数:8,代码来源:test_adb.py


示例3: test_forward_list

 def test_forward_list(self):
     adb = Adb()
     os.name = 'posix'
     adb.raw_cmd = MagicMock()
     adb.raw_cmd.return_value.communicate.return_value = (b"014E05DE0F02000E    tcp:9008    tcp:9008\r\n489328DKFL7DF    tcp:9008    tcp:9008", b"")
     self.assertEqual(adb.forward_list(), [['014E05DE0F02000E', 'tcp:9008', 'tcp:9008'], ['489328DKFL7DF', 'tcp:9008', 'tcp:9008']])
     os.name = 'nt'
     self.assertEqual(adb.forward_list(), [])
开发者ID:Top-Q,项目名称:uiautomator,代码行数:8,代码来源:test_adb.py


示例4: test_adb_cmd

    def test_adb_cmd(self):
        adb = Adb()
        adb.device_serial = MagicMock()
        adb.device_serial.return_value = "ANDROID_SERIAL"
        adb.raw_cmd = MagicMock()
        args = ["a", "b", "c"]
        adb.cmd(*args)
        adb.raw_cmd.assert_called_once_with("-s", "%s" % adb.device_serial(), *args)

        adb.device_serial.return_value = "ANDROID SERIAL"
        adb.raw_cmd = MagicMock()
        args = ["a", "b", "c"]
        adb.cmd(*args)
        adb.raw_cmd.assert_called_once_with("-s", "'%s'" % adb.device_serial(), *args)
开发者ID:Andy-hpliu,项目名称:uiautomator,代码行数:14,代码来源:test_adb.py


示例5: __init__

    def __init__(self,config=None):
        """

        :return:
        """

        self.config = config




        # dict of devices connected to the hub, key is the device_id
        self.connected_devices = {}

        # dict of active devices , key is alias
        self._devices = {}




        # device_ids available ( eg not actice)
        self.available_devices = []



        self.adb = Adb()
开发者ID:cocoon-project,项目名称:droydrunner,代码行数:26,代码来源:uihub.py


示例6: __init__

 def __init__(self):
     '''
     Constructor
     '''
     self.instAdb=Adb()
     
     self.devSerialNoms= self.instAdb.devices().keys()
     self.devcount = len(self.devSerialNoms)
     self.devSerial = self.instAdb.device_serial()
开发者ID:sqler21c,项目名称:Python,代码行数:9,代码来源:Adb.py


示例7: __init__

 def __init__(self, serial=None):
     """
     """
     logger.info("<p>Device=%s>" % serial, html=True)
     print "<p>Device=%s>" % serial
     self._result = ""
     self.starttime = 0
     self.d = Device(serial)
     self.adb = Adb(serial)
     self.debug = "True"
开发者ID:huaping,项目名称:StabilityKPI,代码行数:10,代码来源:UiTestLib.py


示例8: test_adb_raw_cmd

 def test_adb_raw_cmd(self):
     import subprocess
     adb = Adb()
     adb.adb = MagicMock()
     adb.adb.return_value = "adb"
     args = ["a", "b", "c"]
     with patch("subprocess.Popen") as Popen:
         os.name = "posix"
         adb.raw_cmd(*args)
         Popen.assert_called_once_with(["%s %s" % (adb.adb(), " ".join(args))], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     with patch("subprocess.Popen") as Popen:
         os.name = "nt"
         adb.raw_cmd(*args)
         Popen.assert_called_once_with([adb.adb()] + list(args), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
开发者ID:Hening,项目名称:uiautomator,代码行数:14,代码来源:test_adb.py


示例9: test_adb_from_env

    def test_adb_from_env(self):
        home_dir = '/android/home'
        with patch.dict('os.environ', {'ANDROID_HOME': home_dir}):
            with patch('os.path.exists') as exists:
                exists.return_value = True

                os.name = "posix"  # linux
                adb_obj = Adb()
                adb_path = os.path.join(home_dir, "platform-tools", "adb")
                self.assertEqual(adb_obj.adb(), adb_path)
                exists.assert_called_once_with(adb_path)
                self.assertEqual(adb_obj.adb(), adb_path)
                exists.assert_called_once_with(adb_path) # the second call will return the __adb_cmd directly

                os.name = "nt"  # linux
                adb_obj = Adb()
                adb_path = os.path.join(home_dir, "platform-tools", "adb.exe")
                self.assertEqual(adb_obj.adb(), adb_path)

                exists.return_value = False
                with self.assertRaises(EnvironmentError):
                    Adb().adb()
开发者ID:Hening,项目名称:uiautomator,代码行数:22,代码来源:test_adb.py


示例10: test_devices

 def test_devices(self):
     adb = Adb()
     adb.raw_cmd = MagicMock()
     adb.raw_cmd.return_value.communicate.return_value = (b"List of devices attached \r\n014E05DE0F02000E    device\r\n489328DKFL7DF    device", b"")
     self.assertEqual(adb.devices(), {"014E05DE0F02000E": "device", "489328DKFL7DF": "device"})
     adb.raw_cmd.assert_called_once_with("devices")
     adb.raw_cmd.return_value.communicate.return_value = (b"List of devices attached \n\r014E05DE0F02000E    device\n\r489328DKFL7DF    device", b"")
     self.assertEqual(adb.devices(), {"014E05DE0F02000E": "device", "489328DKFL7DF": "device"})
     adb.raw_cmd.return_value.communicate.return_value = (b"List of devices attached \r014E05DE0F02000E    device\r489328DKFL7DF    device", b"")
     self.assertEqual(adb.devices(), {"014E05DE0F02000E": "device", "489328DKFL7DF": "device"})
     adb.raw_cmd.return_value.communicate.return_value = (b"List of devices attached \n014E05DE0F02000E    device\n489328DKFL7DF    device", b"")
     self.assertEqual(adb.devices(), {"014E05DE0F02000E": "device", "489328DKFL7DF": "device"})
     adb.raw_cmd.return_value.communicate.return_value = (b"not match", "")
     with self.assertRaises(EnvironmentError):
         adb.devices()
开发者ID:Hening,项目名称:uiautomator,代码行数:15,代码来源:test_adb.py


示例11: test_forward_list

    def test_forward_list(self):
        adb = Adb()
        adb.version = MagicMock()
        adb.version.return_value = ['1.0.31', '1', '0', '31']
        adb.raw_cmd = MagicMock()
        adb.raw_cmd.return_value.communicate.return_value = (b"014E05DE0F02000E    tcp:9008    tcp:9008\r\n489328DKFL7DF    tcp:9008    tcp:9008", b"")
        self.assertEqual(adb.forward_list(), [['014E05DE0F02000E', 'tcp:9008', 'tcp:9008'], ['489328DKFL7DF', 'tcp:9008', 'tcp:9008']])

        adb.version.return_value = ['1.0.29', '1', '0', '29']
        with self.assertRaises(EnvironmentError):
            adb.forward_list()
开发者ID:Hening,项目名称:uiautomator,代码行数:11,代码来源:test_adb.py


示例12: set_serial

    def set_serial(self, serial):
        """Specify given *serial* device to perform test.
        or export ANDROID_SERIAL=CXFS42343 if you have many devices connected but you don't use this
        interface

        When you need to use multiple devices, do not use this keyword to switch between devices in test execution.
        And set the serial to each library.
        Using different library name when importing this library according to
        http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html?r=2.8.5.

        Examples:
        | Setting | Value |  Value |  Value |
        | Library | UiTestLib | WITH NAME | Mobile1 |
        | Library | UiTestLib | WITH NAME | Mobile2 |

        And set the serial to each library.
        | Test Case        | Action             | Argument           |
        | Multiple Devices | Mobile1.Set Serial | device_1's serial  |
        |                  | Mobile2.Set Serial | device_2's serial  |
        """
        self.d = Device(serial)
        self.adb = Adb(serial)
开发者ID:huaping,项目名称:StabilityKPI,代码行数:22,代码来源:UiTestLib.py


示例13: BaseClient

class BaseClient(object):

    def __init__(self, device_id):
        self._device_id = device_id
        self._adb_commander = Adb(self._device_id)
        self._logcat_thread = threading.Thread(target=self._start_logcat)
        self._logcat_thread.start()
        self._device = Device(self._device_id)

    def open_app(self):
        self._device.screen.on()
        _package_name, _main_activity_name = utils.get_package_and_main_activity_name()
        os.system('adb -s %s shell am force-stop %s' % (self._device_id, _package_name))
        self._adb_commander.cmd('shell am start -W %s/%s' % (_package_name, _main_activity_name))

    def _start_logcat(self):
        log_file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, 'log'))
        self._adb_commander.cmd('logcat -c' % self._device_id)
        self._adb_commander.cmd('logcat> %s/%s.log' % (log_file_path, self._device_id))

    def stop_logcat(self):
        os.system('ps -e | grep "adb -s %s logcat" | xargs kill' % self._device_id)
开发者ID:ChenFromNB,项目名称:uiautomatorManager,代码行数:22,代码来源:base_lib.py


示例14: test_forward

 def test_forward(self):
     adb = Adb()
     adb.cmd = MagicMock()
     adb.forward(90, 91)
     adb.cmd.assert_called_once_with("forward", "tcp:90", "tcp:91")
     adb.cmd.return_value.wait.assert_called_once_with()
开发者ID:Hening,项目名称:uiautomator,代码行数:6,代码来源:test_adb.py


示例15: print

'''
Created on 2015. 10. 22.

@author: User
'''

import os, sys
from Libs import ClsActivity as CLS

from uiautomator import Device, Adb, AutomatorDevice
from Libs import SaveToLog as saveLog
from Libs import ModelInfo
import Libs.ClsKeyCode


instAdb=Adb()
devSerials= instAdb.devices().keys()
print(type(devSerials))
osType = sys.platform
sndLog = saveLog()

#sndLog = CLS("test", "test")

if len(devSerials) == 1:
    devSerials = instAdb.device_serial()
    mstrDevice = Device(devSerials)
    mstrInfo = mstrDevice.info
else:
    mstrDevSerial, slavDevSerial = devSerials
    mstrDevice = Device(mstrDevSerial)
    slvDevice = Device(slavDevSerial)
开发者ID:sqler21c,项目名称:Python,代码行数:31,代码来源:uiautotest.py


示例16: test_device_serial

    def test_device_serial(self):
        with patch.dict('os.environ', {'ANDROID_SERIAL': "ABCDEF123456"}):
            adb = Adb()
            adb.devices = MagicMock()
            adb.devices.return_value = {"ABCDEF123456": "device"}
            self.assertEqual(adb.device_serial(), "ABCDEF123456")
        with patch.dict('os.environ', {'ANDROID_SERIAL': "ABCDEF123456"}):
            adb = Adb()
            adb.devices = MagicMock()
            adb.devices.return_value = {"ABCDEF123456": "device", "123456ABCDEF": "device"}
            self.assertEqual(adb.device_serial(), "ABCDEF123456")
        with patch.dict('os.environ', {'ANDROID_SERIAL': "HIJKLMN098765"}):
            adb = Adb()
            adb.devices = MagicMock()
            adb.devices.return_value = {"ABCDEF123456": "device", "123456ABCDEF": "device"}
            with self.assertRaises(EnvironmentError):
                adb.device_serial()
        with patch.dict('os.environ', {}, clear=True):
            adb = Adb()
            adb.devices = MagicMock()
            adb.devices.return_value = {"ABCDEF123456": "device", "123456ABCDEF": "device"}
            with self.assertRaises(EnvironmentError):
                adb.device_serial()
        with patch.dict('os.environ', {}, clear=True):
            adb = Adb()
            adb.devices = MagicMock()
            adb.devices.return_value = {"ABCDEF123456": "device"}
            print(adb.devices())
            self.assertEqual(adb.device_serial(), "ABCDEF123456")

        with self.assertRaises(EnvironmentError):
            adb = Adb()
            adb.devices = MagicMock()
            adb.devices.return_value = {}
            adb.device_serial()
开发者ID:Hening,项目名称:uiautomator,代码行数:35,代码来源:test_adb.py


示例17: test_adb_cmd_server_host

    def test_adb_cmd_server_host(self):
        adb = Adb(adb_server_host="localhost", adb_server_port=5037)
        adb.adb = MagicMock()
        adb.adb.return_value = "adb"
        adb.device_serial = MagicMock()
        adb.device_serial.return_value = "ANDROID_SERIAL"
        args = ["a", "b", "c"]
        with patch("subprocess.Popen") as Popen:
            os.name = "nt"
            adb.raw_cmd(*args)
            Popen.assert_called_once_with(
                [adb.adb()] + args,
                shell=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE
            )

        adb = Adb(adb_server_host="test.com", adb_server_port=1000)
        adb.adb = MagicMock()
        adb.adb.return_value = "adb"
        adb.device_serial = MagicMock()
        adb.device_serial.return_value = "ANDROID_SERIAL"
        args = ["a", "b", "c"]
        with patch("subprocess.Popen") as Popen:
            os.name = "posix"
            adb.raw_cmd(*args)
            Popen.assert_called_once_with(
                [" ".join([adb.adb()] + ["-H", "test.com", "-P", "1000"] + args)],
                shell=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE
            )
开发者ID:Andy-hpliu,项目名称:uiautomator,代码行数:32,代码来源:test_adb.py


示例18: UiHub

class UiHub(object):
    """
        represents a set of Device

    """

    def __init__(self,config=None):
        """

        :return:
        """

        self.config = config




        # dict of devices connected to the hub, key is the device_id
        self.connected_devices = {}

        # dict of active devices , key is alias
        self._devices = {}




        # device_ids available ( eg not actice)
        self.available_devices = []



        self.adb = Adb()




    def device_list(self):
        """

        :return: list : list of android connected device
        """
        self.connected_devices = self.adb.devices()
        return self.connected_devices



    def device(self,alias):
        """
            return the given connected device info
        :param alias:
        :return:
        """
        try:
            c = self.connected_devices
            assert c != {}
        except:
            self.device_list()
        return self.connected_devices[alias]



    def add_device(self,alias,serial=None,applications=None):
        """
            add a device , make it active

            if no serial is specified take a random device_it (not used ) amoung the connected devices


        :param allias:
        :param serial:
        :param applications:
        :return:
        """
        if not serial:
            # no serial specified: take a random one
            raise NotImplementedError


        self._devices[alias]= UiDevice(alias,serial=serial,applications=applications,config=self.config)
        return self._devices[alias]



    def iter_device(self):
        """
            iteration over active devices
        :return:
        """


    def find_device(self,**kwargs):
        """
开发者ID:cocoon-project,项目名称:droydrunner,代码行数:92,代码来源:uihub.py


示例19: __init__

 def __init__(self, device_id):
     self._device_id = device_id
     self._adb_commander = Adb(self._device_id)
     self._logcat_thread = threading.Thread(target=self._start_logcat)
     self._logcat_thread.start()
     self._device = Device(self._device_id)
开发者ID:ChenFromNB,项目名称:uiautomatorManager,代码行数:6,代码来源:base_lib.py


示例20: test_adb_cmd_server_host

    def test_adb_cmd_server_host(self):
        adb = Adb(adb_server_host="localhost", adb_server_port=5037)
        adb.device_serial = MagicMock()
        adb.device_serial.return_value = "ANDROID_SERIAL"
        adb.raw_cmd = MagicMock()
        args = ["a", "b", "c"]
        adb.cmd(*args)
        adb.raw_cmd.assert_called_once_with("-H", "localhost", "-P", "5037", "-s", "%s" % adb.device_serial(), *args)

        adb = Adb(adb_server_host="localhost")
        adb.device_serial = MagicMock()
        adb.device_serial.return_value = "ANDROID_SERIAL"
        adb.raw_cmd = MagicMock()
        args = ["a", "b", "c"]
        adb.cmd(*args)
        adb.raw_cmd.assert_called_once_with("-H", "localhost", "-s", "%s" % adb.device_serial(), *args)
开发者ID:Prathapnagaraj,项目名称:uiautomator,代码行数:16,代码来源:test_adb.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python uiautomator.AutomatorServer类代码示例发布时间:2022-05-27
下一篇:
Python uiautomator.d函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap