2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > IOS在Windows自动化测试之tidevice

IOS在Windows自动化测试之tidevice

时间:2022-12-29 14:29:03

相关推荐

IOS在Windows自动化测试之tidevice

前提安装了一下工具:

1、Windows上配置了Python环境:Python 3.6+

2、Windows上安装了iTunes

IOS在Windows自动化测试之tidevice

tidevice地址

一、安装tidevice库

pip3 install -U "tidevice[openssl]" # Recommend# 如果上面的命令提示安装失败,就试试下面的命令。(不过这种方法安装,配对功能就没有了,因为没有办法进行签名)pip3 install -U tidevice

用法:tidevice [-h] [-v] [-u UDID] [–socket SOCKET]

C:\Users\shenyf\Desktop>tidevice -u 691a8bdxxxxxxxxxx6eb6eb1b423039f9649d7b9 psPID NAME BUNDLE_ID DISPLAY_NAME311 Preferences com.apple.Preferences 设置328 MailCacheDeleteExtension260 StoreKitUIService com.apple.ios.StoreKitUIService iTunes202 ShortcutsWidget379 AppStore com.apple.AppStore App Store139 Spotlightcom.apple.Spotlight Spotlight276 EscrowSecurityAlert187 WeChat com.tencent.xin 微信C:\Users\shenyf\Desktop>

二、查看版本号

C:\Users\shenyf\Desktop>tidevice versiontidevice version 0.5.0

三、列出链接设备

C:\Users\shenyf\Desktop>tidevice listList of apple devices attached691a8bdxxxxxxxxxx6eb6eb1b423039f9649d7b9 iPhone 6s USBC:\Users\shenyf\Desktop>tidevice list --json[{"udid": "691a8bdxxxxxxxxxx6eb6eb1b423039f9649d7b9","name": "iPhone 6s","conn_type": "USB"}]C:\Users\shenyf\Desktop>

四、应用管理

# 安装应用$ tidevice install example.ipa# 指定设备安装$ tidevice --udid $UDID install /example.ipa# 卸载应用$ tidevice uninstall com.example.demo# 启动应用$ tidevice launch com.example.demo# 停止应用$ tidevice kill com.example.demo# 查看已安装应用$ tidevice applist# 查看运行中的应用$ tidevice ps$ tidevice ps --json output as json

五、Run XCTest

请先确保手机上已经安装有WebDriverAgent应用

# 运行XCTEST$ tidevice xctest -B com.facebook.wda.WebDriverAgent.Runner[I 210127 11:40:23 _device:909] BundleID: com.facebook.wda.WebDriverAgent.Runner[I 210127 11:40:23 _device:911] DeviceIdentifier: 12345678901234567890abcdefg[I 210127 11:40:23 _device:773] SignIdentity: 'Apple Development: -Your-Developer-Name-'[I 210127 11:40:23 _device:840] Launch 'com.facebook.wda.WebDriverAgent.Runner' pid: 239[I 210127 11:40:23 _device:1003] ProductVersion: 12.4[I 210127 11:40:24 _device:952] Start execute test plan with IDE version: 29[I 210127 11:40:24 _device:875] WebDriverAgent start successfully# 修改监听端口为8200, 并显示调试日志$ tidevice xctest -B com.facebook.wda.WebDriverAgent.Runner -e USB_PORT:8200 --debug

六、Relay

# 转发请求到手机,类似于iproxy$ tidevice relay 8100 8100# 转发并把传输的内容用hexdump的方法print出来$ tidevice relay -x 8100 8100

运行WebDriverAgent

运行XCTest UITest

挂载开发者镜像

七、查看设备信息

$ tidevice info# 查看设备电源信息$ tidevice info --domain com.apple.mobile.battery --json{"BatteryCurrentCapacity": 53,"BatteryIsCharging": true,"ExternalChargeCapable": true,"ExternalConnected": true,"FullyCharged": false,"GasGaugeCapability": true,"HasBattery": true}

已知域

com.apple.disk_usage

com.apple.disk_usage.factory

com.apple.mobile.battery

com.apple.iqagent

com.apple.purplebuddy

com.apple.PurpleBuddy

com.apple.mobile.chaperone

com.apple.mobile.third_party_termination

com.apple.mobile.lockdownd

com.apple.mobile.lockdown_cache

com.apple.xcode.developerdomain

com.apple.international

com.apple.mobile.data_sync

com.apple.mobile.tethered_sync

com.apple.mobile.mobile_application_usage

com.apple.mobile.backup

com.apple.mobile.nikita

com.apple.mobile.restriction

com.apple.mobile.user_preferences

com.apple.mobile.sync_data_class

com.apple.mobile.software_behavior

com.apple.mobile.iTunes.SQLMusicLibraryPostProcessCommands

com.apple.mobile.iTunes.accessories

com.apple.mobile.internal

com.apple.mobile.wireless_lockdown

com.apple.fairplay

com.apple.iTunes

com.apple.mobile.iTunes.store

com.apple.mobile.iTunes

八、文件操作

# 查看相册内容$ tidevice fsync /DCIM/# 查看T3出行Documents中的内容$ tidevice fsync -B com.t3go.passenger ls /Documents/# 其他操作 rm cat pull push stat tree rmtree mkdir$ tidevice fsync -h# 支持查看 /Documents 的App# com.apple.iMovie iMovie# com.apple.mobilegarageband 库乐队# com.apple.clips 可立拍# com.t3go.passenger T3出行# com.dji.golite DJI Fly# com.duokan.reader 多看阅读

九、其他常用

# 重启$ tidevice reboot# 截图$ tidevice screenshot screenshot.jpg# 输出日志 same as idevicesyslog$ tidevice syslog# 启动苹果设置C:\Users\shenyf\Desktop>tidevice launch com.apple.PreferencesPID: 311

十、性能采集

使用命令行可以直接看到结果,不过最好还是用接口获取

# 性能采集$ tidevice perf -B com.example.demofps {'fps': 0, 'value': 0, 'timestamp': 1620725299495}network {'timestamp': 1620725300511, 'downFlow': 55685.94921875, 'upFlow': 2300.96484375}screenshot {'value': <PIL.PngImagePlugin.PngImageFile image mode=RGB size=231x500 at 0x1037CF760>, 'timestamp': 1620725301374}fps {'fps': 58, 'value': 58, 'timestamp': 1620725873152}cpu {'timestamp': 1620725873348, 'pid': 21243, 'value': 1.2141945711006428}memory {'pid': 21243, 'timestamp': 1620725873348, 'value': 40.5496533203}

如何在python中获得应用程序性能

import timeimport tidevicet = tidevice.Device()perf = tidevice.Performance(t)def callback(_type: tidevice.DataType, value: dict):print("R:", _type.value, value)perf.start("com.apple.Preferences", callback=callback)time.sleep(10)perf.stop()

遇到的问题

1.没有安装iTunes

C:\Users\shenyf\Desktop>tidevice listList of apple devices attachedTraceback (most recent call last):File "d:\python37\lib\runpy.py", line 193, in _run_module_as_main"__main__", mod_spec)File "d:\python37\lib\runpy.py", line 85, in _run_codeexec(code, run_globals)File "D:\Python37\Scripts\tidevice.exe\__main__.py", line 7, in <module>File "d:\python37\lib\site-packages\tidevice\__main__.py", line 743, in mainactions[args.subparser](args)File "d:\python37\lib\site-packages\tidevice\__main__.py", line 78, in cmd_listfor dinfo in um.device_list():File "d:\python37\lib\site-packages\tidevice\_usbmux.py", line 75, in device_listdata = self.send_recv(payload)File "d:\python37\lib\site-packages\tidevice\_usbmux.py", line 46, in send_recvwith self.create_connection() as s:File "d:\python37\lib\site-packages\tidevice\_usbmux.py", line 43, in create_connectionreturn PlistSocket(self.__address, self._next_tag())File "d:\python37\lib\site-packages\tidevice\_safe_socket.py", line 97, in __init__super().__init__(addr)File "d:\python37\lib\site-packages\tidevice\_safe_socket.py", line 48, in __init__self._sock.connect(addr)ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。